lbstest/lbstestproduct/common/src/ctlbsstepsetupstandaloneprivacymode.cpp
changeset 0 9cfd9a3ee49c
equal deleted inserted replaced
-1:000000000000 0:9cfd9a3ee49c
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // @file ctlbsstep_setupstandaloneprivacymode.cpp
       
    15 // This is the class implementation for the Set Autonomous Moder Test Step
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalTechnology
       
    22  @test
       
    23 */
       
    24 		  
       
    25 #include "ctlbsstepsetupstandaloneprivacymode.h"
       
    26 #include <lbs/lbsadmin.h>
       
    27 #include <centralrepository.h>
       
    28 
       
    29 
       
    30 CT_LbsStep_SetupStandalonePrivacyMode::CT_LbsStep_SetupStandalonePrivacyMode(CT_LbsServer& aParent) : CT_LbsStep(aParent)
       
    31 	{
       
    32 	SetTestStepName(KLbsStep_SetupStandalonePrivacyMode);
       
    33 	}
       
    34 
       
    35 /**
       
    36 Static Constructor
       
    37 */
       
    38 CT_LbsStep_SetupStandalonePrivacyMode* CT_LbsStep_SetupStandalonePrivacyMode::New(CT_LbsServer& aParent)
       
    39 	{
       
    40 	return new CT_LbsStep_SetupStandalonePrivacyMode(aParent);
       
    41 	// Note the lack of ELeave.
       
    42 	// This means that having insufficient memory will return NULL;
       
    43 	}
       
    44 
       
    45 
       
    46 /**
       
    47 @pre 	
       
    48 @return Test verdict
       
    49 @post	LBS sub-system set to standalone privacy mode.
       
    50 */
       
    51 TVerdict CT_LbsStep_SetupStandalonePrivacyMode::doTestStepL()
       
    52 	{
       
    53 	INFO_PRINTF1(_L("&gt;&gt;CT_LbsStep_SetupStandalonePrivacyMode::doTestStepL()"));
       
    54 	
       
    55 	// Set the privacy protocol module as the protocol module to load in admin settings
       
    56 	CLbsAdmin* adminApi = CLbsAdmin::NewL();
       
    57 	CleanupStack::PushL(adminApi);
       
    58 	
       
    59 	const TLbsProtocolModuleId KPrivacyPMUid = { 0x1028373C };
       
    60 	TInt err = adminApi->Set(KLbsSettingHomeProtocolModule, KPrivacyPMUid);	
       
    61 	User::LeaveIfError(err);
       
    62 	TUid uid;
       
    63 	err = adminApi->Get(KLbsSettingHomeProtocolModule, uid);	
       
    64 	User::LeaveIfError(err);
       
    65 	
       
    66 	if(uid.iUid != KPrivacyPMUid.iUid)
       
    67 		{
       
    68 		INFO_PRINTF1(_L("Admin setting didn't work"));
       
    69 		SetTestStepResult(EFail);
       
    70 		}					
       
    71 	
       
    72 	//Get privacy handler type
       
    73 	CLbsAdmin::TPrivacyHandler privacyHandlerType;
       
    74 	err = adminApi->Get(KLbsSettingPrivacyHandler, privacyHandlerType);	
       
    75 	User::LeaveIfError(err);
       
    76 	
       
    77 	// Turn off the LBS logger
       
    78 	err = adminApi->Set(KLbsSettingLogger, CLbsAdmin::ELoggerOff);
       
    79 	User::LeaveIfError(err);
       
    80 
       
    81 	// Set the privacy timeout action as 'network defined'
       
    82 	err = adminApi->Set(KLbsSettingPrivacyTimeoutAction, CLbsAdmin::EPrivacyTimeoutNetworkDefined);
       
    83 	User::LeaveIfError(err);
       
    84 
       
    85 	// Set the maximum number of simultaneous privacy requests allowed
       
    86 	const TUint KMaxExternalLocateRequests(150);
       
    87 	err = adminApi->Set(KLbsSettingMaximumExternalLocateRequests, KMaxExternalLocateRequests);
       
    88 	User::LeaveIfError(err);
       
    89 
       
    90 	CleanupStack::PopAndDestroy(adminApi);
       
    91 
       
    92 	// Alow the setting to be propagated
       
    93 	User::After(2000000);
       
    94 		
       
    95 	// Set-up the LbsRoot cenrep file so that:
       
    96 	// 1) LbsRoot is transient.
       
    97 	// 2) LbsRoot starts the LBS subsystem in transient mode
       
    98 	// 3) LbsRoot only starts the NRH and NG.
       
    99 
       
   100 	CRepository* rootRep = CRepository::NewLC(KLbsCenRepUid);
       
   101 	
       
   102 	// Set Lbs system and LbsRoot process as transient.
       
   103 	
       
   104 	// Start the LBS sub-system in transient mode.
       
   105 	User::LeaveIfError(rootRep->Set(KLbsSystemTransientKey, 1));
       
   106 	User::LeaveIfError(rootRep->Set(KLbsRootProcessTransientKey, 1));
       
   107 	
       
   108 	// Set only NRH and NG to be started.
       
   109 	// First, clear out any existing startup entries.
       
   110 	TUint32 errorKey;
       
   111 	User::LeaveIfError(rootRep->Delete(KLbsRootProcessNameFirstKey, KRootKeyMask, errorKey));
       
   112 	User::LeaveIfError(rootRep->Delete(KLbsRootProcessUidFirstKey, KRootKeyMask, errorKey));
       
   113 	User::LeaveIfError(rootRep->Delete(KLbsRootProcessIsServerFirstKey, KRootKeyMask, errorKey));
       
   114 	
       
   115 	// Set NRH and NG as startup entries.
       
   116 	_LIT(KNGProcessName, "lbsnetgateway.exe");
       
   117 	const TUid KLbsNetworkGatewayUid = { 0x10281D46 };
       
   118 	User::LeaveIfError(rootRep->Set(KLbsRootProcessNameFirstKey, KNGProcessName));
       
   119 	User::LeaveIfError(rootRep->Set(KLbsRootProcessUidFirstKey, TInt(KLbsNetworkGatewayUid.iUid)));
       
   120 	User::LeaveIfError(rootRep->Set(KLbsRootProcessIsServerFirstKey, EFalse));
       
   121 
       
   122 	_LIT(KNRHProcessName, "lbsnetworkrequesthandler.exe");
       
   123 	const TUid KLbsNetRequestHandlerUid = { 0x10281D45 };
       
   124 	User::LeaveIfError(rootRep->Set(KLbsRootProcessNameFirstKey+1, KNRHProcessName));
       
   125 	User::LeaveIfError(rootRep->Set(KLbsRootProcessUidFirstKey+1, TInt(KLbsNetRequestHandlerUid.iUid)));
       
   126 	User::LeaveIfError(rootRep->Set(KLbsRootProcessIsServerFirstKey+1, ETrue));
       
   127 	
       
   128 	//If we are using Privacy Controller mode, start privacy controller as well
       
   129 	if(privacyHandlerType == CLbsAdmin::EPrivacyHandleByController)
       
   130 		{
       
   131 		_LIT(KPrivCtrlProcessName, "lbstestprivacycontroller.exe");
       
   132 		const TUid KLbsPrivacyControllerUid = { 0x10283750 };
       
   133 		User::LeaveIfError(rootRep->Set(KLbsRootProcessNameFirstKey+2, KPrivCtrlProcessName));
       
   134 		User::LeaveIfError(rootRep->Set(KLbsRootProcessUidFirstKey+2, TInt(KLbsPrivacyControllerUid.iUid)));
       
   135 		User::LeaveIfError(rootRep->Set(KLbsRootProcessIsServerFirstKey+2, EFalse));
       
   136 		}
       
   137 	
       
   138 	CleanupStack::PopAndDestroy(rootRep);
       
   139 
       
   140 	INFO_PRINTF1(_L("&lt;&lt;CT_LbsStep_SetupStandalonePrivacyMode::doTestStepL()"));
       
   141 
       
   142 	return TestStepResult();
       
   143 	}
       
   144