|
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 #include <c32comm.h> |
|
22 |
|
23 #if defined (__WINS__) |
|
24 #define PDD_NAME _L("ECDRV") |
|
25 #else |
|
26 #define PDD_NAME _L("EUART1") |
|
27 #define PDD2_NAME _L("EUART2") |
|
28 #define PDD3_NAME _L("EUART3") |
|
29 #define PDD4_NAME _L("EUART4") |
|
30 #endif |
|
31 |
|
32 #define LDD_NAME _L("ECOMM") |
|
33 |
|
34 /** |
|
35 * @file |
|
36 * |
|
37 * SWIS test server implementation |
|
38 */ |
|
39 |
|
40 #include "tupsserver.h" |
|
41 #include "tupsstep.h" |
|
42 |
|
43 _LIT(KServerName, "tups_install"); |
|
44 |
|
45 /** |
|
46 * Called inside the MainL() function to create and start the CTestServer |
|
47 * derived server. |
|
48 * @return Instance of the test server |
|
49 */ |
|
50 CUpsTestServer* CUpsTestServer::NewL() |
|
51 { |
|
52 CUpsTestServer *server = new(ELeave) CUpsTestServer(); |
|
53 CleanupStack::PushL(server); |
|
54 server->ConstructL(KServerName); |
|
55 CleanupStack::Pop(server); |
|
56 return server; |
|
57 } |
|
58 |
|
59 static void InitCommsL() |
|
60 { |
|
61 TInt ret = User::LoadPhysicalDevice(PDD_NAME); |
|
62 User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); |
|
63 |
|
64 #ifndef __WINS__ |
|
65 ret = User::LoadPhysicalDevice(PDD2_NAME); |
|
66 ret = User::LoadPhysicalDevice(PDD3_NAME); |
|
67 ret = User::LoadPhysicalDevice(PDD4_NAME); |
|
68 #endif |
|
69 |
|
70 ret = User::LoadLogicalDevice(LDD_NAME); |
|
71 User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); |
|
72 ret = StartC32(); |
|
73 User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); |
|
74 } |
|
75 |
|
76 LOCAL_C void MainL() |
|
77 { |
|
78 // Leave the hooks in for platform security |
|
79 #if (defined __DATA_CAGING__) |
|
80 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
81 RProcess().SecureApi(RProcess::ESecureApiOn); |
|
82 #endif |
|
83 InitCommsL(); |
|
84 |
|
85 CActiveScheduler* sched=NULL; |
|
86 sched=new(ELeave) CActiveScheduler; |
|
87 CActiveScheduler::Install(sched); |
|
88 CUpsTestServer* server = NULL; |
|
89 // Create the CTestServer derived server |
|
90 TRAPD(err, server = CUpsTestServer::NewL()); |
|
91 if(!err) |
|
92 { |
|
93 // Sync with the client and enter the active scheduler |
|
94 RProcess::Rendezvous(KErrNone); |
|
95 sched->Start(); |
|
96 } |
|
97 delete server; |
|
98 delete sched; |
|
99 } |
|
100 |
|
101 /** |
|
102 * Server entry point |
|
103 * @return Standard Epoc error code on exit |
|
104 */ |
|
105 GLDEF_C TInt E32Main() |
|
106 { |
|
107 __UHEAP_MARK; |
|
108 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
109 if(cleanup == NULL) |
|
110 { |
|
111 return KErrNoMemory; |
|
112 } |
|
113 TRAP_IGNORE(MainL()); |
|
114 delete cleanup; |
|
115 __UHEAP_MARKEND; |
|
116 return KErrNone; |
|
117 } |
|
118 |
|
119 /** |
|
120 * Implementation of CTestServer pure virtual |
|
121 * @return A CTestStep derived instance |
|
122 */ |
|
123 CTestStep* CUpsTestServer::CreateTestStep(const TDesC& aStepName) |
|
124 { |
|
125 CTestStep* testStep = NULL; |
|
126 |
|
127 // This server creates just one step but create as many as you want |
|
128 // They are created "just in time" when the worker thread is created |
|
129 // install steps |
|
130 if (aStepName == KUpsInstallStep) // Install with file name |
|
131 testStep = new CUpsInstallStep(CUpsInstallStep::EUseFileName); |
|
132 // Uninstall |
|
133 else if (aStepName == KUpsUnInstallStep) |
|
134 testStep = new CUpsUninstallStep(CUpsUninstallStep::EByUid); |
|
135 else if (aStepName == KUpsUnInstallAugStep) |
|
136 testStep = new CUpsUninstallStep(CUpsUninstallStep::EByPackage); |
|
137 |
|
138 return testStep; |
|
139 |
|
140 } |