locationrequestmgmt/networkrequesthandler/src/privacyandlocationrequesthandler.cpp
branchRCL_3
changeset 54 0c2046328c85
parent 52 29dbbeac905d
child 55 c92d4f3c47c5
equal deleted inserted replaced
52:29dbbeac905d 54:0c2046328c85
    13 // Description:
    13 // Description:
    14 //
    14 //
    15 
    15 
    16 #include <e32std.h>
    16 #include <e32std.h>
    17 #include <e32property.h>
    17 #include <e32property.h>
       
    18 #include <centralrepository.h>
       
    19 
       
    20 #ifdef SYMBIAN_FEATURE_MANAGER
       
    21     #include <featdiscovery.h>
       
    22     #include <featureuids.h>
       
    23 #endif
    18 
    24 
    19 // LBS-specific
    25 // LBS-specific
    20 #include <lbs.h>
    26 #include <lbs.h>
    21 #include <lbs/lbsadmin.h>
    27 #include <lbs/lbsadmin.h>
    22 #include <lbs/lbslocerrors.h>
    28 #include <lbs/lbslocerrors.h>
    23 #include <lbs/lbslocclasstypes.h>
    29 #include <lbs/lbslocclasstypes.h>
    24 
    30 
    25 #include "nrhpanic.h"
    31 #include "nrhpanic.h"
    26 #include "lbsdevloggermacros.h"
    32 #include "lbsdevloggermacros.h"
    27 #include "lbsqualityprofile.h"
    33 #include "lbsqualityprofile.h"
       
    34 #include "lbsrootcenrepdefs.h"
       
    35 #include "lbspositioningstatusprops.h"
    28 
    36 
    29 #include "privacyandlocationrequesthandler.h"
    37 #include "privacyandlocationrequesthandler.h"
    30 
    38 
    31 // Special 'invalid session' SessionId.
    39 // Special 'invalid session' SessionId.
    32 const TLbsNetSessionIdInt KInvalidSessionId(TUid::Uid(0), 0);
    40 const TLbsNetSessionIdInt KInvalidSessionId(TUid::Uid(0), 0);
    91 		iFsmArray.Remove(index);
    99 		iFsmArray.Remove(index);
    92 		}
   100 		}
    93 	
   101 	
    94 	iFsmArray.ResetAndDestroy();
   102 	iFsmArray.ResetAndDestroy();
    95 
   103 
       
   104     // force the count of active network initiated positioning sessions to 0
       
   105 	// this supports the pre-APE centric architecture wherein the NRH is
       
   106 	// destroyed on completion of network initiated positioning. 
       
   107     RProperty::Set(iPosStatusCategory, KLbsNiPositioningStatusKey, 0);
    96 
   108 
    97 	delete iEmergencyFsm;
   109 	delete iEmergencyFsm;
    98     delete iAgpsInterface;
   110     delete iAgpsInterface;
    99     delete iPrivacyHandler;
   111     delete iPrivacyHandler;
   100 	}
   112 	}
   159 		{
   171 		{
   160 		LBSLOG_ERR2(ELogP3, "Failed to get KLbsSpecialFeatureIntermediateFutileUpdate (err %d)", err);
   172 		LBSLOG_ERR2(ELogP3, "Failed to get KLbsSpecialFeatureIntermediateFutileUpdate (err %d)", err);
   161 		}
   173 		}
   162 	LBSLOG2(ELogP3, "Using KLbsSpecialFeatureIntermediateFutileUpdate = %d", specialFeature);
   174 	LBSLOG2(ELogP3, "Using KLbsSpecialFeatureIntermediateFutileUpdate = %d", specialFeature);
   163 	iSpecialFeatureIntermediateFutileUpdate = (specialFeature == CLbsAdmin::ESpecialFeatureOn) ? ETrue : EFalse;
   175 	iSpecialFeatureIntermediateFutileUpdate = (specialFeature == CLbsAdmin::ESpecialFeatureOn) ? ETrue : EFalse;
       
   176 
       
   177 #if defined __WINSCW__ && defined SYMBIAN_CELLMO_CENTRIC
       
   178 	iLocationManagementSupported = EFalse;
       
   179 #else
       
   180 #ifdef SYMBIAN_FEATURE_MANAGER
       
   181     iLocationManagementSupported = CFeatureDiscovery::IsFeatureSupportedL(NFeature::KLocationManagement);
       
   182 #else
       
   183     __ASSERT_ALWAYS(EFalse, User::Invariant()); // Would happen on older versions of symbian OS if this code ever backported
       
   184 #endif // SYMBIAN_FEATURE_MANAGER
       
   185 #endif // __WINSCW__ && defined SYMBIAN_CELLMO_CENTRIC
       
   186     
       
   187     // Get the CategoryUid from the cenrep file owned by LbsRoot for accessing Positioning Status P&S Keys
       
   188     CRepository* rep = CRepository::NewLC(KLbsCenRepUid);
       
   189     TInt posStatusCategory;
       
   190     err = rep->Get(KNiPositioningStatusAPIKey, posStatusCategory);
       
   191     User::LeaveIfError(err);
       
   192     CleanupStack::PopAndDestroy(rep);
       
   193     iPosStatusCategory = TUid::Uid(posStatusCategory);
   164 	}
   194 	}
   165 
   195 
   166 
   196 
   167 
   197 
   168 /**
   198 /**
   280 		}
   310 		}
   281 
   311 
   282 	if (fsm)
   312 	if (fsm)
   283 		{
   313 		{
   284 		// Add the state machine to the buffer.
   314 		// Add the state machine to the buffer.
   285 		TInt err = iFsmArray.Append(fsm);
   315 		iFsmArray.Append(fsm);
   286 		if( err != KErrNone )
       
   287 			{
       
   288 			delete fsm;
       
   289 			return NULL;
       
   290 			}
       
   291 	
   316 	
   292 		iNumActiveSessions++; // conceptually, a session starts when a Fsm is created for it
   317 		iNumActiveSessions++; // conceptually, a session starts when a Fsm is created for it
   293 
   318 
   294 		}
   319 		}
   295 	
   320 	
   688 
   713 
   689 RLbsNetworkRegistrationStatus& CPrivacyAndLocationHandler::NetworkRegistrationStatus()
   714 RLbsNetworkRegistrationStatus& CPrivacyAndLocationHandler::NetworkRegistrationStatus()
   690 	{
   715 	{
   691 	return iNetRegStatus;
   716 	return iNetRegStatus;
   692 	}
   717 	}
       
   718 
       
   719 // increments the P&S key tracking mobile terminated positioning requests
       
   720 void CPrivacyAndLocationHandler::IncrementPositioningStatus()
       
   721     {
       
   722     TInt count;     
       
   723     RProperty::Get(iPosStatusCategory, KLbsNiPositioningStatusKey, count);
       
   724     RProperty::Set(iPosStatusCategory, KLbsNiPositioningStatusKey, count+1);
       
   725     }
       
   726 
       
   727 // decrements the P&S key tracking mobile terminated positioning requests
       
   728 // if location management is supported. In the alternative architecture,
       
   729 // the NRH is not aware of the positioning session's progress, but is 
       
   730 // transient. Therefore the positioning status is set to zero in the 
       
   731 // class destructor.
       
   732 void CPrivacyAndLocationHandler::DecrementPositioningStatus()
       
   733     {
       
   734     if (iLocationManagementSupported)
       
   735         {
       
   736         TInt count;     
       
   737         RProperty::Get(iPosStatusCategory, KLbsNiPositioningStatusKey, count);
       
   738         if(count>0)
       
   739             {
       
   740             RProperty::Set(iPosStatusCategory, KLbsNiPositioningStatusKey, count-1);
       
   741             }
       
   742         else
       
   743             {
       
   744             LBSLOG_ERR(ELogP3, "CPrivacyAndLocationHandler::DecrementPositioningStatus() - Incorrect Positioning Status count\n");
       
   745             }
       
   746         }
       
   747     }
   693 	
   748 	
   694 
   749 
   695 /**
   750 /**
   696 */
   751 */
   697 MX3pStatusHandler& CPrivacyAndLocationHandler::X3pStatusHandler()
   752 MX3pStatusHandler& CPrivacyAndLocationHandler::X3pStatusHandler()
   918 																TInt aReason)
   973 																TInt aReason)
   919 	{
   974 	{
   920 	if(aSessionId == iFsm->SessionId())
   975 	if(aSessionId == iFsm->SessionId())
   921 		{
   976 		{
   922 		iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitSessionComplete, aReason);
   977 		iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitSessionComplete, aReason);
   923 		iFsm->ChangeState(CLbsPrivLocFsm::EStateIdle, aSessionId);	            
   978 		iFsm->ChangeState(CLbsPrivLocFsm::EStateIdle, aSessionId);
   924 		}		
   979 		}		
   925 	}
   980 	}
   926 
   981 
   927 /** Called when a reference position arrives from the network.
   982 /** Called when a reference position arrives from the network.
   928 */
   983 */
  1057 RLbsNetworkRegistrationStatus& CLbsPrivLocStateBase::LbsNetworkRegistrationStatus()
  1112 RLbsNetworkRegistrationStatus& CLbsPrivLocStateBase::LbsNetworkRegistrationStatus()
  1058 	{
  1113 	{
  1059 	return iFsm->PrivLocHandler().NetworkRegistrationStatus();
  1114 	return iFsm->PrivLocHandler().NetworkRegistrationStatus();
  1060 	}
  1115 	}
  1061 
  1116 
       
  1117 /*
       
  1118  * increments the network initiated positioning status count
       
  1119  * and remembers that it has done
       
  1120  */
       
  1121 void CLbsPrivLocStateBase::IncrementPositioningStatus()
       
  1122     {
       
  1123     iFsm->PrivLocHandler().IncrementPositioningStatus();
       
  1124     iFsm->WasPositioningStatusIncremented() = ETrue;
       
  1125     }
       
  1126 
       
  1127 
  1062 // ----------------------------------------------------------------------------- 
  1128 // ----------------------------------------------------------------------------- 
  1063 // 
  1129 // 
  1064 // ----------------------- Class CLbsPrivLocIdleState --------------------
  1130 // ----------------------- Class CLbsPrivLocIdleState --------------------
  1065 //
  1131 //
  1066 // Implements the Idle state of the Privacy and Location Request Handler
  1132 // Implements the Idle state of the Privacy and Location Request Handler
  1132     if(iFsm->WasPrivacyResponseReceivedStateExited())
  1198     if(iFsm->WasPrivacyResponseReceivedStateExited())
  1133         {
  1199         {
  1134         // The request relates to a rejected privacy request
  1200         // The request relates to a rejected privacy request
  1135         // or a request for this session which has already been answered. 
  1201         // or a request for this session which has already been answered. 
  1136         // In either case, it should be refused. The message is sent to the
  1202         // In either case, it should be refused. The message is sent to the
  1137         // network gateway as apart of exit from the state, but we want to 
  1203         // network gateway as a part of exit from the state, but we want to 
  1138         // remain in Idle state.
  1204         // remain in Idle state.
  1139         iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitCancelledByPrivacyController, KErrAccessDenied);
  1205         iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitCancelledByPrivacyController, KErrAccessDenied);
  1140         iFsm->ChangeState(CLbsPrivLocFsm::EStateIdle, aSessionId);
  1206         iFsm->ChangeState(CLbsPrivLocFsm::EStateIdle, aSessionId);
  1141         }
  1207         }
  1142     else
  1208     else
  1186 				TBool aIsEmergency,
  1252 				TBool aIsEmergency,
  1187 				const TLbsExternalRequestInfo& aExternalRequestInfo,
  1253 				const TLbsExternalRequestInfo& aExternalRequestInfo,
  1188 				const TLbsNetPosRequestPrivacyInt& aNetPosRequestPrivacy)
  1254 				const TLbsNetPosRequestPrivacyInt& aNetPosRequestPrivacy)
  1189 	{
  1255 	{
  1190 	iFsm->SessionType() = aSessionType;
  1256 	iFsm->SessionType() = aSessionType;
       
  1257 	iFsm->ExternalRequestType() = aExternalRequestInfo.RequestType();
  1191 	iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitPrivacyRequestReceived, KErrNone);
  1258 	iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitPrivacyRequestReceived, KErrNone);
  1192 	TPrivLocWaitPrivResponseParams privacyRequestParams(	aSessionId, 
  1259 	TPrivLocWaitPrivResponseParams privacyRequestParams(	aSessionId, 
  1193 													aSessionType,
  1260 													aSessionType,
  1194 													aExternalRequestInfo, 
  1261 													aExternalRequestInfo, 
  1195 													aNetPosRequestPrivacy,
  1262 													aNetPosRequestPrivacy,
  1295 						}
  1362 						}
  1296 					
  1363 					
  1297 					}
  1364 					}
  1298 				}		
  1365 				}		
  1299 				
  1366 				
  1300 			// For MtLrs the Protcol module should not
  1367 			// For MtLrs the Protocol module should not
  1301 			// send a REF position until after we have sent the Priv response to the PM 
  1368 			// send a REF position until after we have sent the Priv response to the PM 
  1302 	            
  1369 	            
  1303 			// Inform network of the privacy response for normal privacy requests.
  1370 			// Inform network of the privacy response for normal privacy requests.
  1304 			if (iFsm->SessionType() == TLbsNetworkEnumInt::EServiceMobileTerminated)
  1371 			if (iFsm->SessionType() == TLbsNetworkEnumInt::EServiceMobileTerminated)
  1305 				{
  1372 				{
  1368 		iFsm->PrivacyResponse() = aRequestResult;
  1435 		iFsm->PrivacyResponse() = aRequestResult;
  1369 		if(iFsm->PrivacyResponse() == TLbsNetworkEnumInt::EPrivacyResponseAccepted)
  1436 		if(iFsm->PrivacyResponse() == TLbsNetworkEnumInt::EPrivacyResponseAccepted)
  1370 			{
  1437 			{
  1371 			// Tell the AGPS handler that we are going to start a location request soon.
  1438 			// Tell the AGPS handler that we are going to start a location request soon.
  1372 			AgpsInterface()->PreStartPositioning(iFsm->SessionId(), iFsm->IsEmergency());
  1439 			AgpsInterface()->PreStartPositioning(iFsm->SessionId(), iFsm->IsEmergency());
       
  1440 			
       
  1441 			// Set the Positioning Status for the UI indicator.
       
  1442 			// Not done for silent requests.
       
  1443 			if (iFsm->ExternalRequestType() < TLbsExternalRequestInfo::ERequestSingleShotSilent)
       
  1444 			    {
       
  1445                 IncrementPositioningStatus();
       
  1446 			    }
  1373 			
  1447 			
  1374 			if(iFsm->LocReqReceived())
  1448 			if(iFsm->LocReqReceived())
  1375 				{				
  1449 				{				
  1376 				TPrivLocWaitLocationUpdateParams updateRequestParams(iFsm->SessionId(),
  1450 				TPrivLocWaitLocationUpdateParams updateRequestParams(iFsm->SessionId(),
  1377 																iFsm->PosRequestMethod(),
  1451 																iFsm->PosRequestMethod(),
  2490 	iIsEmergency(EFalse),
  2564 	iIsEmergency(EFalse),
  2491 	iSessionType(TLbsNetworkEnumInt::EServiceNone),
  2565 	iSessionType(TLbsNetworkEnumInt::EServiceNone),
  2492 	iRefPosProcessed(EFalse),
  2566 	iRefPosProcessed(EFalse),
  2493 	iLocReqReceived(EFalse),
  2567 	iLocReqReceived(EFalse),
  2494 	iReqCancelled(EFalse),
  2568 	iReqCancelled(EFalse),
  2495 	iWasPrivacyResponseReceivedStateExited(EFalse)
  2569 	iWasPrivacyResponseReceivedStateExited(EFalse),
       
  2570 	iPositioningStatusIncremented(EFalse)
  2496 	{	
  2571 	{	
  2497 	}
  2572 	}
  2498 	
  2573 	
  2499 // ----------------------------------------------------------------------------- 
  2574 // ----------------------------------------------------------------------------- 
  2500 // CLbsPrivLocFsm::~CLbsPrivLocFsm
  2575 // CLbsPrivLocFsm::~CLbsPrivLocFsm
  2615 									const TLbsNetSessionIdInt& aSessionId,
  2690 									const TLbsNetSessionIdInt& aSessionId,
  2616 									TInt aReason)
  2691 									TInt aReason)
  2617 	{
  2692 	{
  2618 	LBSLOG3(ELogP3, "FSM(%d) OnSessionComplete reason=%d",iSessionId.SessionNum(),aReason);
  2693 	LBSLOG3(ELogP3, "FSM(%d) OnSessionComplete reason=%d",iSessionId.SessionNum(),aReason);
  2619 	iCurrentState->OnSessionComplete(aSessionId, aReason);
  2694 	iCurrentState->OnSessionComplete(aSessionId, aReason);
       
  2695 	
       
  2696     // update the positioning status. Note this is updated only if it was previously
       
  2697     // incremented as a result of this session.
       
  2698     if (WasPositioningStatusIncremented())
       
  2699         {
       
  2700         PrivLocHandler().DecrementPositioningStatus();
       
  2701         WasPositioningStatusIncremented() = EFalse;
       
  2702         }
  2620 	}
  2703 	}
  2621 
  2704 
  2622 // ----------------------------------------------------------------------------- 
  2705 // ----------------------------------------------------------------------------- 
  2623 // CLbsPrivLocFsm::OnNetLocRequest
  2706 // CLbsPrivLocFsm::OnNetLocRequest
  2624 // Description: The Message Switch has passed on a request for a position update
  2707 // Description: The Message Switch has passed on a request for a position update