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