|
1 /* |
|
2 * Copyright (c) 2006 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 "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: Root server implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <ecom/ecom.h> |
|
19 |
|
20 #include "ximprootserver.h" |
|
21 #include "ximprootserversessionadapter.h" |
|
22 #include "ximprootserverdefs.h" |
|
23 #include "ximptrace.h" |
|
24 #include "ximpglobals.h" |
|
25 #include "ximpoperationfactoryimp.h" |
|
26 |
|
27 //Include Root server namespace |
|
28 using namespace NRootSrv; |
|
29 |
|
30 |
|
31 // ============================================================== |
|
32 // =============== PLATSEC POLICY CONFIGURATION ================= |
|
33 // ============================================================== |
|
34 static const TInt KXIMPRootServerPlatSecRangeCount = 2; |
|
35 |
|
36 //Ranges for the Request values |
|
37 static const TInt KXIMPRootServerPlatSecRanges[ KXIMPRootServerPlatSecRangeCount ] = |
|
38 { |
|
39 0, |
|
40 Max( ( TInt )NRootSrv::NRequest::EOpCodeTop, ( TInt )NRequest::EOpCodeTop ) |
|
41 }; |
|
42 |
|
43 |
|
44 // Element indexes for the defined ranges |
|
45 static const TUint8 KXIMPRootServerPlatSecElementsIndex[ KXIMPRootServerPlatSecRangeCount ] = |
|
46 { |
|
47 0, |
|
48 CPolicyServer::ENotSupported |
|
49 }; |
|
50 |
|
51 |
|
52 // Policy elements |
|
53 static const CPolicyServer::TPolicyElement KXIMPRootServerPlatSecElements[] = |
|
54 { |
|
55 { |
|
56 _INIT_SECURITY_POLICY_C3( ECapabilityReadUserData, |
|
57 ECapabilityWriteUserData, |
|
58 ECapabilityNetworkServices ), |
|
59 CPolicyServer::EFailClient |
|
60 } |
|
61 }; |
|
62 |
|
63 |
|
64 // The platsec policy |
|
65 static const CPolicyServer::TPolicy KXIMPRootServerPlatSecPolicy = |
|
66 { |
|
67 // Shortcut to the index into Elements,that is used to check a connection attempt |
|
68 0, |
|
69 |
|
70 // Number of ranges in the iRanges array |
|
71 KXIMPRootServerPlatSecRangeCount, |
|
72 |
|
73 // A pointer to an array of ordered ranges of request numbers |
|
74 KXIMPRootServerPlatSecRanges, |
|
75 |
|
76 // A pointer to an array of TUint8 values specifying |
|
77 // the appropriate action to take for each range in iRanges |
|
78 KXIMPRootServerPlatSecElementsIndex, |
|
79 |
|
80 // A pointer to an array of distinct policy elements |
|
81 KXIMPRootServerPlatSecElements |
|
82 }; |
|
83 |
|
84 |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CXIMPRootServer::ExecuteL() |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 void CXIMPRootServer::ExecuteL() |
|
91 { |
|
92 // start scheduler |
|
93 CActiveScheduler* pA = new( ELeave )CActiveScheduler; |
|
94 CleanupStack::PushL( pA ); |
|
95 CActiveScheduler::Install( pA ); |
|
96 |
|
97 // create server |
|
98 CXIMPRootServer* server = CXIMPRootServer::NewLC(); |
|
99 server->StartL( NName::KSymbianServer ); |
|
100 |
|
101 //Signal client that we are started |
|
102 RProcess().Rendezvous( KErrNone ); |
|
103 |
|
104 //Execute the server |
|
105 CActiveScheduler::Start(); // CSI: 3 # |
|
106 |
|
107 //Cleanup |
|
108 CleanupStack::PopAndDestroy( server );//server |
|
109 CleanupStack::PopAndDestroy( pA ); |
|
110 CActiveScheduler::Install( NULL ); |
|
111 } |
|
112 |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CXIMPRootServer::~CXIMPRootServer() |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 CXIMPRootServer::~CXIMPRootServer() |
|
119 { |
|
120 CXIMPGlobals::UninstallD(); |
|
121 REComSession::FinalClose(); |
|
122 |
|
123 #if _BullseyeCoverage |
|
124 cov_write(); |
|
125 #endif |
|
126 } |
|
127 |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CXIMPRootServer::CXIMPRootServer() |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 CXIMPRootServer::CXIMPRootServer() |
|
134 : CPolicyServer( CActive::EPriorityStandard, |
|
135 KXIMPRootServerPlatSecPolicy ) |
|
136 { |
|
137 } |
|
138 |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CXIMPRootServer::NewLC() |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 CXIMPRootServer* CXIMPRootServer::NewLC() |
|
145 { |
|
146 CXIMPRootServer* self = new( ELeave ) CXIMPRootServer; |
|
147 CleanupStack::PushL( self ); |
|
148 self->ConstructL(); |
|
149 return self; |
|
150 } |
|
151 |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CXIMPRootServer::ConstructL() |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 void CXIMPRootServer::ConstructL() |
|
158 { |
|
159 CXIMPOperationFactory* operationFactory = CXIMPOperationFactory::NewL(); |
|
160 CleanupStack::PushL( operationFactory ); |
|
161 CXIMPGlobals::InstallL( operationFactory, NULL ); |
|
162 CleanupStack::Pop( operationFactory ); |
|
163 iGlobals = CXIMPGlobals::Instance(); |
|
164 } |
|
165 |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CXIMPRootServer::NewSessionL() |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 CSession2* CXIMPRootServer::NewSessionL( const TVersion &aVersion, |
|
172 const RMessage2& /* aMessage */ ) const |
|
173 { |
|
174 TVersion srvVersion( NVersion::KMajor, |
|
175 NVersion::KMinor, |
|
176 NVersion::KBuild ); |
|
177 |
|
178 if( !User::QueryVersionSupported( aVersion, srvVersion ) ) |
|
179 { |
|
180 User::Leave( KErrNotSupported ); |
|
181 } |
|
182 |
|
183 CXIMPRootServer* self = const_cast< CXIMPRootServer* >( this ); |
|
184 CSession2* session = NULL; |
|
185 |
|
186 TRAPD( err, session = CXIMPRootServerSessionAdapter::NewL( *self ) ); |
|
187 User::LeaveIfError( err ); |
|
188 return session; |
|
189 } |
|
190 |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
|
193 // CXIMPRootServer::SessionCreated() |
|
194 // ----------------------------------------------------------------------------- |
|
195 // |
|
196 void CXIMPRootServer::SessionCreated() |
|
197 { |
|
198 iSessionCount++; |
|
199 } |
|
200 |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // CXIMPRootServer::SessionDied() |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 void CXIMPRootServer::SessionDied() |
|
207 { |
|
208 iSessionCount--; |
|
209 if( iSessionCount == 0 ) |
|
210 { |
|
211 CActiveScheduler::Stop(); // CSI: 4 # |
|
212 } |
|
213 } |
|
214 |
|
215 // ----------------------------------------------------------------------------- |
|
216 // E32Main() |
|
217 // ENTRY POINT |
|
218 // ----------------------------------------------------------------------------- |
|
219 // |
|
220 GLDEF_C TInt E32Main() |
|
221 { |
|
222 TRACE( _L("Root E32Main - enter") ); |
|
223 |
|
224 __UHEAP_MARK; |
|
225 |
|
226 User::RenameThread( NName::KMainThread ); |
|
227 |
|
228 CTrapCleanup* tc = CTrapCleanup::New(); |
|
229 if( !tc ) |
|
230 { |
|
231 return KErrNoMemory; |
|
232 } |
|
233 |
|
234 TRAPD( err, CXIMPRootServer::ExecuteL() ); |
|
235 delete tc; |
|
236 |
|
237 __UHEAP_MARKEND; |
|
238 |
|
239 TRACE_1( _L("Root E32Main - exit: %d"), err ); |
|
240 return err; |
|
241 } |
|
242 |
|
243 |
|
244 // END OF FILE |
|
245 |
|
246 |