authorisation/userpromptservice/test/tups_install/tupsserver.cpp
changeset 94 0e6c5a9328b5
parent 90 8c545fea2798
child 102 deec7e509f66
equal deleted inserted replaced
90:8c545fea2798 94:0e6c5a9328b5
     1 /*
       
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * tups_installserver.cpp
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  * @file
       
    22  *
       
    23  * SWIS test server implementation
       
    24  */
       
    25 
       
    26 #include "tupsserver.h"
       
    27 #include "tupsstep.h"
       
    28 
       
    29 _LIT(KServerName, "tups_install");
       
    30 
       
    31 /**
       
    32  * Called inside the MainL() function to create and start the CTestServer 
       
    33  * derived server.
       
    34  * @return Instance of the test server
       
    35  */
       
    36 CUpsTestServer* CUpsTestServer::NewL()
       
    37 	{
       
    38 	CUpsTestServer *server = new(ELeave) CUpsTestServer();
       
    39 	CleanupStack::PushL(server);
       
    40 	server->ConstructL(KServerName);
       
    41 	CleanupStack::Pop(server);
       
    42 	return server;
       
    43 	}
       
    44 
       
    45 
       
    46 LOCAL_C void MainL()
       
    47 	{
       
    48 	// Leave the hooks in for platform security
       
    49 #if (defined __DATA_CAGING__)
       
    50 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    51 	RProcess().SecureApi(RProcess::ESecureApiOn);
       
    52 #endif
       
    53 	
       
    54 	CActiveScheduler* sched=NULL;
       
    55 	sched=new(ELeave) CActiveScheduler;
       
    56 	CActiveScheduler::Install(sched);
       
    57 	CUpsTestServer* server = NULL;
       
    58 	// Create the CTestServer derived server
       
    59 	TRAPD(err, server = CUpsTestServer::NewL());
       
    60 	if(!err)
       
    61 		{
       
    62 		// Sync with the client and enter the active scheduler
       
    63 		RProcess::Rendezvous(KErrNone);
       
    64 		sched->Start();
       
    65 		}
       
    66 	delete server;
       
    67 	delete sched;
       
    68 	}
       
    69 
       
    70 /**
       
    71  * Server entry point
       
    72  * @return Standard Epoc error code on exit
       
    73  */
       
    74 GLDEF_C TInt E32Main()
       
    75 	{
       
    76 	__UHEAP_MARK;
       
    77 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    78 	if(cleanup == NULL)
       
    79 		{
       
    80 		return KErrNoMemory;
       
    81 		}
       
    82 	TRAP_IGNORE(MainL());
       
    83 	delete cleanup;
       
    84 	__UHEAP_MARKEND;
       
    85 	return KErrNone;
       
    86 	}
       
    87 
       
    88 /**
       
    89  * Implementation of CTestServer pure virtual
       
    90  * @return A CTestStep derived instance
       
    91  */
       
    92 CTestStep* CUpsTestServer::CreateTestStep(const TDesC& aStepName)
       
    93 	{
       
    94 	CTestStep* testStep = NULL;
       
    95 
       
    96 	// This server creates just one step but create as many as you want
       
    97 	// They are created "just in time" when the worker thread is created
       
    98 	// install steps
       
    99 	if (aStepName == KUpsInstallStep)	// Install with file name
       
   100 		testStep = new CUpsInstallStep(CUpsInstallStep::EUseFileName);
       
   101 // Uninstall
       
   102 	else if (aStepName == KUpsUnInstallStep)
       
   103 		testStep = new CUpsUninstallStep(CUpsUninstallStep::EByUid);
       
   104 	else if (aStepName == KUpsUnInstallAugStep)
       
   105 		testStep = new CUpsUninstallStep(CUpsUninstallStep::EByPackage);
       
   106 	
       
   107 	return testStep;
       
   108 
       
   109 	}