|
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 /** |
|
19 @file |
|
20 @internalTechnology |
|
21 */ |
|
22 |
|
23 #include "testupnp.h" |
|
24 #include "testdelay.h" |
|
25 |
|
26 /** |
|
27 Static factory constructor. Uses two phase construction and leaves nothing on the |
|
28 CleanupStack. Creates a CTestUPnP object. |
|
29 @param None |
|
30 @return Instance of the test server |
|
31 */ |
|
32 CTestUPnP* CTestUPnP::NewL() |
|
33 { |
|
34 CTestUPnP * server = new (ELeave) CTestUPnP(); |
|
35 CleanupStack::PushL(server); |
|
36 // CServer base class call |
|
37 RProcess handle = RProcess(); |
|
38 TParsePtrC serverName(handle.FileName()); |
|
39 server->ConstructL(serverName.Name()); |
|
40 CleanupStack::Pop(server); |
|
41 return server; |
|
42 } |
|
43 |
|
44 /** |
|
45 Function to create and start the CTestServer derived server. |
|
46 Secure variant.Much simpler, uses the new Rendezvous() call to sync with the client |
|
47 @param None |
|
48 @return None |
|
49 */ |
|
50 LOCAL_C void MainL() |
|
51 { |
|
52 // Leave the hooks in for platform security |
|
53 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
54 RProcess().DataCaging(RProcess::ESecureApiOn); |
|
55 CActiveScheduler* sched = new(ELeave) CActiveScheduler; |
|
56 CActiveScheduler::Install(sched); |
|
57 CTestUPnP* server = NULL; |
|
58 // Create the CTestServer derived server |
|
59 TRAPD(err,server = CTestUPnP::NewL()); |
|
60 if(err == KErrNone) |
|
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 Secure variant only |
|
72 Process entry point. Called by client using RProcess API. |
|
73 @param None |
|
74 @return Standard Epoc error code on process exit |
|
75 */ |
|
76 GLDEF_C TInt E32Main() |
|
77 { |
|
78 __UHEAP_MARK; |
|
79 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
80 if(cleanup == NULL) |
|
81 { |
|
82 return KErrNoMemory; |
|
83 } |
|
84 TRAPD( error, MainL() ); |
|
85 delete cleanup; |
|
86 __UHEAP_MARKEND; |
|
87 return error; |
|
88 } |
|
89 |
|
90 /** |
|
91 Secure and non-secure variants |
|
92 Implementation of CTestServer pure virtual |
|
93 @param aStepName a reference to string |
|
94 @return A CTestStep derived instance |
|
95 */ |
|
96 CTestStep* CTestUPnP::CreateTestStep(const TDesC& aStepName) |
|
97 { |
|
98 CTestStep* testStep = NULL; |
|
99 // They are created "just in time" when the worker thread is created |
|
100 // More test steps can be added below |
|
101 if(aStepName == KTestUPnPManager) |
|
102 { |
|
103 testStep = new CTestUPnPManager(); |
|
104 } |
|
105 |
|
106 return testStep; |
|
107 } |
|
108 |
|
109 |
|
110 |