1 /* |
|
2 * Copyright (c) 2007-2009 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: CCCHServiceHandler declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CCHSERVICEHANDLER_H |
|
20 #define C_CCHSERVICEHANDLER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32std.h> |
|
24 #include <e32base.h> |
|
25 #include <mspnotifychangeobserver.h> |
|
26 |
|
27 #include "cchserviceinfo.h" |
|
28 #include "cchsubserviceinfo.h" |
|
29 #include "cchservicenotifier.h" |
|
30 #include "cchclientserver.h" |
|
31 #include "cchcommdbwatcherobserver.h" |
|
32 |
|
33 // CONSTANTS |
|
34 // None |
|
35 |
|
36 // MACROS |
|
37 // None |
|
38 |
|
39 // FUNCTION PROTOTYPES |
|
40 // None |
|
41 |
|
42 // FORWARD DECLARATIONS |
|
43 class CCCHServiceInfo; |
|
44 class CCCHServerBase; |
|
45 class CCCHSubserviceInfo; |
|
46 class CSPNotifyChange; |
|
47 class CCchUIHandler; |
|
48 class CCchWlanExtension; |
|
49 class CCCHCommDbWatcher; |
|
50 |
|
51 // DATA TYPES |
|
52 typedef RPointerArray<CCCHServiceInfo> RServiceArray; |
|
53 |
|
54 // CLASS DECLARATION |
|
55 |
|
56 /** |
|
57 * CCCHServiceHandler declaration |
|
58 * Handles services and service related components |
|
59 * @lib cchserver.exe |
|
60 * @since S60 3.2 |
|
61 */ |
|
62 NONSHARABLE_CLASS( CCCHServiceHandler ) : public CBase, |
|
63 private MCCHServiceNotifier, |
|
64 private MSPNotifyChangeObserver, |
|
65 private MCCHCommDbWatcherObserver |
|
66 { |
|
67 |
|
68 public: // Constructors and destructor |
|
69 |
|
70 /** |
|
71 * Two-phased constructor. |
|
72 */ |
|
73 static CCCHServiceHandler* NewL( CCCHServerBase& aServer ); |
|
74 |
|
75 /** |
|
76 * Two-phased constructor. |
|
77 */ |
|
78 static CCCHServiceHandler* NewLC( CCCHServerBase& aServer ); |
|
79 |
|
80 /** |
|
81 * Destructor. |
|
82 */ |
|
83 virtual ~CCCHServiceHandler(); |
|
84 |
|
85 public: // New functions |
|
86 |
|
87 /** |
|
88 * Initialize object |
|
89 * @since S60 3.2 |
|
90 */ |
|
91 void InitServiceHandlerL(); |
|
92 |
|
93 /** |
|
94 * Update service and subservice's state |
|
95 * @since S60 3.2 |
|
96 * @param aReadSettingTable If ETrue class reads and updates |
|
97 * all services from Service Provider Settings |
|
98 */ |
|
99 void UpdateL( TBool aReadSettingTable = EFalse ); |
|
100 |
|
101 /** |
|
102 * Enables service |
|
103 * @since S60 3.2 |
|
104 * @param aServiceSelection Service to enable |
|
105 * @param aConnectivityCheck Is value is True Connectivity Plug-in will |
|
106 * make test call to check is the connection truly working. |
|
107 * @return General symbian error code. |
|
108 */ |
|
109 TInt EnableService( const TServiceSelection aServiceSelection, |
|
110 const TBool aConnectivityCheck ); |
|
111 |
|
112 /** |
|
113 * Disables service |
|
114 * @since S60 3.2 |
|
115 * @param aServiceSelection Service to disable |
|
116 * @return General symbian error code. |
|
117 */ |
|
118 TInt DisableService( const TServiceSelection aServiceSelection ); |
|
119 |
|
120 /** |
|
121 * Set new connection information to Service |
|
122 * @since S60 3.2 |
|
123 * @param aServiceConnInfo Connection information |
|
124 * @return General symbian error code. |
|
125 */ |
|
126 TInt SetConnectionInfo( const TServiceConnectionInfo aServiceConnInfo ); |
|
127 |
|
128 /** |
|
129 * Get connection information from Service |
|
130 * @since S60 3.2 |
|
131 * @param aServiceSelection Selected Service |
|
132 * @param aServiceConnInfo On completion contains Service's |
|
133 * connection infomation |
|
134 * @return General symbian error code. |
|
135 */ |
|
136 TInt GetConnectionInfo( TServiceConnectionInfo& aServiceConnInfo ); |
|
137 |
|
138 /** |
|
139 * Is any service's startup-flag set to true |
|
140 * @since S60 3.2 |
|
141 * @return ETrue if startup-flag is set to true |
|
142 */ |
|
143 TBool IsStartupFlagSet() const; |
|
144 |
|
145 /** |
|
146 * Subservice's enable at startup info setter. |
|
147 * Method does not change value for permanently. |
|
148 * CCCHSPSHandler::SetLoadAtStartUpL sets value for permanently. |
|
149 * @since S60 3.2 |
|
150 * @param aServiceSelection Service which owns startup flag |
|
151 * @param aLoadAtStartUp New startup flag |
|
152 * @return KErrNotFound if service or subservice does not exist |
|
153 */ |
|
154 TInt SetStartupFlag( const TServiceSelection aServiceSelection, |
|
155 TBool aLoadAtStartUp ) const; |
|
156 |
|
157 /** |
|
158 * Load Plug-ins |
|
159 * @since S60 3.2 |
|
160 */ |
|
161 void LoadPluginsL(); |
|
162 |
|
163 /** |
|
164 * Unloads Plug-in(s) of certain service; if all |
|
165 * subservices in one plugin are disabled, those are unloaded. |
|
166 * @since S60 3.2 |
|
167 */ |
|
168 void UnloadDisabledPluginsL( ); |
|
169 |
|
170 /** |
|
171 * Checks if certain subservice exists in certain state |
|
172 * @param aType Subservice type |
|
173 * @param aState Subservice state to be checked |
|
174 * @since S60 3.2 |
|
175 */ |
|
176 TBool Exists( TCCHSubserviceType aType, |
|
177 TCCHSubserviceState aState, |
|
178 TInt aError ) const; |
|
179 |
|
180 /** |
|
181 * Count of Services |
|
182 * @since S60 3.2 |
|
183 * @param aMessage IPC message; |
|
184 */ |
|
185 void ServiceCountL( RMessage2 aMessage ) const; |
|
186 |
|
187 /** |
|
188 * Get all services and subservices. |
|
189 * @since S60 3.2 |
|
190 * @param aMessage IPC message |
|
191 */ |
|
192 void GetServicesL( RMessage2 aMessage ); |
|
193 |
|
194 /** |
|
195 * Get state of service or subservice of a certain service |
|
196 * @since S60 3.2 |
|
197 * @param aMessage IPC message |
|
198 * @return General symbian error code. |
|
199 */ |
|
200 TInt GetServiceState( const RMessage2 aMessage ); |
|
201 |
|
202 /** |
|
203 * Get state of service |
|
204 * @since S60 3.2 |
|
205 * @param aServiceId Service which to be checked |
|
206 * @return A state of the service. |
|
207 */ |
|
208 TCCHSubserviceState CCCHServiceHandler::ServiceState( |
|
209 const TUint aServiceId ); |
|
210 |
|
211 /** |
|
212 * Get info of service or subservice of a certain service |
|
213 * @since S60 3.2 |
|
214 * @param aMessage IPC message |
|
215 * @return General symbian error code. |
|
216 */ |
|
217 TInt GetServiceInfo( const RMessage2 aMessage ); |
|
218 |
|
219 /** |
|
220 * Reserves the service for exclusive use |
|
221 * @since S60 3.2 |
|
222 * @param aMessage IPC message |
|
223 * @return General symbian error code. |
|
224 */ |
|
225 TInt ReserveService( const RMessage2 aMessage ); |
|
226 |
|
227 /** |
|
228 * Frees the exclusive service reservation |
|
229 * @since S60 3.2 |
|
230 * @param aMessage IPC message |
|
231 * @return General symbian error code. |
|
232 */ |
|
233 TInt FreeService( const RMessage2& aMessage ); |
|
234 |
|
235 /** |
|
236 * Is the service exclusively reserved? |
|
237 * @since S60 3.2 |
|
238 * @param aMessage IPC message |
|
239 * @return ETrue if service is reserved for exclusive use. |
|
240 */ |
|
241 void IsReserved( RMessage2 aMessage ) const; |
|
242 |
|
243 /** |
|
244 * Service exist |
|
245 * @since S60 3.2 |
|
246 * @param aSelection Checked Service |
|
247 * @return TInt index if found else KErrNotFound |
|
248 */ |
|
249 TInt ServiceExist( TServiceSelection aSelection ) const; |
|
250 |
|
251 /** |
|
252 * Find service by service id |
|
253 * @since S60 3.2 |
|
254 * @param serviceId |
|
255 * @return TInt position within the iServices array or KErrNotFound |
|
256 */ |
|
257 TInt FindService( TUint32 aServiceId ) const; |
|
258 |
|
259 /** |
|
260 * Subscribe to service change notifies |
|
261 * @since S60 3.2 |
|
262 */ |
|
263 void EnableNotifyChange(); |
|
264 |
|
265 /** |
|
266 * Cancel service change notifies |
|
267 * @since S60 3.2 |
|
268 */ |
|
269 void DisableNotifyChange(); |
|
270 |
|
271 /** |
|
272 * Get all subservice types which uses given Plug-in uid. |
|
273 * @since S60 3.2 |
|
274 * @param aServiceId Service which to be checked |
|
275 * @param aSubserviceTypes On completion contains subservice types. |
|
276 */ |
|
277 void GetSubserviceTypesL( const TUint aServiceId, |
|
278 RArray<TCCHSubserviceType>& aSubserviceTypes ) const; |
|
279 |
|
280 /** |
|
281 * Disables Wlan scan if needed |
|
282 */ |
|
283 void DisableWlanScan(); |
|
284 |
|
285 /** |
|
286 * Handle restart situation, all services and subservices |
|
287 * goes to disabled state. |
|
288 */ |
|
289 void HandleRestartL(); |
|
290 |
|
291 protected: // From base classes |
|
292 |
|
293 /** |
|
294 * Determines if we should start recovery |
|
295 * @since S60 3.2 |
|
296 * @param aServiceId Service which state has changed |
|
297 * @param aError Subservice's error. |
|
298 * @return ETrue if recovery is needed |
|
299 */ |
|
300 |
|
301 TBool IsRecoveryNeeded( const TCCHSubserviceState aState, |
|
302 TInt aError ); |
|
303 |
|
304 /** |
|
305 * Service state notifier. |
|
306 * @since S60 3.2 |
|
307 * @param aServiceId Service which state has changed |
|
308 * @param aSubService Subservice's type. |
|
309 * @param aState A new state of the service. |
|
310 */ |
|
311 void StateChangedL( const TUint aServiceId, |
|
312 const TCCHSubserviceType aSubService, |
|
313 const TCCHSubserviceState aState, |
|
314 const TInt aError ); |
|
315 |
|
316 /** |
|
317 * Handle notify change event. |
|
318 * From MSPNotifyChangeObserver; |
|
319 * |
|
320 * @since S60 3.2 |
|
321 * @param aServiceId The service ID of changed service |
|
322 */ |
|
323 void HandleNotifyChange( TServiceId aServiceId ); |
|
324 |
|
325 /** |
|
326 * Handle error |
|
327 * |
|
328 * @since S60 3.2 |
|
329 */ |
|
330 void HandleError( TInt aError ); |
|
331 |
|
332 private: |
|
333 |
|
334 /** |
|
335 * C++ default constructor. |
|
336 */ |
|
337 CCCHServiceHandler( CCCHServerBase& aServer ); |
|
338 |
|
339 /** |
|
340 * By default Symbian 2nd phase constructor is private. |
|
341 */ |
|
342 void ConstructL(); |
|
343 |
|
344 /** |
|
345 * Add service to service array |
|
346 * @since S60 3.2 |
|
347 * @param aService service information |
|
348 */ |
|
349 void AddServiceL( TCCHService& aService ); |
|
350 |
|
351 /** |
|
352 * Counts how many Service contains this kind of Subservice |
|
353 * @since S60 3.2 |
|
354 * @param aType Subservice's type |
|
355 * @return TInt Count of Service |
|
356 */ |
|
357 TInt ServiceCount( const TCCHSubserviceType aType ) const; |
|
358 |
|
359 /** |
|
360 * Starts connection recovery timer |
|
361 * @param aFunction The function to call after the time out |
|
362 */ |
|
363 void StartConnectionRecoveryTimer( TInt (*aFunction)(TAny* aPtr) ); |
|
364 |
|
365 /** |
|
366 * Cancels the connection recovery timer |
|
367 */ |
|
368 void CancelConnectionRecoveryTimer(); |
|
369 |
|
370 /** |
|
371 * Connection recovery callback |
|
372 * @param aSelf this object |
|
373 */ |
|
374 static TInt ConnectionRecoveryEvent( TAny* aSelf ); |
|
375 |
|
376 /** |
|
377 * Handles connection recovery event |
|
378 */ |
|
379 void HandleConnectionRecovery(); |
|
380 |
|
381 /** |
|
382 * Starts plugin unload timer |
|
383 * @param aFunction The function to call after the time out |
|
384 */ |
|
385 void StartPluginUnloadTimer(); |
|
386 |
|
387 /** |
|
388 * Cancels the connection recovery timer |
|
389 */ |
|
390 void CancelPluginUnloadTimer(); |
|
391 |
|
392 /** |
|
393 * Starts handle notify delay timer |
|
394 * @param aFunction The function to call after the time out |
|
395 */ |
|
396 void StartHandleNotifyDelayTimer(); |
|
397 |
|
398 /** |
|
399 * Cancels the handler notify delay timer |
|
400 */ |
|
401 void CancelHandleNotifyDelayTimer(); |
|
402 |
|
403 /** |
|
404 * Plugin unload callback |
|
405 * @param aSelf this object |
|
406 */ |
|
407 static TInt PluginUnloadEvent( TAny* aSelf ); |
|
408 |
|
409 /** |
|
410 * Handle notify event callback |
|
411 * @param aSelf this object |
|
412 */ |
|
413 static TInt HandleNotifyEvent( TAny* aSelf ); |
|
414 |
|
415 /** |
|
416 * Handles plugin unload event |
|
417 */ |
|
418 void HandlePluginUnload(); |
|
419 |
|
420 /** |
|
421 * Handles delayed notify event |
|
422 */ |
|
423 void HandleDelayedNotifyEvent(); |
|
424 |
|
425 /** |
|
426 * From MCCHCommDbWatcherObserver, handles commsdb events |
|
427 */ |
|
428 void HandleWLANIapAdded( TInt aSNAPId ); |
|
429 |
|
430 /** |
|
431 * Checks if there is wlan iap used, second part |
|
432 */ |
|
433 TBool UsesWlanIap( const TServiceSelection& aServiceSelection ); |
|
434 |
|
435 /** |
|
436 * Checks if there is wlan iap used |
|
437 */ |
|
438 TBool HasWlanIap( const TServiceSelection& aServiceSelection ); |
|
439 |
|
440 /** |
|
441 * Checks if IAP or SNAP is defined for certain subservice |
|
442 */ |
|
443 TBool IsConnectionDefinedL( const TServiceSelection& aServiceSelection ); |
|
444 |
|
445 /** |
|
446 * Checks if IAP or SNAP is defined for certain service |
|
447 */ |
|
448 TBool IsServiceConnectivityDefinedL( const TServiceSelection& aServiceSelection ); |
|
449 |
|
450 private: // data |
|
451 |
|
452 /** |
|
453 * Handle to server |
|
454 */ |
|
455 CCCHServerBase& iServer; |
|
456 |
|
457 /** |
|
458 * Service array |
|
459 */ |
|
460 RServiceArray iServices; |
|
461 |
|
462 /** |
|
463 * Pointer to CSPNotifyChange |
|
464 */ |
|
465 CSPNotifyChange* iNotifier; |
|
466 |
|
467 /** |
|
468 * Service id array |
|
469 */ |
|
470 RIdArray iServiceIds; |
|
471 |
|
472 /** |
|
473 * UI handler to show VoIP small icon etc. |
|
474 */ |
|
475 CCchUIHandler* iCchUIHandler; |
|
476 |
|
477 /** |
|
478 * Connection recovery timer. Owned. |
|
479 */ |
|
480 CPeriodic* iConnectionRecoveryTimer; |
|
481 |
|
482 /** |
|
483 * Plugin unload timer. Owned. |
|
484 */ |
|
485 CPeriodic* iPluginUnloadTimer; |
|
486 |
|
487 /** |
|
488 * Handle notify delay timer. Owned. |
|
489 */ |
|
490 CPeriodic* iHandleNotifyDelayTimer; |
|
491 |
|
492 /** |
|
493 * Recovery trial counter |
|
494 */ |
|
495 TInt iConnectionRecoveryTry; |
|
496 |
|
497 /** |
|
498 * Services that require recovery |
|
499 */ |
|
500 RArray<TServiceSelection> iServicesInRecovery; |
|
501 |
|
502 /** |
|
503 * Recovery intervals |
|
504 */ |
|
505 RArray<TInt> iRecoveryInterval; |
|
506 |
|
507 /** |
|
508 * WLAN extension |
|
509 */ |
|
510 CCchWlanExtension* iWlanExtension; |
|
511 |
|
512 /** |
|
513 * CommsDb watcher |
|
514 */ |
|
515 CCCHCommDbWatcher* iCommDbWatcher; |
|
516 |
|
517 /** |
|
518 * Disable SPSettings notifications |
|
519 */ |
|
520 TBool iCancelNotify; |
|
521 |
|
522 /** |
|
523 * Service id of delayed handle notify event |
|
524 */ |
|
525 TServiceId iDelayedHandleNotifyServiceId; |
|
526 }; |
|
527 |
|
528 #endif // C_CCHSERVICEHANDLER_H |
|
529 |
|
530 // End of file |
|