locationrequestmgmt/networkrequesthandler/src/privacyandlocationrequesthandler.cpp
changeset 48 81c9bee26a45
parent 0 9cfd9a3ee49c
child 57 3267d9ea3e98
equal deleted inserted replaced
23:2965a06983dc 48:81c9bee26a45
    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 /**
   683 
   713 
   684 RLbsNetworkRegistrationStatus& CPrivacyAndLocationHandler::NetworkRegistrationStatus()
   714 RLbsNetworkRegistrationStatus& CPrivacyAndLocationHandler::NetworkRegistrationStatus()
   685 	{
   715 	{
   686 	return iNetRegStatus;
   716 	return iNetRegStatus;
   687 	}
   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     }
   688 	
   748 	
   689 
   749 
   690 /**
   750 /**
   691 */
   751 */
   692 MX3pStatusHandler& CPrivacyAndLocationHandler::X3pStatusHandler()
   752 MX3pStatusHandler& CPrivacyAndLocationHandler::X3pStatusHandler()
   913 																TInt aReason)
   973 																TInt aReason)
   914 	{
   974 	{
   915 	if(aSessionId == iFsm->SessionId())
   975 	if(aSessionId == iFsm->SessionId())
   916 		{
   976 		{
   917 		iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitSessionComplete, aReason);
   977 		iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitSessionComplete, aReason);
   918 		iFsm->ChangeState(CLbsPrivLocFsm::EStateIdle, aSessionId);	            
   978 		iFsm->ChangeState(CLbsPrivLocFsm::EStateIdle, aSessionId);
   919 		}		
   979 		}		
   920 	}
   980 	}
   921 
   981 
   922 /** Called when a reference position arrives from the network.
   982 /** Called when a reference position arrives from the network.
   923 */
   983 */
  1052 RLbsNetworkRegistrationStatus& CLbsPrivLocStateBase::LbsNetworkRegistrationStatus()
  1112 RLbsNetworkRegistrationStatus& CLbsPrivLocStateBase::LbsNetworkRegistrationStatus()
  1053 	{
  1113 	{
  1054 	return iFsm->PrivLocHandler().NetworkRegistrationStatus();
  1114 	return iFsm->PrivLocHandler().NetworkRegistrationStatus();
  1055 	}
  1115 	}
  1056 
  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 
  1057 // ----------------------------------------------------------------------------- 
  1128 // ----------------------------------------------------------------------------- 
  1058 // 
  1129 // 
  1059 // ----------------------- Class CLbsPrivLocIdleState --------------------
  1130 // ----------------------- Class CLbsPrivLocIdleState --------------------
  1060 //
  1131 //
  1061 // Implements the Idle state of the Privacy and Location Request Handler
  1132 // Implements the Idle state of the Privacy and Location Request Handler
  1127     if(iFsm->WasPrivacyResponseReceivedStateExited())
  1198     if(iFsm->WasPrivacyResponseReceivedStateExited())
  1128         {
  1199         {
  1129         // The request relates to a rejected privacy request
  1200         // The request relates to a rejected privacy request
  1130         // or a request for this session which has already been answered. 
  1201         // or a request for this session which has already been answered. 
  1131         // 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
  1132         // 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 
  1133         // remain in Idle state.
  1204         // remain in Idle state.
  1134         iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitCancelledByPrivacyController, KErrAccessDenied);
  1205         iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitCancelledByPrivacyController, KErrAccessDenied);
  1135         iFsm->ChangeState(CLbsPrivLocFsm::EStateIdle, aSessionId);
  1206         iFsm->ChangeState(CLbsPrivLocFsm::EStateIdle, aSessionId);
  1136         }
  1207         }
  1137     else
  1208     else
  1181 				TBool aIsEmergency,
  1252 				TBool aIsEmergency,
  1182 				const TLbsExternalRequestInfo& aExternalRequestInfo,
  1253 				const TLbsExternalRequestInfo& aExternalRequestInfo,
  1183 				const TLbsNetPosRequestPrivacyInt& aNetPosRequestPrivacy)
  1254 				const TLbsNetPosRequestPrivacyInt& aNetPosRequestPrivacy)
  1184 	{
  1255 	{
  1185 	iFsm->SessionType() = aSessionType;
  1256 	iFsm->SessionType() = aSessionType;
       
  1257 	iFsm->ExternalRequestType() = aExternalRequestInfo.RequestType();
  1186 	iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitPrivacyRequestReceived, KErrNone);
  1258 	iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitPrivacyRequestReceived, KErrNone);
  1187 	TPrivLocWaitPrivResponseParams privacyRequestParams(	aSessionId, 
  1259 	TPrivLocWaitPrivResponseParams privacyRequestParams(	aSessionId, 
  1188 													aSessionType,
  1260 													aSessionType,
  1189 													aExternalRequestInfo, 
  1261 													aExternalRequestInfo, 
  1190 													aNetPosRequestPrivacy,
  1262 													aNetPosRequestPrivacy,
  1290 						}
  1362 						}
  1291 					
  1363 					
  1292 					}
  1364 					}
  1293 				}		
  1365 				}		
  1294 				
  1366 				
  1295 			// For MtLrs the Protcol module should not
  1367 			// For MtLrs the Protocol module should not
  1296 			// 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 
  1297 	            
  1369 	            
  1298 			// Inform network of the privacy response for normal privacy requests.
  1370 			// Inform network of the privacy response for normal privacy requests.
  1299 			if (iFsm->SessionType() == TLbsNetworkEnumInt::EServiceMobileTerminated)
  1371 			if (iFsm->SessionType() == TLbsNetworkEnumInt::EServiceMobileTerminated)
  1300 				{
  1372 				{
  1363 		iFsm->PrivacyResponse() = aRequestResult;
  1435 		iFsm->PrivacyResponse() = aRequestResult;
  1364 		if(iFsm->PrivacyResponse() == TLbsNetworkEnumInt::EPrivacyResponseAccepted)
  1436 		if(iFsm->PrivacyResponse() == TLbsNetworkEnumInt::EPrivacyResponseAccepted)
  1365 			{
  1437 			{
  1366 			// 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.
  1367 			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 			    }
  1368 			
  1447 			
  1369 			if(iFsm->LocReqReceived())
  1448 			if(iFsm->LocReqReceived())
  1370 				{				
  1449 				{				
  1371 				TPrivLocWaitLocationUpdateParams updateRequestParams(iFsm->SessionId(),
  1450 				TPrivLocWaitLocationUpdateParams updateRequestParams(iFsm->SessionId(),
  1372 																iFsm->PosRequestMethod(),
  1451 																iFsm->PosRequestMethod(),
  2485 	iIsEmergency(EFalse),
  2564 	iIsEmergency(EFalse),
  2486 	iSessionType(TLbsNetworkEnumInt::EServiceNone),
  2565 	iSessionType(TLbsNetworkEnumInt::EServiceNone),
  2487 	iRefPosProcessed(EFalse),
  2566 	iRefPosProcessed(EFalse),
  2488 	iLocReqReceived(EFalse),
  2567 	iLocReqReceived(EFalse),
  2489 	iReqCancelled(EFalse),
  2568 	iReqCancelled(EFalse),
  2490 	iWasPrivacyResponseReceivedStateExited(EFalse)
  2569 	iWasPrivacyResponseReceivedStateExited(EFalse),
       
  2570 	iPositioningStatusIncremented(EFalse)
  2491 	{	
  2571 	{	
  2492 	}
  2572 	}
  2493 	
  2573 	
  2494 // ----------------------------------------------------------------------------- 
  2574 // ----------------------------------------------------------------------------- 
  2495 // CLbsPrivLocFsm::~CLbsPrivLocFsm
  2575 // CLbsPrivLocFsm::~CLbsPrivLocFsm
  2610 									const TLbsNetSessionIdInt& aSessionId,
  2690 									const TLbsNetSessionIdInt& aSessionId,
  2611 									TInt aReason)
  2691 									TInt aReason)
  2612 	{
  2692 	{
  2613 	LBSLOG3(ELogP3, "FSM(%d) OnSessionComplete reason=%d",iSessionId.SessionNum(),aReason);
  2693 	LBSLOG3(ELogP3, "FSM(%d) OnSessionComplete reason=%d",iSessionId.SessionNum(),aReason);
  2614 	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         }
  2615 	}
  2703 	}
  2616 
  2704 
  2617 // ----------------------------------------------------------------------------- 
  2705 // ----------------------------------------------------------------------------- 
  2618 // CLbsPrivLocFsm::OnNetLocRequest
  2706 // CLbsPrivLocFsm::OnNetLocRequest
  2619 // 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