servicediscoveryandcontrol/pnp/test/upnp/IntegTest/testupnp/src/testupnp.cpp
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 // Copyright (c) 2008-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 // Contains implementation of CTestUPnPManager class
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "testupnp.h"
       
    19 #include "testupnpmanager.h"
       
    20 #include "testrcontrolchannel.h"
       
    21 
       
    22 /*
       
    23 	Static factory constructor. Uses two phase construction and leaves nothing on the 
       
    24 	CleanupStack. Creates a CTestUPnP object.
       
    25 	@param  None
       
    26 	@return Instance of the test server
       
    27  */
       
    28 CTestUPnP* CTestUPnP::NewL()
       
    29 	{
       
    30 	CTestUPnP *	server = new (ELeave) CTestUPnP();
       
    31 	CleanupStack::PushL(server);
       
    32 	// CServer base class call
       
    33 	RProcess	handle = RProcess();
       
    34 	TParsePtrC	serverName(handle.FileName());
       
    35 	server->ConstructL(serverName.Name());
       
    36 	CleanupStack::Pop(server);
       
    37 	return server;
       
    38 	}
       
    39 
       
    40 /*
       
    41    Function to create and start the CTestServer derived server.
       
    42    Secure variant.Much simpler, uses the new Rendezvous() call to sync with the client
       
    43    @param  None
       
    44    @return None
       
    45 */
       
    46 LOCAL_C void MainL()
       
    47 	{
       
    48 	// Leave the hooks in for platform security
       
    49 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    50 	RProcess().DataCaging(RProcess::ESecureApiOn);
       
    51 	CActiveScheduler* sched = new(ELeave) CActiveScheduler;
       
    52 	CActiveScheduler::Install(sched);
       
    53 	CTestUPnP*	server = NULL;
       
    54 	// Create the CTestServer derived server
       
    55 	TRAPD(err,server = CTestUPnP::NewL());
       
    56 	if(err == KErrNone)
       
    57 		{
       
    58 		// Sync with the client and enter the active scheduler
       
    59 		RProcess::Rendezvous(KErrNone);
       
    60 		sched->Start();
       
    61 		}
       
    62 	delete server;
       
    63 	delete sched;
       
    64 	}
       
    65 
       
    66 /**
       
    67    Secure variant only
       
    68    Process entry point. Called by client using RProcess API.	
       
    69    @param  None
       
    70    @return Standard Epoc error code on process exit
       
    71  */
       
    72 GLDEF_C TInt E32Main()
       
    73 	{
       
    74 	__UHEAP_MARK;
       
    75 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    76 	if(cleanup == NULL)
       
    77 		{
       
    78 		return KErrNoMemory;
       
    79 		}
       
    80 	TRAPD( error, MainL() );
       
    81 	delete cleanup;
       
    82 	__UHEAP_MARKEND;
       
    83 	return error;
       
    84     }
       
    85 
       
    86 
       
    87 CTestStep* CTestUPnP::CreateTestStep(const TDesC& aStepName)
       
    88 	{
       
    89 	CTestStep* testStep = NULL;
       
    90 	TRAPD(err,testStep=CreateTestStepL(aStepName));
       
    91 	if(err == KErrNone)
       
    92 		{
       
    93 		return testStep;
       
    94 		}
       
    95 	else
       
    96 		{
       
    97 		return NULL;
       
    98 		}
       
    99 	}
       
   100 
       
   101 /**
       
   102    Secure and non-secure variants
       
   103    Implementation of CTestServer pure virtual
       
   104    @param  aStepName a reference to string
       
   105    @return A CTestStep derived instance
       
   106  */
       
   107 CTestStep* CTestUPnP::CreateTestStepL(const TDesC& aStepName)
       
   108 	{
       
   109 	CTestStep* testStep = NULL;
       
   110 	// They are created "just in time" when the worker thread is created
       
   111 	// More test steps can be added below
       
   112 	if(aStepName == KTestUPnPManager)
       
   113 		{
       
   114 		testStep = new CTestUPnPManager();
       
   115         }
       
   116     if(aStepName == KTestRControlChannel)
       
   117 		{
       
   118 		testStep = new CTestRControlChannel();
       
   119         }
       
   120 	return testStep;
       
   121 	}
       
   122 
       
   123 
       
   124