|
1 // Copyright (c) 2005-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 // |
|
15 |
|
16 #include "TestContactSuiteServer.h" |
|
17 #include "TestAddFieldsStep.h" |
|
18 #include "TestUpdateFieldsStep.h" |
|
19 #include "TestDeleteFieldsStep.h" |
|
20 #include "TestAddMultipleContactsStep.h" |
|
21 #include "TestUpdateMultipleContactsStep.h" |
|
22 #include "TestDeleteMultipleContactsStep.h" |
|
23 #include "TestContactPerformanceStep.h" |
|
24 |
|
25 |
|
26 _LIT(KServerName,"TestContactSuite"); |
|
27 CTestContactSuite* CTestContactSuite::NewL() |
|
28 /** |
|
29 * @return - Instance of the test server |
|
30 * Same code for Secure and non-secure variants |
|
31 * Called inside the MainL() function to create and start the |
|
32 * CTestServer derived server. |
|
33 */ |
|
34 { |
|
35 CTestContactSuite * server = new (ELeave) CTestContactSuite(); |
|
36 CleanupStack::PushL(server); |
|
37 // CServer base class call which can be either StartL or ConstructL, |
|
38 // the later will permit Server Logging. |
|
39 |
|
40 server->StartL(KServerName); |
|
41 //server->ConstructL(KServerName); |
|
42 CleanupStack::Pop(server); |
|
43 return server; |
|
44 } |
|
45 |
|
46 // Secure variants much simpler |
|
47 // For EKA2, just an E32Main and a MainL() |
|
48 LOCAL_C void MainL() |
|
49 /** |
|
50 * Secure variant |
|
51 * Much simpler, uses the new Rendezvous() call to sync with the client |
|
52 */ |
|
53 { |
|
54 // Leave the hooks in for platform security |
|
55 #if (defined __DATA_CAGING__) |
|
56 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
57 RProcess().DataCaging(RProcess::ESecureApiOn); |
|
58 #endif |
|
59 CActiveScheduler* sched=NULL; |
|
60 sched=new(ELeave) CActiveScheduler; |
|
61 CActiveScheduler::Install(sched); |
|
62 CTestContactSuite* server = NULL; |
|
63 // Create the CTestServer derived server |
|
64 TRAPD(err,server = CTestContactSuite::NewL()); |
|
65 if(!err) |
|
66 { |
|
67 RProcess::Rendezvous(KErrNone); |
|
68 sched->Start(); |
|
69 } |
|
70 |
|
71 delete server; |
|
72 delete sched; |
|
73 } |
|
74 |
|
75 GLDEF_C TInt E32Main() |
|
76 /** |
|
77 * @return - Standard Epoc error code on process exit |
|
78 * Secure variant only |
|
79 * Process entry point. Called by client using RProcess API |
|
80 */ |
|
81 { |
|
82 __UHEAP_MARK; |
|
83 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
84 if(cleanup == NULL) |
|
85 { |
|
86 return KErrNoMemory; |
|
87 } |
|
88 TRAP_IGNORE(MainL()); |
|
89 delete cleanup; |
|
90 __UHEAP_MARKEND; |
|
91 return KErrNone; |
|
92 } |
|
93 |
|
94 CTestStep* CTestContactSuite::CreateTestStep(const TDesC& aStepName) |
|
95 /** |
|
96 * @return - A CTestStep derived instance |
|
97 * Secure and non-secure variants |
|
98 * Implementation of CTestServer pure virtual |
|
99 */ |
|
100 { |
|
101 CTestStep* testStep = NULL; |
|
102 // They are created "just in time" when the worker thread is created |
|
103 // More test steps can be added below |
|
104 |
|
105 if(aStepName == KTestAddFieldsStep) |
|
106 { |
|
107 testStep = new CTestAddFieldsStep(); |
|
108 } |
|
109 else if (aStepName == KTestUpdateFieldsStep) |
|
110 { |
|
111 testStep = new CTestUpdateFieldsStep(); |
|
112 } |
|
113 else if (aStepName == KTestDeleteFieldsStep) |
|
114 { |
|
115 testStep = new CTestDeleteFieldsStep(); |
|
116 } |
|
117 else if (aStepName == KTestAddMultipleContactsStep) |
|
118 { |
|
119 testStep = new CTestAddMultipleContactsStep(); |
|
120 } |
|
121 else if (aStepName == KTestUpdateMultipleContactsStep) |
|
122 { |
|
123 testStep = new CTestUpdateMultipleContactsStep(); |
|
124 } |
|
125 else if (aStepName == KTestDeleteMultipleContactsStep) |
|
126 { |
|
127 testStep = new CTestDeleteMultipleContactsStep(); |
|
128 } |
|
129 else if (aStepName == KTestContactPerformanceStep) |
|
130 { |
|
131 testStep = new CTestContactPerformanceStep(); |
|
132 } |
|
133 return testStep; |
|
134 } |