|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * This is the definition for CDosServer class. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef __DOSSERVER_H__ |
|
21 #define __DOSSERVER_H__ |
|
22 |
|
23 #include <e32base.h> |
|
24 #include "dosclientserver.h" |
|
25 #include "shareddatafilesystemnotifier.h" |
|
26 #include "SaeThread.h" |
|
27 |
|
28 // ---------------------------------------------------------------------------------------- |
|
29 // DosServer's policy |
|
30 // ---------------------------------------------------------------------------------------- |
|
31 |
|
32 //Total number of ranges |
|
33 const TUint KDosServerRangeCount = 4; |
|
34 |
|
35 //Definition of the ranges of IPC numbers |
|
36 const TInt KDosServerRanges[KDosServerRangeCount] = |
|
37 { |
|
38 0, // 0th range, Subsession opening and closing |
|
39 EGetSimLanguage, // 1st range, all other than request free disk space operations |
|
40 ERequestFreeDiskSpace, // 2nd range, request free disk space operations |
|
41 ERequestFreeDiskSpaceCancel+1 // non implemented function end of range check ; ENotSupported |
|
42 }; |
|
43 |
|
44 //Policy to implement for each of the above ranges |
|
45 const TUint8 KDosServerElementsIndex[KDosServerRangeCount] = |
|
46 { |
|
47 0, //applies to 0th range |
|
48 1, //applies to 1st range |
|
49 2, //applies to 2nd range |
|
50 CPolicyServer::ENotSupported //applies to 1st range (out of range IPC) |
|
51 }; |
|
52 |
|
53 //Specific capability checks |
|
54 const CPolicyServer::TPolicyElement KDosServerElements[] = |
|
55 { |
|
56 {_INIT_SECURITY_POLICY_C2( ECapabilityReadUserData, |
|
57 ECapabilityWriteUserData ), CPolicyServer::EFailClient}, //policy "0" |
|
58 {_INIT_SECURITY_POLICY_C4( ECapabilityReadUserData, |
|
59 ECapabilityWriteUserData, |
|
60 ECapabilityReadDeviceData, |
|
61 ECapabilityWriteDeviceData ), CPolicyServer::EFailClient}, //policy "1" |
|
62 {_INIT_SECURITY_POLICY_C2( ECapabilityReadUserData, |
|
63 ECapabilityWriteUserData ), CPolicyServer::EFailClient} //policy "2" |
|
64 }; |
|
65 |
|
66 //Package all the above together into a policy |
|
67 const CPolicyServer::TPolicy KDosServerPolicy = |
|
68 { |
|
69 CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass |
|
70 KDosServerRangeCount, //number of ranges |
|
71 KDosServerRanges, //ranges array |
|
72 KDosServerElementsIndex, //elements<->ranges index |
|
73 KDosServerElements, //array of elements |
|
74 }; |
|
75 |
|
76 class CDosFactoryBase; |
|
77 class CDosEventNotifier; |
|
78 class CDosEventManager; |
|
79 |
|
80 /** |
|
81 * Panics the client thread. |
|
82 * @param aMessage Client-server message. |
|
83 * @param aPanic Panic code. |
|
84 */ |
|
85 void PanicClient(const RMessage2& aMessage,TDosPanic aPanic); |
|
86 |
|
87 _LIT(KDosLibName,"DosSrv.dll"); |
|
88 _LIT(KDosServerExe,"DosServer.exe"); |
|
89 // Startup semaphore name |
|
90 _LIT( KServerStartupSemaphoreName, "DosServerStartupSem" ); |
|
91 |
|
92 #ifdef __WINS__ |
|
93 const TInt KDosServerStackSize=0x2000; // 8KB |
|
94 const TInt KDosServerInitHeapSize=0x1000; // 4KB |
|
95 const TInt KDosServerMaxHeapSize=0x1000000; // 16MB |
|
96 #endif |
|
97 |
|
98 /** |
|
99 * Server class. |
|
100 */ |
|
101 class CDosServer : public CPolicyServer |
|
102 { |
|
103 public: |
|
104 /** |
|
105 * signal class for waiting while thread/process is being set up. |
|
106 */ |
|
107 class TSignal |
|
108 { |
|
109 public: |
|
110 inline TSignal(); |
|
111 inline TSignal( TRequestStatus& aStatus ); |
|
112 |
|
113 inline TInt Set( const TDesC& aData ); |
|
114 inline TPtrC Get() const; |
|
115 |
|
116 public: |
|
117 TRequestStatus* iStatus; |
|
118 TThreadId iId; |
|
119 }; |
|
120 |
|
121 public: |
|
122 |
|
123 /** |
|
124 * Constructor. |
|
125 */ |
|
126 CDosServer(); |
|
127 |
|
128 /** |
|
129 * Destructor. |
|
130 */ |
|
131 virtual ~CDosServer(); |
|
132 |
|
133 /** |
|
134 * NewL function that creates the object. |
|
135 * @return A pointer to the newly created object. |
|
136 */ |
|
137 static CDosServer* NewL(); |
|
138 |
|
139 /** |
|
140 * Function that starts the thread. |
|
141 * @param aSignal The signal for synchronization. |
|
142 */ |
|
143 IMPORT_C static TInt ThreadStart( CDosServer::TSignal& aSignal ); |
|
144 |
|
145 /** |
|
146 * It adds a session to the server. |
|
147 */ |
|
148 void AddSession(); |
|
149 |
|
150 /** |
|
151 * It removes a session from the server. |
|
152 */ |
|
153 void DropSession(); |
|
154 |
|
155 /** |
|
156 * It's called by CActive on error situations. |
|
157 * @param aError Symbian error code. |
|
158 * @return Returns KErrNone if the error was handled or aError otherwise. |
|
159 */ |
|
160 TInt RunError(TInt aError); |
|
161 |
|
162 /** |
|
163 * Gets the Container Index. |
|
164 * @return The container index. |
|
165 */ |
|
166 inline CObjectConIx* ContainerIx() const; |
|
167 |
|
168 /** |
|
169 * Gets the event manager. |
|
170 * @return A pointer to the evetn manager. |
|
171 */ |
|
172 inline CDosEventManager* EventManager() const; |
|
173 |
|
174 /** |
|
175 * Gets the Factory. |
|
176 * @return A pointer to the factory. |
|
177 */ |
|
178 inline CDosFactoryBase* DosFactory() const; |
|
179 TInt* CurrentFreeDiskSpaceRequest(); |
|
180 void SetCurrentFreeDiskSpaceRequest(TInt* diskSpace); |
|
181 |
|
182 public: |
|
183 // free disk space notifier |
|
184 CSharedDataFileSystemNotifier* iFileSystemNotifier; |
|
185 private: |
|
186 /** |
|
187 * Symbian two-phased constructor. |
|
188 */ |
|
189 void ConstructL(); |
|
190 |
|
191 /** |
|
192 * It creates and sets up a new server side session. |
|
193 * @param aVersion Unused. |
|
194 * @return A pointer to the created session. |
|
195 */ |
|
196 CSession2* NewSessionL(const TVersion& aVersion) const; |
|
197 |
|
198 /** |
|
199 * It creates and sets up a new server side session. |
|
200 * @param aVersion Unused. |
|
201 * @param aMessage ... |
|
202 * @return A pointer to the created session. |
|
203 */ |
|
204 CSession2* NewSessionL(const TVersion& aVersion, const class RMessage2& aMessage) const; |
|
205 |
|
206 /** |
|
207 * It reads from z:\system\data\DosServer.ini the Dsy Module and |
|
208 * loads it. |
|
209 */ |
|
210 void LoadDsyModuleL(); |
|
211 |
|
212 /** |
|
213 * It signals client thread via semaphore that we have started. |
|
214 */ |
|
215 static void SignalClient(); |
|
216 |
|
217 private: |
|
218 //Container Index. |
|
219 CObjectConIx* iContainerIx; |
|
220 |
|
221 //Number of active sessions in the server. |
|
222 TInt iSessionCount; |
|
223 |
|
224 //Pointer to the DosServer's event manager. |
|
225 CDosEventManager* iEventManager; |
|
226 |
|
227 //Pointer to the Service Factory. |
|
228 CDosFactoryBase* iDosFactory; |
|
229 |
|
230 //Contains the Dsy module. |
|
231 RLibrary iLib; |
|
232 |
|
233 //Indicates if DSY is Loaded, RLibrary::Close() can not be called if |
|
234 //RLibrary::Load() has not been called. |
|
235 TBool iLibLoaded; |
|
236 // highest outstanding free disk space request |
|
237 TInt* iCurrentFreeDiskSpaceRequest; |
|
238 |
|
239 CSaeThread* iSaeThread; |
|
240 |
|
241 friend class CSharedDataFileSystemNotifier; |
|
242 }; |
|
243 |
|
244 #include "dosserver.inl" |
|
245 |
|
246 #endif //__DOSSERVER_H__ |