29
|
1 |
/*
|
|
2 |
* Copyright (c) 2006-2007 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: DUN server
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef C_CDUNSERVER_H
|
|
20 |
#define C_CDUNSERVER_H
|
|
21 |
|
|
22 |
#include <e32base.h>
|
|
23 |
#include "DunPlugin.h"
|
|
24 |
#include "DunCloseWait.h"
|
|
25 |
#include "dunserverdef.h"
|
|
26 |
#include "dundomainpskeys.h"
|
|
27 |
|
|
28 |
_LIT( KDunPluginBt, "dunbt.dll" );
|
|
29 |
_LIT( KDunPluginIrda, "dunir.dll" );
|
|
30 |
_LIT( KDunPluginUsb, "dunusb.dll" );
|
|
31 |
|
|
32 |
class MDunSession;
|
|
33 |
class MDunServerUtility;
|
|
34 |
|
|
35 |
/**
|
|
36 |
* Class used to store data needed for each separate plugin
|
|
37 |
* One TDunConnectionData data contains objects needed for one plugin
|
|
38 |
*
|
|
39 |
* @since S60 v3.2
|
|
40 |
*/
|
|
41 |
NONSHARABLE_CLASS( TDunConnectionData )
|
|
42 |
{
|
|
43 |
|
|
44 |
public:
|
|
45 |
|
|
46 |
/**
|
|
47 |
* Pointer to plugin DLL
|
|
48 |
* Not own.
|
|
49 |
*/
|
|
50 |
MDunLocalMediaPlugin* iLocalModulePtr;
|
|
51 |
|
|
52 |
/**
|
|
53 |
* Current state of plugin
|
|
54 |
*/
|
|
55 |
TDunPluginState iPluginState;
|
|
56 |
|
|
57 |
/**
|
|
58 |
* DLL library server needed to open/close existing plugin
|
|
59 |
*/
|
|
60 |
RLibrary iModuleLibrary;
|
|
61 |
|
|
62 |
/**
|
|
63 |
* Loaded plugin's UID
|
|
64 |
*/
|
|
65 |
TUid iLocalModuleUid;
|
|
66 |
|
|
67 |
};
|
|
68 |
|
|
69 |
/**
|
|
70 |
* Main DUN server's class
|
|
71 |
*
|
|
72 |
* @since S60 v3.2
|
|
73 |
*/
|
|
74 |
class CDunServer : public CPolicyServer,
|
|
75 |
public MDunServerCallback,
|
|
76 |
public MDunCloseWait
|
|
77 |
{
|
|
78 |
|
|
79 |
friend class CDunServerUtils;
|
|
80 |
|
|
81 |
public:
|
|
82 |
|
|
83 |
/**
|
|
84 |
* Two-phased constructor.
|
|
85 |
* @return Instance of self
|
|
86 |
*/
|
|
87 |
static CDunServer* NewL();
|
|
88 |
|
|
89 |
/**
|
|
90 |
* Destructor.
|
|
91 |
*/
|
|
92 |
virtual ~CDunServer();
|
|
93 |
|
|
94 |
/**
|
|
95 |
* Notification to manage local media On request
|
|
96 |
* This comes from client
|
|
97 |
*
|
|
98 |
* @since S60 3.2
|
|
99 |
* @param aPluginUid UID of the local media plugin to open
|
|
100 |
* @return None
|
|
101 |
*/
|
|
102 |
TInt NotifyMediaOpenRequest( TUid aPluginUid );
|
|
103 |
|
|
104 |
/**
|
|
105 |
* Notification to manage local media Off request
|
|
106 |
* This comes from client
|
|
107 |
*
|
|
108 |
* @since S60 3.2
|
|
109 |
* @param aPluginUid UID of the local media plugin to close
|
|
110 |
* @return None
|
|
111 |
*/
|
|
112 |
TInt NotifyMediaCloseRequest( TUid aPluginUid );
|
|
113 |
|
|
114 |
/**
|
|
115 |
* Current active connection
|
|
116 |
* (For testing purposes only)
|
|
117 |
*
|
|
118 |
* @since S60 5.0
|
|
119 |
* @return Active connection, NULL otherwise
|
|
120 |
*/
|
|
121 |
TConnId ActiveConnection();
|
|
122 |
|
|
123 |
/**
|
|
124 |
* Increases reference count made by sessions
|
|
125 |
* This comes from client
|
|
126 |
*
|
|
127 |
* @since S60 3.2
|
|
128 |
* @return None
|
|
129 |
*/
|
|
130 |
void IncRefCount();
|
|
131 |
|
|
132 |
/**
|
|
133 |
* Decreases reference count made by sessions
|
|
134 |
* This comes from client
|
|
135 |
*
|
|
136 |
* @since S60 3.2
|
|
137 |
* @return None
|
|
138 |
*/
|
|
139 |
void DecRefCount();
|
|
140 |
|
|
141 |
// from base class CServer2 (CPolicyServer -> CServer2)
|
|
142 |
|
|
143 |
/**
|
|
144 |
* From CServer2 (CPolicyServer derived from CServer2).
|
|
145 |
* Creates a server-side client session object.
|
|
146 |
*
|
|
147 |
* @since S60 3.2
|
|
148 |
* @param aVersion Version information supplied by the client
|
|
149 |
* @return A pointer to the newly created server-side client session
|
|
150 |
*/
|
|
151 |
CSession2* NewSessionL( const TVersion& aVersion, const RMessage2& ) const;
|
|
152 |
|
|
153 |
private:
|
|
154 |
|
|
155 |
CDunServer( TInt aPriority );
|
|
156 |
|
|
157 |
void ConstructL();
|
|
158 |
|
|
159 |
/**
|
|
160 |
* Opens local media plugin by UID
|
|
161 |
*
|
|
162 |
* @since S60 3.2
|
|
163 |
* @param aPluginUid UID of local media plugin to open
|
|
164 |
* @param aDequeue ETrue if restarting of queued plugins and plugin
|
|
165 |
* dequeue wanted after successful plugin close
|
|
166 |
* (normal case, see also TryClosePlugin()),
|
|
167 |
* EFalse if no restarting of queued plugins and plugin
|
|
168 |
* dequeue wanted after successful plugin close
|
|
169 |
* (in this case caller is reopener itself, see also
|
|
170 |
* ReopenQeueuedPlugins())
|
|
171 |
* @return Symbian error code on error, KErrNone otherwise
|
|
172 |
*/
|
|
173 |
TInt OpenMediaByUid( TUid aPluginUid, TBool aDequeue );
|
|
174 |
|
|
175 |
/**
|
|
176 |
* Closes local media plugin by UID
|
|
177 |
*
|
|
178 |
* @since S60 3.2
|
|
179 |
* @param aPluginUid UID of local media plugin to close
|
|
180 |
* @param aClearQueued ETrue if clear from plugin queue wanted,
|
|
181 |
* EFalse otherwise
|
|
182 |
* @param aClientClose ETrue if close originator is client
|
|
183 |
* @param aSelfDelete ETrue if plugin closes itself, EFalse otherwise
|
|
184 |
* @return Symbian error code on error, KErrNone otherwise
|
|
185 |
*/
|
|
186 |
TInt CloseMediaByUid( TUid aPluginUid,
|
|
187 |
TBool aClearQueued,
|
|
188 |
TBool aClientClose,
|
|
189 |
TBool aSelfDelete );
|
|
190 |
|
|
191 |
/**
|
|
192 |
* Reopens plugins from plugin queue
|
|
193 |
*
|
|
194 |
* @since S60 3.2
|
|
195 |
* @return Symbian error code on error, KErrNone otherwise
|
|
196 |
*/
|
|
197 |
TInt ReopenQueuedPlugins();
|
|
198 |
|
|
199 |
// from base class MDunServerCallback
|
|
200 |
|
|
201 |
/**
|
|
202 |
* From MDunServerCallback.
|
|
203 |
* Searches for plugin in connection data and returns its state
|
|
204 |
*
|
|
205 |
* @since S60 3.2
|
|
206 |
* @param aPluginUid UID of local media plugin to search for
|
|
207 |
* @return State of plugin
|
|
208 |
*/
|
|
209 |
TDunPluginState GetPluginStateByUid( TUid aPluginUid );
|
|
210 |
|
|
211 |
/**
|
|
212 |
* From MDunServerCallback.
|
|
213 |
* Notification about request to change plugin state up by one level
|
|
214 |
*
|
|
215 |
* @since S60 3.2
|
|
216 |
* @param aPluginState New state to set for a local media plugin
|
|
217 |
* @param aPluginUid UID of the local media plugin whose state to change
|
|
218 |
* @return KErrNotFound if plugin not found by UID,
|
|
219 |
KErrNotSupported if unknown state,
|
|
220 |
KErrNone otherwise
|
|
221 |
*/
|
|
222 |
TInt NotifyPluginStateChangeUp( TDunPluginState aPluginState,
|
|
223 |
TUid aPluginUid );
|
|
224 |
|
|
225 |
/**
|
|
226 |
* From MDunServerCallback.
|
|
227 |
* Notification about request to change plugin state down by one level
|
|
228 |
*
|
|
229 |
* @since S60 3.2
|
|
230 |
* @param aPluginState New state to set for a local media plugin
|
|
231 |
* @param aPluginUid UID of the local media plugin whose state to change
|
|
232 |
* @return KErrNotFound if plugin not found by UID,
|
|
233 |
KErrNotSupported if unknown state,
|
|
234 |
KErrNone otherwise
|
|
235 |
*/
|
|
236 |
TInt NotifyPluginStateChangeDown( TDunPluginState aPluginState,
|
|
237 |
TUid aPluginUid );
|
|
238 |
|
|
239 |
/**
|
|
240 |
* From MDunServerCallback.
|
|
241 |
* Notification about plugin restart request
|
|
242 |
*
|
|
243 |
* @since S60 3.2
|
|
244 |
* @param aPluginUid UID of the local media plugin to restart
|
|
245 |
* @return Symbian error code on error, KErrNone otherwise
|
|
246 |
*/
|
|
247 |
TInt NotifyPluginRestart( TUid aPluginUid );
|
|
248 |
|
|
249 |
/**
|
|
250 |
* From MDunServerCallback.
|
|
251 |
* Notification about plugin reopen request
|
|
252 |
*
|
|
253 |
* @since S60 3.2
|
|
254 |
* @return Symbian error code on error, KErrNone otherwise
|
|
255 |
*/
|
|
256 |
TInt NotifyPluginReopenRequest();
|
|
257 |
|
|
258 |
// from base class MDunPluginManager (MDunServerCallback->MDunPluginManager).
|
|
259 |
|
|
260 |
/**
|
|
261 |
* From MDunPluginManager (MDunServerCallback->MDunPluginManager).
|
|
262 |
* Notification about request to enqueue a plugin to plugin queue
|
|
263 |
*
|
|
264 |
* @since S60 3.2
|
|
265 |
* @param aPluginUid UID of the local media plugin to enqueue
|
|
266 |
* @return KErrNotFound = plugin not found by UID,
|
|
267 |
KErrAlreadyExists = plugin already in queue,
|
|
268 |
KErrNone otherwise
|
|
269 |
*/
|
|
270 |
TInt NotifyPluginEnqueueRequest( TUid aPluginUid );
|
|
271 |
|
|
272 |
/**
|
|
273 |
* From MDunPluginManager (MDunServerCallback->MDunPluginManager).
|
|
274 |
* Notification about request to dequeue a plugin from plugin queue
|
|
275 |
* Just removes a found UID from the queue
|
|
276 |
*
|
|
277 |
* @since S60 3.2
|
|
278 |
* @param aPluginUid UID of the local media plugin to dequeue
|
|
279 |
* @return Symbian error code on error, KErrNone otherwise
|
|
280 |
*/
|
|
281 |
TInt NotifyPluginDequeueRequest( TUid aPluginUid );
|
|
282 |
|
|
283 |
/**
|
|
284 |
* From MDunPluginManager (MDunServerCallback->MDunPluginManager).
|
|
285 |
* Notification about request to close a plugin
|
|
286 |
*
|
|
287 |
* @since S60 3.2
|
|
288 |
* @param aPluginUid UID of the local media plugin to close
|
|
289 |
* @param aSelfClose ETrue if plugin closes itself, EFalse otherwise
|
|
290 |
* @return Symbian error code on error, KErrNone otherwise
|
|
291 |
*/
|
|
292 |
TInt NotifyPluginCloseRequest( TUid aPluginUid,
|
|
293 |
TBool aSelfClose );
|
|
294 |
|
|
295 |
// from base class MDunCloseWait
|
|
296 |
|
|
297 |
/**
|
|
298 |
* From MDunCloseWait.
|
|
299 |
* Notification about request to close a plugin after wait
|
|
300 |
*
|
|
301 |
* @since S60 5.0
|
|
302 |
* @param aPluginsToClose Plugins to be closed
|
|
303 |
* @return Symbian error code on error, KErrNone otherwise
|
|
304 |
*/
|
|
305 |
void NotifyPluginCloseAfterWait(
|
|
306 |
RPointerArray<MDunLocalMediaPlugin>& aPluginsToClose );
|
|
307 |
|
|
308 |
private: // data
|
|
309 |
|
|
310 |
/**
|
|
311 |
* Pointer to common utility class
|
|
312 |
* Own.
|
|
313 |
*/
|
|
314 |
MDunServerUtility* iUtility;
|
|
315 |
|
|
316 |
/**
|
|
317 |
* Transporter to use for network side communication
|
|
318 |
* Own.
|
|
319 |
*/
|
|
320 |
CDunTransporter* iTransporter;
|
|
321 |
|
|
322 |
/**
|
|
323 |
* Waiter for closing self-destruct plugins
|
|
324 |
* Own.
|
|
325 |
*/
|
|
326 |
CDunCloseWait* iCloseWait;
|
|
327 |
|
|
328 |
/**
|
|
329 |
* Array of TDunConnectionData needed for each loaded plugin
|
|
330 |
*/
|
|
331 |
RArray<TDunConnectionData> iConnData;
|
|
332 |
|
|
333 |
/**
|
|
334 |
* Array of plugin UIDs
|
|
335 |
* Used for queuing plugins that have no resources to use
|
|
336 |
* Used for dequeuing plugins when free resources detected
|
|
337 |
*/
|
|
338 |
RArray<TUid> iPluginQueue;
|
|
339 |
|
|
340 |
/**
|
|
341 |
* Array of plugin UIDs
|
|
342 |
* Used for queuing plugins that were successfully closed outside
|
|
343 |
* this server. This is to avoid returning KErrNotFound to LOCOD
|
|
344 |
* when NotifyMediaCloseRequest() is caught
|
|
345 |
*/
|
|
346 |
RArray<TUid> iClosedQueue;
|
|
347 |
|
|
348 |
/**
|
|
349 |
* Connection status of dialup: active or inactive
|
|
350 |
* Used for updating KPSUidDialupConnStatus Pub&Sub key
|
|
351 |
*/
|
|
352 |
TDialupConnStatus iConnStatus;
|
|
353 |
|
|
354 |
/**
|
|
355 |
* Reference count of client sides
|
|
356 |
*/
|
|
357 |
TInt iRefCount;
|
|
358 |
|
|
359 |
};
|
|
360 |
|
|
361 |
#endif // C_CDUNSERVER_H
|