|
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: Utility class for CDunServer |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CDUNSERVERUTILS_H |
|
20 #define C_CDUNSERVERUTILS_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include "DunPlugin.h" |
|
24 |
|
25 class CDunServer; |
|
26 |
|
27 /** |
|
28 * Utility accessor class for CDunServer class |
|
29 * Basically a collection of miscellaneous helper methods |
|
30 * |
|
31 * @since S60 v3.2 |
|
32 */ |
|
33 NONSHARABLE_CLASS( MDunServerUtility ) |
|
34 { |
|
35 |
|
36 public: |
|
37 |
|
38 /** |
|
39 * From MDunServerUtility. |
|
40 * Closes plugins with state marked as zombie |
|
41 * |
|
42 * @since S60 3.2 |
|
43 * @return KErrGeneral = close on any of the plugins failed, |
|
44 KErrNone otherwise |
|
45 */ |
|
46 virtual TInt RemoveZombiePlugins() = 0; |
|
47 |
|
48 /** |
|
49 * From MDunServerUtility. |
|
50 * Loads local media module |
|
51 * |
|
52 * @since S60 3.2 |
|
53 * @param aPluginUid UID of the local media module to load |
|
54 * @return Symbian error code on error, KErrNone otherwise |
|
55 */ |
|
56 virtual TInt CreateNewPlugin( TUid aPluginUid ) = 0; |
|
57 |
|
58 /** |
|
59 * From MDunServerUtility. |
|
60 * Constructs local media module |
|
61 * |
|
62 * @since S60 3.2 |
|
63 * @param aPluginUid UID of the local media module to construct |
|
64 * @param aDllName Name of the DLL to the constructed local media module |
|
65 * @return Symbian error code on error, KErrNone otherwise |
|
66 */ |
|
67 virtual TInt ConstructLocalMediaModule( const TUid& aPluginUid, |
|
68 const TPtrC& aDllName ) = 0; |
|
69 |
|
70 /** |
|
71 * From MDunServerUtility. |
|
72 * Clears queued UIDs |
|
73 * |
|
74 * @since S60 3.2 |
|
75 * @param aPluginUid UID of local media plugin to remove |
|
76 * @param aClearClosed ETrue if clear from closed queued wanted |
|
77 * @param aClearQueued ETrue if clear from plugin queue wanted |
|
78 * @return ETrue if plugin UID was removed, EFalse otherwise |
|
79 */ |
|
80 virtual TBool ClearQueuedUIDs( TUid aPluginUid, |
|
81 TBool aClearClosed, |
|
82 TBool aClearQueued ) = 0; |
|
83 |
|
84 /** |
|
85 * From MDunServerUtility. |
|
86 * Tries to close loaded local media plugin |
|
87 * |
|
88 * @since S60 3.2 |
|
89 * @param aIndex Index of plugin in connectiondata |
|
90 * @param aDequeue ETrue if restarting of queued plugins and plugin |
|
91 * dequeue wanted after successful plugin close |
|
92 * (normal case, see also OpenMediaByUid()), |
|
93 * EFalse if no restarting of queued plugins and plugin |
|
94 * dequeue wanted after successful plugin close |
|
95 * (in this case caller is reopener itself, see also |
|
96 * ReopenQeueuedPlugins()) |
|
97 * @param aClientClose ETrue if close originator is client |
|
98 * @param aSelfClose ETrue if plugin closes itself, EFalse otherwise |
|
99 * @return Symbian error code on error, KErrNone otherwise |
|
100 */ |
|
101 virtual TInt TryClosePlugin( TInt aIndex, |
|
102 TBool aDequeue, |
|
103 TBool aClientClose, |
|
104 TBool aSelfClose ) = 0; |
|
105 |
|
106 /** |
|
107 * From MDunServerUtility. |
|
108 * Closes a plugin directly without uninitializing it |
|
109 * |
|
110 * @since S60 5.0 |
|
111 * @param aIndex Index of plugin in connectiondata |
|
112 * @param aDequeue ETrue if restarting of queued plugins and plugin |
|
113 * dequeue wanted after successful plugin close |
|
114 * (normal case, see also OpenMediaByUid()), |
|
115 * EFalse if no restarting of queued plugins and plugin |
|
116 * dequeue wanted after successful plugin close |
|
117 * (in this case caller is reopener itself, see also |
|
118 * ReopenQeueuedPlugins()) |
|
119 * @param aClientClose ETrue if close originator is client |
|
120 * @return Symbian error code on error, KErrNone otherwise |
|
121 */ |
|
122 virtual TInt DoClosePlugin( TInt aIndex, |
|
123 TBool aDequeue, |
|
124 TBool aClientClose ) = 0; |
|
125 |
|
126 /** |
|
127 * From MDunServerUtility. |
|
128 * Does immediate close of plugin |
|
129 * |
|
130 * @since S60 3.2 |
|
131 * @param aIndex Index of plugin in connectiondata |
|
132 * @param aDequeue ETrue if restarting of queued plugins and plugin |
|
133 * dequeue wanted after successful plugin close |
|
134 * (normal case, see also OpenMediaByUid()), |
|
135 * EFalse if no restarting of queued plugins and plugin |
|
136 * dequeue wanted after successful plugin close |
|
137 * (in this case caller is reopener itself, see also |
|
138 * ReopenQeueuedPlugins()) |
|
139 * @return Symbian error code on error, KErrNone otherwise |
|
140 */ |
|
141 virtual TInt DoImmediatePluginClose( TInt aIndex, |
|
142 TBool aDequeue ) = 0; |
|
143 |
|
144 /** |
|
145 * From MDunServerUtility. |
|
146 * Tries uninitialization and after that listening state switch on a plugin |
|
147 * |
|
148 * @since S60 3.2 |
|
149 * @param aPluginUid UID of the plugin to initialize to listening state |
|
150 * @return Symbian error code on error, KErrNone otherwise |
|
151 */ |
|
152 virtual TInt TryInitializeToListening( TUid aPluginUid ) = 0; |
|
153 |
|
154 /** |
|
155 * From MDunServerUtility. |
|
156 * Tries listening state switch on a plugin |
|
157 * |
|
158 * @since S60 3.2 |
|
159 * @param aIndex Index of plugin in connectiondata |
|
160 * @return KErrNotFound = plugin not found, |
|
161 KErrNotReady = wrong state, |
|
162 KErrNone otherwise |
|
163 */ |
|
164 virtual TInt TryListening( TInt aIndex ) = 0; |
|
165 |
|
166 /** |
|
167 * From MDunServerUtility. |
|
168 * Tries uninitialization of a plugin |
|
169 * |
|
170 * @since S60 3.2 |
|
171 * @param aIndex Index of plugin in connectiondata |
|
172 * @return KErrNotFound = plugin not found, KErrNone otherwise |
|
173 */ |
|
174 virtual TInt TryUninitialize( TInt aIndex ) = 0; |
|
175 |
|
176 }; |
|
177 |
|
178 /** |
|
179 * DUN server's utility class |
|
180 * |
|
181 * @since S60 v3.2 |
|
182 */ |
|
183 class CDunServerUtils : public CBase, |
|
184 public MDunServerUtility |
|
185 { |
|
186 |
|
187 public: |
|
188 |
|
189 /** |
|
190 * Two-phased constructor. |
|
191 * @param aParent Parent class owning this friend class (CDunServer) |
|
192 * @return Instance of self |
|
193 */ |
|
194 static CDunServerUtils* NewL( CDunServer& aParent ); |
|
195 |
|
196 /** |
|
197 * Destructor. |
|
198 */ |
|
199 virtual ~CDunServerUtils(); |
|
200 |
|
201 private: |
|
202 |
|
203 CDunServerUtils( CDunServer& aParent ); |
|
204 |
|
205 void ConstructL(); |
|
206 |
|
207 // from base class MDunServerUtility |
|
208 |
|
209 /** |
|
210 * From MDunServerUtility. |
|
211 * Closes plugins with state marked as zombie |
|
212 * |
|
213 * @since S60 3.2 |
|
214 * @return KErrGeneral = close on any of the plugins failed, |
|
215 KErrNone otherwise |
|
216 */ |
|
217 TInt RemoveZombiePlugins(); |
|
218 |
|
219 /** |
|
220 * From MDunServerUtility. |
|
221 * Loads local media module |
|
222 * |
|
223 * @since S60 3.2 |
|
224 * @param aPluginUid UID of the local media module to load |
|
225 * @return Symbian error code on error, KErrNone otherwise |
|
226 */ |
|
227 TInt CreateNewPlugin( TUid aPluginUid ); |
|
228 |
|
229 /** |
|
230 * From MDunServerUtility. |
|
231 * Constructs local media module |
|
232 * |
|
233 * @since S60 3.2 |
|
234 * @param aPluginUid UID of the local media module to construct |
|
235 * @param aDllName Name of the DLL to the constructed local media module |
|
236 * @return Symbian error code on error, KErrNone otherwise |
|
237 */ |
|
238 TInt ConstructLocalMediaModule( const TUid& aPluginUid, |
|
239 const TPtrC& aDllName ); |
|
240 |
|
241 /** |
|
242 * From MDunServerUtility. |
|
243 * Clears queued UIDs |
|
244 * |
|
245 * @since S60 3.2 |
|
246 * @param aPluginUid UID of local media plugin to remove |
|
247 * @param aClearClosed ETrue if clear from closed queued wanted |
|
248 * @param aClearQueued ETrue if clear from plugin queue wanted |
|
249 * @return ETrue if plugin UID was removed, EFalse otherwise |
|
250 */ |
|
251 TBool ClearQueuedUIDs( TUid aPluginUid, |
|
252 TBool aClearClosed, |
|
253 TBool aClearQueued ); |
|
254 |
|
255 /** |
|
256 * From MDunServerUtility. |
|
257 * Tries to close loaded local media plugin |
|
258 * |
|
259 * @since S60 3.2 |
|
260 * @param aIndex Index of plugin in connectiondata |
|
261 * @param aDequeue ETrue if restarting of queued plugins and plugin |
|
262 * dequeue wanted after successful plugin close |
|
263 * (normal case, see also OpenMediaByUid()), |
|
264 * EFalse if no restarting of queued plugins and plugin |
|
265 * dequeue wanted after successful plugin close |
|
266 * (in this case caller is reopener itself, see also |
|
267 * ReopenQeueuedPlugins()) |
|
268 * @param aClientClose ETrue if close originator is client |
|
269 * @param aSelfClose ETrue if plugin closes itself, EFalse otherwise |
|
270 * @return Symbian error code on error, KErrNone otherwise |
|
271 */ |
|
272 TInt TryClosePlugin( TInt aIndex, |
|
273 TBool aDequeue, |
|
274 TBool aClientClose, |
|
275 TBool aSelfClose ); |
|
276 |
|
277 /** |
|
278 * From MDunServerUtility. |
|
279 * Closes a plugin directly without uninitializing it |
|
280 * |
|
281 * @since S60 5.0 |
|
282 * @param aIndex Index of plugin in connectiondata |
|
283 * @param aDequeue ETrue if restarting of queued plugins and plugin |
|
284 * dequeue wanted after successful plugin close |
|
285 * (normal case, see also OpenMediaByUid()), |
|
286 * EFalse if no restarting of queued plugins and plugin |
|
287 * dequeue wanted after successful plugin close |
|
288 * (in this case caller is reopener itself, see also |
|
289 * ReopenQeueuedPlugins()) |
|
290 * @param aClientClose ETrue if close originator is client |
|
291 * @return Symbian error code on error, KErrNone otherwise |
|
292 */ |
|
293 TInt DoClosePlugin( TInt aIndex, |
|
294 TBool aDequeue, |
|
295 TBool aClientClose ); |
|
296 |
|
297 /** |
|
298 * From MDunServerUtility. |
|
299 * Does immediate close of plugin |
|
300 * |
|
301 * @since S60 3.2 |
|
302 * @param aIndex Index of plugin in connectiondata |
|
303 * @param aDequeue ETrue if restarting of queued plugins and plugin |
|
304 * dequeue wanted after successful plugin close |
|
305 * (normal case, see also OpenMediaByUid()), |
|
306 * EFalse if no restarting of queued plugins and plugin |
|
307 * dequeue wanted after successful plugin close |
|
308 * (in this case caller is reopener itself, see also |
|
309 * ReopenQeueuedPlugins()) |
|
310 * @return Symbian error code on error, KErrNone otherwise |
|
311 */ |
|
312 TInt DoImmediatePluginClose( TInt aIndex, |
|
313 TBool aDequeue ); |
|
314 |
|
315 /** |
|
316 * From MDunServerUtility. |
|
317 * Tries uninitialization and after that listening state switch on a plugin |
|
318 * |
|
319 * @since S60 3.2 |
|
320 * @param aPluginUid UID of the plugin to initialize to listening state |
|
321 * @return Symbian error code on error, KErrNone otherwise |
|
322 */ |
|
323 TInt TryInitializeToListening( TUid aPluginUid ); |
|
324 |
|
325 /** |
|
326 * From MDunServerUtility. |
|
327 * Tries listening state switch on a plugin |
|
328 * |
|
329 * @since S60 3.2 |
|
330 * @param aIndex Index of plugin in connectiondata |
|
331 * @return KErrNotFound = plugin not found, |
|
332 KErrNotReady = wrong state, |
|
333 KErrNone otherwise |
|
334 */ |
|
335 TInt TryListening( TInt aIndex ); |
|
336 |
|
337 /** |
|
338 * From MDunServerUtility. |
|
339 * Tries uninitialization of a plugin |
|
340 * |
|
341 * @since S60 3.2 |
|
342 * @param aIndex Index of plugin in connectiondata |
|
343 * @return KErrNotFound = plugin not found, KErrNone otherwise |
|
344 */ |
|
345 TInt TryUninitialize( TInt aIndex ); |
|
346 |
|
347 private: // data |
|
348 |
|
349 /** |
|
350 * Parent class owning this friend class (CDunServer) |
|
351 */ |
|
352 CDunServer& iParent; |
|
353 |
|
354 /** |
|
355 * Transporter to use for network side communication |
|
356 * (from parent iParent) |
|
357 */ |
|
358 CDunTransporter*& iTransporter; |
|
359 |
|
360 /** |
|
361 * Waiter for closing self-destruct plugins |
|
362 * (from parent iParent) |
|
363 */ |
|
364 CDunCloseWait*& iCloseWait; |
|
365 |
|
366 /** |
|
367 * Array of TDunConnectionData needed for each loaded plugin |
|
368 * (from parent iParent) |
|
369 */ |
|
370 RArray<TDunConnectionData>& iConnData; |
|
371 |
|
372 /** |
|
373 * Array of plugin UIDs (from parent iParent) |
|
374 * Used for queuing plugins that have no resources to use |
|
375 * Used for dequeuing plugins when free resources detected |
|
376 */ |
|
377 RArray<TUid>& iPluginQueue; |
|
378 |
|
379 /** |
|
380 * Array of plugin UIDs (from parent iParent) |
|
381 * Used for queuing plugins that were successfully closed outside |
|
382 * this server. This is to avoid returning KErrNotFound to LOCOD |
|
383 * when NotifyMediaCloseRequest() is caught |
|
384 */ |
|
385 RArray<TUid>& iClosedQueue; |
|
386 |
|
387 }; |
|
388 |
|
389 #endif // C_CDUNSERVERUTILS_H |