1 /* |
|
2 * Copyright (c) 2007-2008 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: Class header for CWsfServer |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_WSFSERVER_H |
|
21 #define C_WSFSERVER_H |
|
22 |
|
23 // EXTERNAL INCLUDES |
|
24 #include <e32base.h> |
|
25 |
|
26 // INTERNAL INCLUDES |
|
27 #include "wsfservercloseradapter.h" |
|
28 |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CWsfEngine; |
|
32 class CWsfSession; |
|
33 |
|
34 |
|
35 // CLASS DEFINITION |
|
36 /** |
|
37 * CWsfServer is the server class that realises the necessary server functions |
|
38 * |
|
39 * @since S60 5.0 |
|
40 * @lib wsfserver.exe |
|
41 */ |
|
42 NONSHARABLE_CLASS( CWsfServer ): public CPolicyServer |
|
43 { |
|
44 private: |
|
45 |
|
46 /** |
|
47 * CWsfServerCloser is an auxiliary class that is responsible for |
|
48 * closing the server when there is no need for it any more |
|
49 * |
|
50 * @since S60 5.0 |
|
51 * @lib wsfserver.exe |
|
52 */ |
|
53 NONSHARABLE_CLASS( CWsfServerCloser ): public CTimer, |
|
54 public MWsfServerCloserAdapter |
|
55 { |
|
56 public: |
|
57 /** |
|
58 * Factory function. |
|
59 * @since S60 5.0 |
|
60 * @return Server closer instance |
|
61 */ |
|
62 static CWsfServerCloser* NewL(); |
|
63 |
|
64 /** |
|
65 * Destructor. |
|
66 */ |
|
67 ~CWsfServerCloser(); |
|
68 |
|
69 public: // from MWsfServerCloserAdapter |
|
70 |
|
71 /** |
|
72 * Sets whether the server closer should wait for the |
|
73 * termination of the owned connection |
|
74 * @since S60 5.0 |
|
75 * @param aWait If ETrue, the server closer will wait. |
|
76 */ |
|
77 void WaitForOwnedConnection( TBool aWait ); |
|
78 |
|
79 /** |
|
80 * Sets whether the server closer should wait for the |
|
81 * termination of the browser |
|
82 * @since S60 5.0 |
|
83 * @param aWait If ETrue, the server closer will wait. |
|
84 */ |
|
85 void WaitForBrowserExit( TBool aWait ); |
|
86 |
|
87 /** |
|
88 * Sets whether the server closer should wait for the |
|
89 * clients of the owned connection to detach |
|
90 * @since S60 5.0 |
|
91 * @param aWait If ETrue, the server closer will wait. |
|
92 */ |
|
93 void WaitForClients( TBool aWait ); |
|
94 |
|
95 private: |
|
96 |
|
97 /** |
|
98 * Constructor. |
|
99 * @since S60 5.0 |
|
100 */ |
|
101 CWsfServerCloser(); |
|
102 |
|
103 /** |
|
104 * Second-phase constructor. |
|
105 * @since S60 5.0 |
|
106 */ |
|
107 void ConstructL(); |
|
108 |
|
109 |
|
110 private: // from CActive |
|
111 |
|
112 /** |
|
113 * Handles an active object's request completion event. |
|
114 * @since S60 5.0 |
|
115 */ |
|
116 void RunL(); |
|
117 |
|
118 |
|
119 private: // new methods |
|
120 /** |
|
121 * Start the closing timer |
|
122 */ |
|
123 void StartClosureWait(); |
|
124 |
|
125 private: |
|
126 /** |
|
127 * Indicates whether the server should wait for the owned |
|
128 * connection to terminate. |
|
129 */ |
|
130 TBool iWaitForOwnedConnection; |
|
131 |
|
132 /** |
|
133 * Indicates whether the server should wait for the browser |
|
134 * to exit. |
|
135 */ |
|
136 TBool iWaitForBrowserExit; |
|
137 |
|
138 /** |
|
139 * Indicates whether the server should wait for the clients |
|
140 * of the owned connection to detach. |
|
141 */ |
|
142 TBool iWaitForClients; |
|
143 }; |
|
144 |
|
145 public: // Constructors and destructor |
|
146 /** |
|
147 * Factory function. |
|
148 * @since S60 5.0 |
|
149 * @return Server instance |
|
150 */ |
|
151 static CWsfServer* NewLC(); |
|
152 |
|
153 /** |
|
154 * Destructor. |
|
155 * @since S60 5.0 |
|
156 */ |
|
157 ~CWsfServer(); |
|
158 |
|
159 private: // Constructors |
|
160 /** |
|
161 * Constructor |
|
162 * @since S60 5.0 |
|
163 * @param aPriority Active object priority value |
|
164 */ |
|
165 CWsfServer( TInt aPriority ); |
|
166 |
|
167 /** |
|
168 * Second-phase constructor. |
|
169 * @since S60 5.0 |
|
170 */ |
|
171 void ConstructL(); |
|
172 |
|
173 |
|
174 private: // from CActive |
|
175 /** |
|
176 * Handles a leave occurring in RunL(). |
|
177 * @since S60 5.0 |
|
178 * @param aError Leave code |
|
179 * @return aError |
|
180 */ |
|
181 TInt RunError( TInt aError ); |
|
182 |
|
183 |
|
184 private: // from CPolicyServer |
|
185 |
|
186 /** |
|
187 * Performs a custom security check for IPCs marked with |
|
188 * TSpecialCase::ECustomCheck. |
|
189 * @since S60 5.0 |
|
190 * @param aMsg The message to check. |
|
191 * @param aAction A reference to the action to take if the security |
|
192 * check fails. |
|
193 * @param aMissing A reference to the list of security attributes |
|
194 * missing from the checked process |
|
195 * @return The result of the security check |
|
196 * (TCustomResult::EPass/TCustomResult::EFail). |
|
197 */ |
|
198 TCustomResult CustomSecurityCheckL( const RMessage2& aMsg, |
|
199 TInt& aAction, |
|
200 TSecurityInfo& aMissing ); |
|
201 |
|
202 public: // from CServer2 |
|
203 |
|
204 /** |
|
205 * Creates a server-side session object. |
|
206 * @since S60 5.0 |
|
207 * @param aVersion The version information supplied by the client. |
|
208 * @param aMessage Represents the details of the client request that is |
|
209 * requesting the creation of the session. |
|
210 * @return A pointer to the newly created server-side session object. |
|
211 */ |
|
212 CSession2 *NewSessionL( const TVersion& aVersion, |
|
213 const RMessage2& /*aMessage*/) const; |
|
214 |
|
215 public: |
|
216 /** |
|
217 * The entry point for server startup. |
|
218 * Creates the cleanupstack and continues to RunServerL |
|
219 * @since S60 5.0 |
|
220 * @return KErrNone if success, otherwise error code |
|
221 */ |
|
222 static TInt RunServer(); |
|
223 |
|
224 /** |
|
225 * Reduce client count and start server shutdown sequence if no client |
|
226 * sessions are available |
|
227 * @since S60 5.0 |
|
228 */ |
|
229 void ClientRelease(); |
|
230 |
|
231 /** |
|
232 * Increment the client count counter by one |
|
233 * @since S60 5.0 |
|
234 */ |
|
235 void ClientAttach(); |
|
236 |
|
237 /** |
|
238 * Returns pointer to the engine |
|
239 * @since S60 5.0 |
|
240 * @return Pointer to the engine object |
|
241 */ |
|
242 CWsfEngine* Engine(); |
|
243 |
|
244 private: |
|
245 /** |
|
246 * Creates active schduler and thread for server and start waiting for |
|
247 * client requests |
|
248 * @since S60 5.0 |
|
249 */ |
|
250 static void RunServerL(); |
|
251 |
|
252 |
|
253 private: // Data |
|
254 /** |
|
255 * Sniffer engine instance (owned) |
|
256 */ |
|
257 CWsfEngine *iEngine; |
|
258 |
|
259 /** |
|
260 * Server closer object (owned) |
|
261 */ |
|
262 CWsfServerCloser* iCloser; |
|
263 |
|
264 /** |
|
265 * Number of currently attached clients |
|
266 */ |
|
267 TInt iClientCount; |
|
268 |
|
269 }; |
|
270 |
|
271 |
|
272 #endif // C_WSFSERVER_H |
|
273 |
|