|
1 /* |
|
2 * Copyright (c) 2002-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: Connection Monitor server. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <featmgr.h> |
|
19 #include <rconnmon.h> |
|
20 |
|
21 #include "ConnMonServ.h" |
|
22 #include "ConnMonDef.h" |
|
23 #include "ConnMonIAP.h" |
|
24 #include "ConnMonSess.h" |
|
25 #include "CEventQueue.h" |
|
26 #include "log.h" |
|
27 |
|
28 #include "ConnMonAvailabilityManager.h" |
|
29 #include "connmoncommsdatcache.h" |
|
30 #include "ConnMonBearerCSD.h" |
|
31 #include "ConnMonBearerGPRS.h" |
|
32 #include "ConnMonBearerLAN.h" |
|
33 #include "ConnMonBearerWLAN.h" |
|
34 #include "ConnMonBearerGroupManager.h" |
|
35 #include "connmoncommsdatnotifier.h" |
|
36 |
|
37 // ============================ LOCAL FUNCTIONS =============================== |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // PanicServer |
|
41 // Panics the server in case of programming error. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 void PanicServer( TInt aPanic ) |
|
45 { |
|
46 _LIT( KPanicCategory, "ConnectionMonitor Server" ); |
|
47 User::Panic( KPanicCategory, aPanic ); |
|
48 } |
|
49 |
|
50 // ============================ MEMBER FUNCTIONS =============================== |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CConnMonScheduler::ConstructL |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 void CConnMonScheduler::ConstructL() |
|
57 { |
|
58 // Construct active scheduler |
|
59 CConnMonScheduler* self = new( ELeave ) CConnMonScheduler; |
|
60 CActiveScheduler::Install( self ); |
|
61 |
|
62 // Construct server |
|
63 self->iServer = new( ELeave ) CConnMonServer; |
|
64 self->iServer->ConstructL(); |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CConnMonScheduler::~CConnMonScheduler |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 CConnMonScheduler::~CConnMonScheduler() |
|
72 { |
|
73 delete iServer; |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CConnMonScheduler::LaunchFromClient |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 TInt CConnMonScheduler::LaunchFromClient() |
|
81 { |
|
82 LOGENTRFN("CConnMonScheduler::LaunchFromClient()") |
|
83 TInt err( KErrNone ); |
|
84 |
|
85 // Set up waiting apparatus |
|
86 TRequestStatus status; |
|
87 TSignal signal( status ); |
|
88 |
|
89 // Create semaphore to allow to signal when server has started |
|
90 RSemaphore globStartSignal; |
|
91 |
|
92 LOGTIMINGSTART("CConnMonScheduler::LaunchFromClient()") |
|
93 |
|
94 err = globStartSignal.CreateGlobal( KConnMonStartupSemaphore, 0 ); |
|
95 if ( err != KErrNone ) |
|
96 { |
|
97 // If semaphore already exists, open it and wait |
|
98 err = globStartSignal.OpenGlobal( KConnMonStartupSemaphore, EOwnerProcess ); |
|
99 if ( KErrNone == err ) |
|
100 { |
|
101 LOGIT("LaunchFromClient: semaphore in use, waiting release...") |
|
102 globStartSignal.Wait(); |
|
103 globStartSignal.Signal(); |
|
104 globStartSignal.Close(); |
|
105 LOGTIMINGEND("CConnMonScheduler::LaunchFromClient() (waiting)") |
|
106 LOGIT("LaunchFromClient: semaphore released") |
|
107 } |
|
108 else |
|
109 { |
|
110 LOGIT1("LaunchFromClient: semaphore in use, but open failed <%d>", err) |
|
111 } |
|
112 LOGEXITFN1("CConnMonScheduler::LaunchFromClient()", err) |
|
113 return err; |
|
114 } |
|
115 |
|
116 RProcess server; |
|
117 err = server.Create( |
|
118 KConnectionMonitorServerExe, |
|
119 signal.Get(), |
|
120 TUidType( KNullUid, KNullUid, KConnMonServerUid ), |
|
121 EOwnerThread ); |
|
122 if ( err != KErrNone ) |
|
123 { |
|
124 LOGIT1("LaunchFromClient: ERROR, server creation failed <%d>", err) |
|
125 LOGEXITFN1("CConnMonScheduler::LaunchFromClient()", err) |
|
126 return err; |
|
127 } |
|
128 |
|
129 server.Rendezvous( status ); |
|
130 if ( status != KRequestPending ) |
|
131 { |
|
132 server.Kill( 0 ); // Abort startup |
|
133 } |
|
134 else |
|
135 { |
|
136 server.Resume(); // Logon OK - start the server |
|
137 } |
|
138 |
|
139 // Wait for launch to complete |
|
140 User::WaitForRequest( status ); |
|
141 |
|
142 // We can't use the 'exit reason' if the server panicked as this is the |
|
143 // panic 'reason' and may be '0' which cannot be distinguished from KErrNone |
|
144 if ( server.ExitType() == EExitPanic ) |
|
145 { |
|
146 LOGIT2("LaunchFromClient: ERROR, server start PANIC, reason: %d, status: %d", server.ExitReason(), status.Int()) |
|
147 err = KErrGeneral; |
|
148 } |
|
149 else |
|
150 { |
|
151 err = status.Int(); |
|
152 } |
|
153 |
|
154 server.Close(); |
|
155 |
|
156 // Signal other clients that server process has started |
|
157 globStartSignal.Signal(); |
|
158 |
|
159 // Delete semaphore |
|
160 globStartSignal.Close(); |
|
161 |
|
162 LOGTIMINGEND("CConnMonScheduler::LaunchFromClient() (real)") |
|
163 LOGEXITFN1("CConnMonScheduler::LaunchFromClient()", err) |
|
164 return err; |
|
165 } |
|
166 |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // CConnMonScheduler::ThreadStart |
|
170 // ----------------------------------------------------------------------------- |
|
171 // |
|
172 EXPORT_C TInt CConnMonScheduler::ThreadStart( TSignal& /*aSignal*/ ) |
|
173 { |
|
174 __UHEAP_MARK; |
|
175 LOGENTRFN("CConnMonScheduler::ThreadStart()") |
|
176 TInt err( KErrNone ); |
|
177 |
|
178 // Get cleanup stack |
|
179 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
180 // Initialize all up to and excluding starting scheduler |
|
181 if ( cleanup ) |
|
182 { |
|
183 TRAP( err, ConstructL() ); |
|
184 } |
|
185 else |
|
186 { |
|
187 err = KErrNoMemory; |
|
188 } |
|
189 |
|
190 // Tell starting thread we've started and start the active scheduler |
|
191 // Scheduler will "sit" here while the server is running because |
|
192 // Start() will return only when server calls CActiveScheduler::Stop(). |
|
193 if ( KErrNone == err ) |
|
194 { |
|
195 RProcess::Rendezvous( KErrNone ); |
|
196 CActiveScheduler::Start(); |
|
197 } |
|
198 |
|
199 // Close things down because server has died |
|
200 delete CActiveScheduler::Current(); |
|
201 delete cleanup; |
|
202 |
|
203 __UHEAP_MARKEND; |
|
204 LOGEXITFN1("CConnMonScheduler::ThreadStart()", err) |
|
205 return err; |
|
206 } |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // CConnMonScheduler::Error |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 void CConnMonScheduler::Error( TInt aError ) const |
|
213 { |
|
214 // Panic if error didn't arise from server |
|
215 if ( iServer->IsActive() ) |
|
216 { |
|
217 PanicServer( EErrorFromNonClientObject ); |
|
218 } |
|
219 |
|
220 // If it's a bad descriptor, panic the client |
|
221 if ( aError == KErrBadDescriptor ) |
|
222 { |
|
223 iServer->PanicClient( EBadDescriptor ); |
|
224 } |
|
225 |
|
226 iServer->Error( aError ); |
|
227 } |
|
228 |
|
229 // ============================ MEMBER FUNCTIONS =============================== |
|
230 |
|
231 // ----------------------------------------------------------------------------- |
|
232 // CConnMonServer::CConnMonServer |
|
233 // ----------------------------------------------------------------------------- |
|
234 // |
|
235 CConnMonServer::CConnMonServer() |
|
236 : |
|
237 CPolicyServer( CActive::EPriorityStandard, KConnMonPolicy ), |
|
238 iAvailabilityManager( NULL ) |
|
239 { |
|
240 } |
|
241 |
|
242 // ----------------------------------------------------------------------------- |
|
243 // CConnMonServer::ConstructL |
|
244 // ----------------------------------------------------------------------------- |
|
245 // |
|
246 void CConnMonServer::ConstructL() |
|
247 { |
|
248 LOGENTRFN("CConnMonServer::ConstructL()") |
|
249 LOGIT("ConstructL: Server trying to start...") |
|
250 |
|
251 // Naming the server thread after the server helps debugging panics. |
|
252 RThread::RenameMe( KConnectionMonitorServerName ); |
|
253 |
|
254 // Construct IAP wrapper |
|
255 iIap = new( ELeave ) CConnMonIAP( this ); |
|
256 iIap->ConstructL(); |
|
257 |
|
258 // Construct event queue |
|
259 iEventQueue = new( ELeave ) CEventQueue; |
|
260 iEventQueue->ConstructL( this ); |
|
261 |
|
262 // Create the object container index |
|
263 iContainerIndex = CObjectConIx::NewL(); |
|
264 |
|
265 // Construct shutdown timer |
|
266 iShutdown = new( ELeave ) CConnMonDelayedShutdown( this ); |
|
267 iShutdown->ConstructL(); |
|
268 |
|
269 |
|
270 ////// Availability stuff |
|
271 |
|
272 // CommsDat cache |
|
273 iCommsDatCache = CConnMonCommsDatCache::NewL(); |
|
274 |
|
275 // Add bearers to array |
|
276 User::LeaveIfError( |
|
277 iBearers.Append( new( ELeave ) TConnMonBearerCSD( iIap, iCommsDatCache ) ) ); |
|
278 User::LeaveIfError( |
|
279 iBearers.Append( new( ELeave ) TConnMonBearerGPRS( iIap, iCommsDatCache ) ) ); |
|
280 User::LeaveIfError( |
|
281 iBearers.Append( new( ELeave ) TConnMonBearerLAN( iIap, iCommsDatCache ) ) ); |
|
282 |
|
283 // Initialize FeatureManager |
|
284 FeatureManager::InitializeLibL(); |
|
285 |
|
286 #ifndef __WINSCW__ // WINS does not support WLAN |
|
287 // Check if WLAN is enabled |
|
288 if ( FeatureManager::FeatureSupported( KFeatureIdProtocolWlan ) ) |
|
289 { |
|
290 User::LeaveIfError( |
|
291 iBearers.Append( new( ELeave ) TConnMonBearerWLAN( iIap, iCommsDatCache ) ) ); |
|
292 } |
|
293 #endif |
|
294 LOGIT1("ConstructL: iBearers constructed, count <%d>", iBearers.Count() ) |
|
295 |
|
296 // Initialize the CommsDat cache. Will read the necessary CommsDat tables |
|
297 // and populate the cache tables with current information. Any changes |
|
298 // after this init phase will trigger ConnMon events when appropriate. |
|
299 iCommsDatCache->Init( this, iIap, &iBearers ); |
|
300 |
|
301 // IAP / SNAP availability manager |
|
302 iAvailabilityManager = CConnMonAvailabilityManager::NewL( |
|
303 iCommsDatCache, |
|
304 this ); |
|
305 |
|
306 // Central Repository notifiers |
|
307 iIapTableNotifier = CConnMonCommsDatNotifier::NewL( |
|
308 iAvailabilityManager, |
|
309 iCommsDatCache->GetIapRecordTableId() ); |
|
310 iSnapTableNotifier = CConnMonCommsDatNotifier::NewL( |
|
311 iAvailabilityManager, |
|
312 iCommsDatCache->GetSnapRecordTableId() ); |
|
313 iVirtualTableNotifier = CConnMonCommsDatNotifier::NewL( |
|
314 iAvailabilityManager, |
|
315 iCommsDatCache->GetVirtualRecordTableId() ); |
|
316 LOGIT("ConstructL: Availability manager and CenRep notifiers constructed") |
|
317 |
|
318 // Bearer group manager |
|
319 iBearerGroupManager = CConnMonBearerGroupManager::NewL(); |
|
320 LOGIT("ConstructL: Bearer group manager constructed") |
|
321 |
|
322 // Identify ourselves and open for service |
|
323 StartL( KConnectionMonitorServerName ); |
|
324 |
|
325 LOGIT("ConstructL: Server started successfully") |
|
326 LOGEXITFN("CConnMonServer::ConstructL()") |
|
327 } |
|
328 |
|
329 // ----------------------------------------------------------------------------- |
|
330 // CConnMonServer::~CConnMonServer |
|
331 // ----------------------------------------------------------------------------- |
|
332 // |
|
333 CConnMonServer::~CConnMonServer() |
|
334 { |
|
335 LOGIT("Server: Running destructor") |
|
336 |
|
337 delete iIap; |
|
338 delete iEventQueue; |
|
339 delete iContainerIndex; |
|
340 delete iShutdown; |
|
341 |
|
342 // Bearers to array |
|
343 iBearers.ResetAndDestroy(); |
|
344 iBearers.Close(); |
|
345 |
|
346 // Availability manager |
|
347 delete iAvailabilityManager; |
|
348 |
|
349 // CenRep notification listeners |
|
350 if ( iIapTableNotifier ) |
|
351 { |
|
352 iIapTableNotifier->Cancel(); |
|
353 } |
|
354 if ( iSnapTableNotifier ) |
|
355 { |
|
356 iSnapTableNotifier->Cancel(); |
|
357 } |
|
358 if ( iVirtualTableNotifier ) |
|
359 { |
|
360 iVirtualTableNotifier->Cancel(); |
|
361 } |
|
362 delete iIapTableNotifier; |
|
363 delete iSnapTableNotifier; |
|
364 delete iVirtualTableNotifier; |
|
365 |
|
366 // CommsDat cache |
|
367 delete iCommsDatCache; |
|
368 |
|
369 // Bearer Group Manager |
|
370 delete iBearerGroupManager; |
|
371 |
|
372 FeatureManager::UnInitializeLib(); |
|
373 } |
|
374 |
|
375 // ----------------------------------------------------------------------------- |
|
376 // CConnMonServer::NewSessionL |
|
377 // ----------------------------------------------------------------------------- |
|
378 // |
|
379 CSession2* CConnMonServer::NewSessionL( |
|
380 const TVersion& /*aVersion*/, |
|
381 const RMessage2& /*aMessage*/ ) const |
|
382 { |
|
383 CConnMonSession* session = new( ELeave ) CConnMonSession( |
|
384 CONST_CAST( CConnMonServer*, this ) ); |
|
385 |
|
386 CleanupStack::PushL( session ); |
|
387 session->ConstructL(); |
|
388 CleanupStack::Pop( session ); |
|
389 CONST_CAST( CConnMonServer*, this )->IncrementSessions(); |
|
390 return session; |
|
391 } |
|
392 |
|
393 // ----------------------------------------------------------------------------- |
|
394 // CConnMonServer::IncrementSessions |
|
395 // ----------------------------------------------------------------------------- |
|
396 // |
|
397 void CConnMonServer::IncrementSessions() |
|
398 { |
|
399 iSessionCount++; |
|
400 iShutdown->Cancel(); |
|
401 } |
|
402 |
|
403 // ----------------------------------------------------------------------------- |
|
404 // CConnMonServer::DecrementSessions |
|
405 // ----------------------------------------------------------------------------- |
|
406 // |
|
407 void CConnMonServer::DecrementSessions() |
|
408 { |
|
409 iSessionCount--; |
|
410 |
|
411 if ( iSessionCount > 0 ) |
|
412 { |
|
413 return; |
|
414 } |
|
415 if ( !iShutdown->IsActive() ) |
|
416 { |
|
417 iShutdown->Start(); |
|
418 } |
|
419 } |
|
420 |
|
421 // ----------------------------------------------------------------------------- |
|
422 // CConnMonServer::SendEventToSessions |
|
423 // ----------------------------------------------------------------------------- |
|
424 // |
|
425 void CConnMonServer::SendEventToSessions( const TEvent& aEvent, TInt& aNumOffered ) |
|
426 { |
|
427 CSession2* session; |
|
428 |
|
429 // Iterate through sessions |
|
430 iSessionIter.SetToFirst(); |
|
431 for ( session = iSessionIter++; session; session = iSessionIter++ ) |
|
432 { |
|
433 CConnMonSession* cmsession = static_cast<CConnMonSession*>( session ); |
|
434 if ( cmsession->CanReceiveEvent() ) |
|
435 { |
|
436 cmsession->SendEventToClient( aEvent ); |
|
437 ++aNumOffered; |
|
438 } |
|
439 } |
|
440 } |
|
441 |
|
442 // ----------------------------------------------------------------------------- |
|
443 // CConnMonServer::SendDataVolumesToSessions |
|
444 // ----------------------------------------------------------------------------- |
|
445 // |
|
446 void CConnMonServer::SendDataVolumesToSessions( |
|
447 const TUint aConnectionId, |
|
448 const TUint aDlData, |
|
449 const TUint aUlData, |
|
450 const TInt aStatus ) |
|
451 { |
|
452 CSession2* session; |
|
453 |
|
454 // Iterate through sessions |
|
455 iSessionIter.SetToFirst(); |
|
456 for ( session = iSessionIter++; session; session = iSessionIter++ ) |
|
457 { |
|
458 ( static_cast<CConnMonSession*>( session ) )->CompleteDataVolumeRequests( |
|
459 aConnectionId, |
|
460 aDlData, |
|
461 aUlData, |
|
462 aStatus ); |
|
463 } |
|
464 } |
|
465 |
|
466 // ----------------------------------------------------------------------------- |
|
467 // CConnMonServer::SendActivityToSessions |
|
468 // ----------------------------------------------------------------------------- |
|
469 // |
|
470 void CConnMonServer::SendActivityToSessions( |
|
471 const TUint aConnectionId, |
|
472 const TBool aActivity, |
|
473 const TInt aStatus ) |
|
474 { |
|
475 CSession2* session; |
|
476 |
|
477 // Iterate through sessions |
|
478 iSessionIter.SetToFirst(); |
|
479 for ( session = iSessionIter++; session; session = iSessionIter++ ) |
|
480 { |
|
481 ( static_cast<CConnMonSession*>( session ) )->CompleteActivityRequests( |
|
482 aConnectionId, |
|
483 aActivity, |
|
484 aStatus ); |
|
485 } |
|
486 } |
|
487 |
|
488 // ----------------------------------------------------------------------------- |
|
489 // CConnMonServer::RemoveConnSettingsFromSessions |
|
490 // ----------------------------------------------------------------------------- |
|
491 // |
|
492 void CConnMonServer::RemoveConnSettingsFromSessions( const TUint aConnectionId ) |
|
493 { |
|
494 CSession2* session; |
|
495 |
|
496 // Iterate through sessions |
|
497 iSessionIter.SetToFirst(); |
|
498 for ( session = iSessionIter++; session; session = iSessionIter++ ) |
|
499 { |
|
500 ( static_cast<CConnMonSession*>( session ) )->RemoveConnectionParams( |
|
501 aConnectionId ); |
|
502 } |
|
503 } |
|
504 |
|
505 // ----------------------------------------------------------------------------- |
|
506 // CConnMonServer::NumberOfListeners |
|
507 // ----------------------------------------------------------------------------- |
|
508 // |
|
509 TInt CConnMonServer::NumberOfListeners() |
|
510 { |
|
511 CSession2* session; |
|
512 CSession2* original; |
|
513 TInt count( 0 ); |
|
514 |
|
515 original = iSessionIter; |
|
516 |
|
517 // Iterate through sessions |
|
518 iSessionIter.SetToFirst(); |
|
519 for ( session = iSessionIter++; session; session = iSessionIter++ ) |
|
520 { |
|
521 if ( ( static_cast<CConnMonSession*>( session ) )->IsListening() ) |
|
522 { |
|
523 ++count; |
|
524 } |
|
525 } |
|
526 |
|
527 // Reset session iterator |
|
528 if ( original != 0 ) |
|
529 { |
|
530 iSessionIter.Set( *original ); |
|
531 } |
|
532 |
|
533 return count; |
|
534 } |
|
535 |
|
536 // ----------------------------------------------------------------------------- |
|
537 // CConnMonServer::CalculateThreshold |
|
538 // ----------------------------------------------------------------------------- |
|
539 // |
|
540 void CConnMonServer::CalculateThreshold( |
|
541 const TUint aConnectionId, |
|
542 const TInt& aThresholdType, |
|
543 TUint& aThreshold ) |
|
544 { |
|
545 CSession2* session; |
|
546 CSession2* original; |
|
547 TUint th( 0 ); |
|
548 |
|
549 aThreshold = 0; |
|
550 original = iSessionIter; |
|
551 |
|
552 // Iterate through sessions to find the smallest threshold |
|
553 iSessionIter.SetToFirst(); |
|
554 for ( session = iSessionIter++; session; session = iSessionIter++ ) |
|
555 { |
|
556 if ( aThresholdType == EBearerAvailabilityThreshold || |
|
557 aThresholdType == ESignalStrengthThreshold ) |
|
558 { |
|
559 // Bearer specific thresholds |
|
560 ( static_cast<CConnMonSession*>( session ) )->GetBearerThreshold( |
|
561 aThresholdType, |
|
562 th ); |
|
563 |
|
564 if ( th != 0 ) |
|
565 { |
|
566 aThreshold = 1; |
|
567 } |
|
568 } |
|
569 else |
|
570 { |
|
571 // Connection Specific thresholds |
|
572 TConnSettings connSettings( 0, 0, 0 ); |
|
573 |
|
574 ( static_cast<CConnMonSession*>( session ) )->GetConnectionSettings( |
|
575 aConnectionId, |
|
576 connSettings ); |
|
577 if ( aThresholdType == EDownlinkThreshold ) |
|
578 { |
|
579 th = connSettings.iDLDataThreshold; |
|
580 } |
|
581 else if ( aThresholdType == EUplinkThreshold ) |
|
582 { |
|
583 th = connSettings.iULDataThreshold; |
|
584 } |
|
585 else if ( aThresholdType == EActivityTimeThreshold ) |
|
586 { |
|
587 th = connSettings.iActivityTimeThreshold; |
|
588 } |
|
589 |
|
590 if ( ( th > 0 ) && ( aThreshold == 0 || th < aThreshold ) ) |
|
591 { |
|
592 aThreshold = th; |
|
593 } |
|
594 } |
|
595 } |
|
596 |
|
597 // Reset session iterator |
|
598 if ( original != 0 ) |
|
599 { |
|
600 iSessionIter.Set( *original ); |
|
601 } |
|
602 } |
|
603 |
|
604 // ----------------------------------------------------------------------------- |
|
605 // CConnMonServer::NewContainerL |
|
606 // ----------------------------------------------------------------------------- |
|
607 // |
|
608 CObjectCon* CConnMonServer::NewContainerL() |
|
609 { |
|
610 return iContainerIndex->CreateL(); |
|
611 } |
|
612 |
|
613 // ----------------------------------------------------------------------------- |
|
614 // CConnMonServer::RemoveContainer |
|
615 // ----------------------------------------------------------------------------- |
|
616 // |
|
617 void CConnMonServer::RemoveContainer( CObjectCon* aContainer ) |
|
618 { |
|
619 iContainerIndex->Remove( aContainer ); |
|
620 } |
|
621 |
|
622 // ----------------------------------------------------------------------------- |
|
623 // CConnMonServer::SendRequestToPlugin |
|
624 // ----------------------------------------------------------------------------- |
|
625 // |
|
626 TInt CConnMonServer::SendRequestToPlugin( |
|
627 const TInt aType, |
|
628 const RMessage2& aMessage, |
|
629 const TBool aToAllPlugins ) |
|
630 { |
|
631 TInt ret( KErrNotSupported ); |
|
632 TInt err( KErrNotSupported ); |
|
633 CSession2* session; |
|
634 |
|
635 if ( FeatureManager::FeatureSupported( KFeatureIdConnMonExtension ) ) |
|
636 { |
|
637 // Iterate through sessions |
|
638 iSessionIter.SetToFirst(); |
|
639 |
|
640 for ( session = iSessionIter++; session; session = iSessionIter++ ) |
|
641 { |
|
642 err = ( static_cast<CConnMonSession*>( session ) )->SendRequestToPlugin( |
|
643 aType, |
|
644 aMessage ); |
|
645 |
|
646 if ( ( err == KRequestPending ) || ( err == KErrNone ) ) |
|
647 { |
|
648 // OK because a plugin has handled the request. |
|
649 if ( aToAllPlugins ) |
|
650 { |
|
651 ret = err; |
|
652 } |
|
653 else |
|
654 { |
|
655 return err; |
|
656 } |
|
657 } |
|
658 } |
|
659 } |
|
660 return ret; |
|
661 } |
|
662 |
|
663 // ----------------------------------------------------------------------------- |
|
664 // CConnMonServer::CancelAttributeRequestsFromPlugins |
|
665 // ----------------------------------------------------------------------------- |
|
666 // |
|
667 void CConnMonServer::CancelAttributeRequestsFromPlugins( |
|
668 const RThread& aClient, |
|
669 const TInt aType ) |
|
670 { |
|
671 CSession2* session; |
|
672 |
|
673 if ( FeatureManager::FeatureSupported( KFeatureIdConnMonExtension ) ) |
|
674 { |
|
675 // Iterate through sessions |
|
676 iSessionIter.SetToFirst(); |
|
677 |
|
678 for ( session = iSessionIter++; session; session = iSessionIter++ ) |
|
679 { |
|
680 ( static_cast<CConnMonSession*>( session ) )->CancelAttributeRequestFromPlugin( |
|
681 aClient, |
|
682 aType ); |
|
683 } |
|
684 } |
|
685 } |
|
686 |
|
687 // ----------------------------------------------------------------------------- |
|
688 // CConnMonServer::PanicClient |
|
689 // ----------------------------------------------------------------------------- |
|
690 // |
|
691 void CConnMonServer::PanicClient( TInt aPanic ) const |
|
692 { |
|
693 // Let's have a look before we panic the client |
|
694 __DEBUGGER() |
|
695 |
|
696 // Ok, go for it |
|
697 LOGIT("Server: PanicClient: Sending panic") |
|
698 /*_LIT( KConnectionMonitorServer, "ConnMonServ" );*/ |
|
699 /*Message().Panic( KConnectionMonitorServer, aPanic );*/ |
|
700 LOGIT1("Server: PanicClient: Panic removed to improve ConnMon robustness, code was <%d>", aPanic ) |
|
701 aPanic = aPanic; // To remove warning |
|
702 } |
|
703 |
|
704 // ----------------------------------------------------------------------------- |
|
705 // CConnMonServer::PanicClient |
|
706 // ----------------------------------------------------------------------------- |
|
707 // |
|
708 void CConnMonServer::PanicClient( const RMessage2& aMsg, const TInt aPanic ) const |
|
709 { |
|
710 // Let's have a look before we panic the client |
|
711 __DEBUGGER() |
|
712 |
|
713 // Ok, go for it |
|
714 LOGIT("Server: PanicClient: Sending panic") |
|
715 /*_LIT( KConnectionMonitorServer, "ConnMonServ" );*/ |
|
716 /*aMsg.Panic( KConnectionMonitorServer, aPanic );*/ |
|
717 LOGIT1("Server: PanicClient: Panic removed to improve ConnMon robustness, code was <%d>", aPanic ) |
|
718 TInt panic = aPanic; // To remove warning |
|
719 panic = aMsg.Int0(); // To remove warning |
|
720 panic = panic; // To remove warning |
|
721 } |
|
722 |
|
723 // ----------------------------------------------------------------------------- |
|
724 // CConnMonServer::Error |
|
725 // ----------------------------------------------------------------------------- |
|
726 // |
|
727 void CConnMonServer::Error( TInt aError ) |
|
728 { |
|
729 if ( aError != KErrBadDescriptor ) |
|
730 { |
|
731 // Anyway, complete the outstanding message |
|
732 Message().Complete( aError ); |
|
733 } |
|
734 |
|
735 // Ready to roll again |
|
736 ReStart(); // Really means just continue reading client requests |
|
737 } |
|
738 |
|
739 // ----------------------------------------------------------------------------- |
|
740 // Get available IAP IDs for the IAPs with bearer aBearerId |
|
741 // ----------------------------------------------------------------------------- |
|
742 // |
|
743 TInt CConnMonServer::GetAvailableIaps( const TUint aBearerId, TConnMonIapInfo& aIapInfo ) |
|
744 { |
|
745 // Currently CommsDat is read only after a change notification is received |
|
746 // from CenRep about a relevant CommsDat table. If these events are |
|
747 // unreliable, we can increase robustness by reading CommsDat tables again |
|
748 // every time a client asks for IAP/SNAP availability information, but this |
|
749 // will slow down the requests. |
|
750 // |
|
751 // Uncomment the following TRAP to force ConnMon to read CommsDat every |
|
752 // time a client asks for IAP availability (KIapAvailability-attribute). |
|
753 // |
|
754 /*TRAPD( err, iCommsDatCache->RefreshCommsDatCacheL( 0 ) );*/ |
|
755 return iCommsDatCache->GetAvailableIaps( aBearerId, aIapInfo ); |
|
756 } |
|
757 |
|
758 // ----------------------------------------------------------------------------- |
|
759 // Get available SANP IDs |
|
760 // ----------------------------------------------------------------------------- |
|
761 // |
|
762 void CConnMonServer::GetAvailableSnaps( TConnMonSNAPInfo& aSnapInfo ) |
|
763 { |
|
764 // See comment in CConnMonServer::GetAvailableIaps() (above) |
|
765 /*TRAPD( err, iCommsDatCache->RefreshCommsDatCacheL( 0 ) );*/ |
|
766 iCommsDatCache->GetAvailableSnaps( aSnapInfo ); |
|
767 } |
|
768 |
|
769 // ----------------------------------------------------------------------------- |
|
770 // Get available SANP IDs |
|
771 // ----------------------------------------------------------------------------- |
|
772 // |
|
773 TInt CConnMonServer::GetAvailableSnaps( RArray<TConnMonId>& aSnapIds ) |
|
774 { |
|
775 // See comment in CConnMonServer::GetAvailableIaps() (above) |
|
776 /*TRAPD( err, iCommsDatCache->RefreshCommsDatCacheL( 0 ) );*/ |
|
777 return iCommsDatCache->GetAvailableSnaps( aSnapIds ); |
|
778 } |
|
779 |
|
780 // ----------------------------------------------------------------------------- |
|
781 // CConnMonServer::CustomSecurityCheckL |
|
782 // Implements custom security checking for IPCs marked with |
|
783 // TSpecialCase::ECustomCheck. |
|
784 // ----------------------------------------------------------------------------- |
|
785 // |
|
786 CPolicyServer::TCustomResult CConnMonServer::CustomSecurityCheckL( |
|
787 const RMessage2& aMsg, |
|
788 TInt& /*aAction*/, |
|
789 TSecurityInfo& /*aMissing*/ ) |
|
790 { |
|
791 switch ( aMsg.Function() ) |
|
792 { |
|
793 case EReqSetBoolAttribute: |
|
794 { |
|
795 switch ( aMsg.Int2() ) |
|
796 { |
|
797 case KConnectionStop: |
|
798 case KConnectionStopAll: |
|
799 { |
|
800 // NetworkServices + NetworkControl |
|
801 return ( KConnMonPolicyElements[4].iPolicy.CheckPolicy( aMsg ) ) ? |
|
802 EPass : EFail; |
|
803 } |
|
804 default: |
|
805 return EPass; |
|
806 } |
|
807 } |
|
808 default: |
|
809 return EPass; |
|
810 } |
|
811 } |
|
812 |
|
813 // ============================ MEMBER FUNCTIONS =============================== |
|
814 |
|
815 // ----------------------------------------------------------------------------- |
|
816 // CConnMonDelayedShutdown::CConnMonDelayedShutdown |
|
817 // ----------------------------------------------------------------------------- |
|
818 // |
|
819 CConnMonDelayedShutdown::CConnMonDelayedShutdown( CConnMonServer* aServer ) |
|
820 : |
|
821 CActive( EConnMonPriorityNormal ), |
|
822 iServer( aServer ) |
|
823 { |
|
824 } |
|
825 |
|
826 // ----------------------------------------------------------------------------- |
|
827 // CConnMonDelayedShutdown::ConstructL |
|
828 // ----------------------------------------------------------------------------- |
|
829 // |
|
830 void CConnMonDelayedShutdown::ConstructL() |
|
831 { |
|
832 CActiveScheduler::Add( this ); |
|
833 User::LeaveIfError( iTimer.CreateLocal() ); |
|
834 } |
|
835 |
|
836 // Destructor |
|
837 CConnMonDelayedShutdown::~CConnMonDelayedShutdown() |
|
838 { |
|
839 Cancel(); |
|
840 iTimer.Close(); |
|
841 iServer = NULL; |
|
842 } |
|
843 |
|
844 // ----------------------------------------------------------------------------- |
|
845 // CConnMonDelayedShutdown::Start |
|
846 // ----------------------------------------------------------------------------- |
|
847 // |
|
848 void CConnMonDelayedShutdown::Start() |
|
849 { |
|
850 if ( IsActive() ) |
|
851 { |
|
852 return; |
|
853 } |
|
854 |
|
855 iTimer.After( iStatus, KConnMonShutdownInterval ); |
|
856 SetActive(); |
|
857 } |
|
858 |
|
859 // ----------------------------------------------------------------------------- |
|
860 // CConnMonDelayedShutdown::DoCancel |
|
861 // ----------------------------------------------------------------------------- |
|
862 // |
|
863 void CConnMonDelayedShutdown::DoCancel() |
|
864 { |
|
865 iTimer.Cancel(); |
|
866 } |
|
867 |
|
868 // ----------------------------------------------------------------------------- |
|
869 // CConnMonDelayedShutdown::RunL |
|
870 // ----------------------------------------------------------------------------- |
|
871 // |
|
872 void CConnMonDelayedShutdown::RunL() |
|
873 { |
|
874 LOGIT("Server: Shutting down by timer") |
|
875 CActiveScheduler::Stop(); |
|
876 } |
|
877 |
|
878 // End-of-file |