|
1 /* |
|
2 * Copyright (c) 2002-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: Event notifiers (active objects). |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
19 #include <es_enum_partner.h> |
|
20 #endif |
|
21 #include <e32base.h> |
|
22 #include <rmmcustomapi.h> |
|
23 #include <featmgr.h> |
|
24 |
|
25 #include "ConnMonServ.h" |
|
26 #include "ConnMonSess.h" |
|
27 #include "CEventQueue.h" |
|
28 #include "ConnMonIAP.h" |
|
29 #include "ConnMonNoti.h" |
|
30 #include "ConnMonAvailabilityManager.h" |
|
31 #include "log.h" |
|
32 |
|
33 // ============================ MEMBER FUNCTIONS =============================== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CConnUpDownNotifier::CConnUpDownNotifier |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CConnUpDownNotifier::CConnUpDownNotifier( |
|
40 CConnMonServer* aServer ) |
|
41 : |
|
42 CActive( EConnMonPriorityNormal ), |
|
43 iServer( aServer ) |
|
44 { |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CConnUpDownNotifier::ConstructL |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 void CConnUpDownNotifier::Construct() |
|
52 { |
|
53 //LOGENTRFN("CConnUpDownNotifier::Construct()") |
|
54 CActiveScheduler::Add( this ); |
|
55 LOGIT("Created CConnUpDownNotifier") |
|
56 //LOGEXITFN("CConnUpDownNotifier::Construct()") |
|
57 } |
|
58 |
|
59 // Destructor |
|
60 CConnUpDownNotifier::~CConnUpDownNotifier() |
|
61 { |
|
62 Cancel(); |
|
63 iServer = NULL; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CConnUpDownNotifier::Receive |
|
68 // Requests a new event (connection up/down) from RConnection |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 void CConnUpDownNotifier::Receive() |
|
72 { |
|
73 if ( IsActive() ) |
|
74 { |
|
75 Cancel(); |
|
76 } |
|
77 |
|
78 iServer->Iap()->Rconnection()->AllInterfaceNotification( iInfoBuf, iStatus ); |
|
79 SetActive(); |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CConnUpDownNotifier::DoCancel |
|
84 // Cancels the request from RConnection. |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 void CConnUpDownNotifier::DoCancel() |
|
88 { |
|
89 if ( IsActive() ) |
|
90 { |
|
91 iServer->Iap()->Rconnection()->CancelAllInterfaceNotification(); |
|
92 } |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // CConnUpDownNotifier::RunL |
|
97 // Handles the event that has arrived from RConnection |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 void CConnUpDownNotifier::RunL() |
|
101 { |
|
102 //LOGENTRFN("CConnUpDownNotifier::RunL()") |
|
103 |
|
104 // All RunL():s outside CServer-derived main class MUST NOT LEAVE. |
|
105 // Use TRAPD when needed. |
|
106 |
|
107 LOGIT(".") |
|
108 LOGIT1("RunL: CConnUpDownNotifier, status <%d>", iStatus.Int()) |
|
109 |
|
110 if ( iStatus.Int() != KErrNone ) |
|
111 { |
|
112 iErrorCounter++; |
|
113 if ( iErrorCounter > KConnMonEventErrorThreshold ) |
|
114 { |
|
115 LOGIT1("Over %d consecutive errors, stopping", KConnMonEventErrorThreshold) |
|
116 return; |
|
117 } |
|
118 } |
|
119 else |
|
120 { |
|
121 iErrorCounter = 0; |
|
122 // Send event to clients |
|
123 TInt err( KErrNone ); |
|
124 TBearerInfo bearerInfo; |
|
125 TConnInfo connInfo( |
|
126 iInfoBuf().iConnectionInfo.iIapId, |
|
127 iInfoBuf().iConnectionInfo.iNetId, |
|
128 0, |
|
129 0, |
|
130 bearerInfo ); |
|
131 |
|
132 TInt listeners( iServer->NumberOfListeners() ); |
|
133 LOGIT3("CConnUpDownNotifier, %d listeners, iap id %d, net id %d", |
|
134 listeners, connInfo.iIapId, connInfo.iNetId) |
|
135 iEventInfo.Reset(); |
|
136 |
|
137 if ( iInfoBuf().iState == EInterfaceUp ) |
|
138 { |
|
139 // Add to the connection table and fill in the new connectioId to connInfo |
|
140 TRAPD( ret, ( err = iServer->Iap()->AddConnectionL( connInfo ) ) ); |
|
141 |
|
142 if ( ( ret != KErrNone ) || ( err != KErrNone ) ) |
|
143 { |
|
144 LOGIT2("SERVER: FAILED to add a new connection <%d>,<%d>", ret, err) |
|
145 Receive(); |
|
146 return; // Can't leave |
|
147 } |
|
148 |
|
149 // Send event to all clients that are listening |
|
150 if ( listeners > 0) |
|
151 { |
|
152 iEventInfo.iEventType = EConnMonCreateConnection; |
|
153 iEventInfo.iConnectionId = connInfo.iConnectionId; |
|
154 |
|
155 iServer->EventQueue()->Add( iEventInfo ); |
|
156 } |
|
157 |
|
158 LOGIT1("SERVER: EVENT -> connection %d created.", connInfo.iConnectionId) |
|
159 } |
|
160 else if ( iInfoBuf().iState == EInterfaceDown ) |
|
161 { |
|
162 if ( listeners == 0 ) |
|
163 { |
|
164 // Remove from the connection array. Note. when the notifications |
|
165 // are ON event handlers will remove the connection from the array. |
|
166 iServer->Iap()->RemoveConnection( connInfo ); |
|
167 } |
|
168 else |
|
169 { |
|
170 TBool alreadyNotified( EFalse ); |
|
171 |
|
172 // This updates the correct 'iConnectionId' and 'iBearer' to connInfo |
|
173 TInt ret = iServer->Iap()->GetDeleteNotifyStatus( connInfo, alreadyNotified ); |
|
174 |
|
175 if ( ret == KErrNone ) |
|
176 { |
|
177 CSubConnUpDownNotifier* subConnUpDownNotifier = 0; |
|
178 |
|
179 ret = iServer->Iap()->GetSubConnUpDownNotifier( |
|
180 connInfo.iConnectionId, |
|
181 &subConnUpDownNotifier ); |
|
182 |
|
183 if ( ret == KErrNone ) |
|
184 { |
|
185 subConnUpDownNotifier->SetInterfaceClosed(); |
|
186 |
|
187 if ( !subConnUpDownNotifier->DeleteSent() ) |
|
188 { |
|
189 TNifProgress progress; |
|
190 err = iServer->Iap()->LastProgressError( |
|
191 connInfo.iConnectionId, |
|
192 progress ); |
|
193 |
|
194 if ( progress.iError == KErrDisconnected ) |
|
195 { |
|
196 // Enable WLAN scan for the next IAP availability check |
|
197 // because the current bearer has been lost (-36). MPM needs |
|
198 // a fresh list of available iaps on connection closure. |
|
199 iServer->Iap()->EnableWlanScan(); |
|
200 } |
|
201 |
|
202 // Progress and subconn notifiers have died and no delete has been sent |
|
203 subConnUpDownNotifier->SendDeletedEvent(); |
|
204 } |
|
205 else |
|
206 { |
|
207 // Delete has been sent. Just remove from internal table. |
|
208 iServer->Iap()->RemoveConnection( connInfo ); |
|
209 } |
|
210 } |
|
211 } |
|
212 |
|
213 } |
|
214 LOGIT3("SERVER: EVENT (allinterface) -> connection %d (%d, %d) closed.", |
|
215 connInfo.iConnectionId, connInfo.iIapId, connInfo.iNetId) |
|
216 } |
|
217 else |
|
218 { |
|
219 LOGIT("SERVER: Unknown event") |
|
220 Receive(); |
|
221 return; |
|
222 } |
|
223 |
|
224 LOGIT("CConnUpDownNotifier::RunL triggered HandleAvailabilityChange()") |
|
225 iServer->AvailabilityManager()->HandleAvailabilityChange(); |
|
226 } |
|
227 // New request |
|
228 Receive(); |
|
229 //LOGEXITFN("CConnUpDownNotifier::RunL()") |
|
230 } |
|
231 |
|
232 // ============================ MEMBER FUNCTIONS =============================== |
|
233 |
|
234 // ----------------------------------------------------------------------------- |
|
235 // CDataNotifier::CDataNotifier |
|
236 // ----------------------------------------------------------------------------- |
|
237 // |
|
238 CDataNotifier::CDataNotifier( |
|
239 CConnMonServer* aServer, |
|
240 RConnection* aConnection, |
|
241 const TUint& aConnectionId, |
|
242 const TUint& aSubConnectionId, |
|
243 const TInt& aDirection ) |
|
244 : |
|
245 CActive( EConnMonPriorityNormal ), |
|
246 iServer( aServer ), |
|
247 iConnection( aConnection ), |
|
248 iConnectionId( aConnectionId), |
|
249 iSubConnectionId( aSubConnectionId ), |
|
250 iDirection( aDirection ), |
|
251 iVolume( 0 ), |
|
252 iPckgVolume( iVolume ) |
|
253 { |
|
254 } |
|
255 |
|
256 // ----------------------------------------------------------------------------- |
|
257 // CDataNotifier::Construct |
|
258 // ----------------------------------------------------------------------------- |
|
259 // |
|
260 void CDataNotifier::Construct() |
|
261 { |
|
262 //LOGENTRFN("CDataNotifier::Construct()") |
|
263 CActiveScheduler::Add( this ); |
|
264 LOGIT("Created CDataNotifier") |
|
265 //LOGEXITFN("CDataNotifier::Construct()") |
|
266 } |
|
267 |
|
268 // Destructor |
|
269 CDataNotifier::~CDataNotifier() |
|
270 { |
|
271 Cancel(); |
|
272 |
|
273 iServer = NULL; |
|
274 iConnection = NULL; |
|
275 } |
|
276 |
|
277 // ----------------------------------------------------------------------------- |
|
278 // CDataNotifier::Receive |
|
279 // Requests a new event (data transferred) from RConnection |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 void CDataNotifier::Receive() |
|
283 { |
|
284 // Don't make a new request if previous |
|
285 // status indicates that connection is closing |
|
286 if ( iStatus == KErrCancel ) |
|
287 { |
|
288 return; |
|
289 } |
|
290 |
|
291 if ( IsActive() ) |
|
292 { |
|
293 return; |
|
294 } |
|
295 |
|
296 iVolume = 0; |
|
297 |
|
298 if ( iDirection == EDownlink ) |
|
299 { |
|
300 iServer->CalculateThreshold( |
|
301 iConnectionId, |
|
302 EDownlinkThreshold, |
|
303 iThreshold ); |
|
304 |
|
305 if ( iThreshold > 0 ) |
|
306 { |
|
307 iConnection->DataReceivedNotificationRequest( |
|
308 iThreshold, |
|
309 iPckgVolume, |
|
310 iStatus ); |
|
311 SetActive(); |
|
312 } |
|
313 } |
|
314 else |
|
315 { |
|
316 iServer->CalculateThreshold( |
|
317 iConnectionId, |
|
318 EUplinkThreshold, |
|
319 iThreshold ); |
|
320 if ( iThreshold > 0 ) |
|
321 { |
|
322 iConnection->DataSentNotificationRequest( |
|
323 iThreshold, |
|
324 iPckgVolume, |
|
325 iStatus ); |
|
326 SetActive(); |
|
327 } |
|
328 } |
|
329 } |
|
330 |
|
331 // ----------------------------------------------------------------------------- |
|
332 // CDataNotifier::DoCancel |
|
333 // Cancels the request from RConnection. |
|
334 // ----------------------------------------------------------------------------- |
|
335 // |
|
336 void CDataNotifier::DoCancel() |
|
337 { |
|
338 if ( IsActive() ) |
|
339 { |
|
340 if ( iDirection == EDownlink ) |
|
341 { |
|
342 iConnection->DataReceivedNotificationCancel(); |
|
343 } |
|
344 else |
|
345 { |
|
346 iConnection->DataSentNotificationCancel(); |
|
347 } |
|
348 } |
|
349 } |
|
350 |
|
351 // ----------------------------------------------------------------------------- |
|
352 // CDataNotifier::RunL |
|
353 // Handles the event that has arrived from RConnection |
|
354 // ----------------------------------------------------------------------------- |
|
355 // |
|
356 void CDataNotifier::RunL() |
|
357 { |
|
358 //LOGENTRFN("CDataNotifier::RunL()") |
|
359 |
|
360 // All RunL():s outside CServer-derived main class MUST NOT LEAVE. |
|
361 // Use TRAPD when needed. |
|
362 |
|
363 LOGIT(".") |
|
364 LOGIT1("RunL: CDataNotifier, status %d", iStatus.Int()) |
|
365 |
|
366 if ( iStatus.Int() != KErrNone ) |
|
367 { |
|
368 //LOGIT2("SERVER: Data volume event FAILED <%d>, id <%d>", iStatus.Int(), iConnectionId ) |
|
369 iErrorCounter++; |
|
370 if ( iErrorCounter > KConnMonEventErrorThreshold ) |
|
371 { |
|
372 LOGIT1("Over %d consecutive errors, stopping", KConnMonEventErrorThreshold) |
|
373 return; |
|
374 } |
|
375 } |
|
376 else |
|
377 { |
|
378 iErrorCounter = 0; |
|
379 iEventInfo.Reset(); |
|
380 |
|
381 // Send event(s) to clients |
|
382 iEventInfo.iConnectionId = iConnectionId; |
|
383 iEventInfo.iSubConnectionId = iSubConnectionId; |
|
384 iEventInfo.iData = iPckgVolume(); |
|
385 |
|
386 if ( iDirection == EDownlink ) |
|
387 { |
|
388 iEventInfo.iEventType = EConnMonDownlinkDataThreshold; |
|
389 LOGIT2("SERVER: EVENT -> Downlink data <%d>, id <%d>", iEventInfo.iData, iEventInfo.iConnectionId ) |
|
390 } |
|
391 else |
|
392 { |
|
393 iEventInfo.iEventType = EConnMonUplinkDataThreshold; |
|
394 LOGIT2("SERVER: EVENT -> Uplink data <%d>, id <%d>", iEventInfo.iData, iEventInfo.iConnectionId ) |
|
395 } |
|
396 |
|
397 iServer->EventQueue()->Add( iEventInfo ); |
|
398 } |
|
399 // New request |
|
400 Receive(); |
|
401 //LOGEXITFN("CDataNotifier::RunL()") |
|
402 } |
|
403 |
|
404 // ============================ MEMBER FUNCTIONS =============================== |
|
405 |
|
406 // ----------------------------------------------------------------------------- |
|
407 // CProgressNotifier::CProgressNotifier |
|
408 // Priority is set to 10. Progress notifier must have higher priority than |
|
409 // connection up/down notifier because otherwise connection delete event will |
|
410 // arrive before status reaches KLinkLayerClosed. |
|
411 // ----------------------------------------------------------------------------- |
|
412 // |
|
413 CProgressNotifier::CProgressNotifier( |
|
414 CConnMonServer* aServer, |
|
415 RConnection* aConnection, |
|
416 const TUint& aConnectionId, |
|
417 const TUint& aSubConnectionId ) |
|
418 : |
|
419 CActive( EConnMonPriorityHigh ), |
|
420 iServer( aServer ), |
|
421 iConnection( aConnection ), |
|
422 iConnectionId( aConnectionId), |
|
423 iSubConnectionId( aSubConnectionId ), |
|
424 iFilter( KNoFiltering ) |
|
425 { |
|
426 } |
|
427 |
|
428 // ----------------------------------------------------------------------------- |
|
429 // CProgressNotifier::Construct |
|
430 // ----------------------------------------------------------------------------- |
|
431 // |
|
432 void CProgressNotifier::Construct() |
|
433 { |
|
434 //LOGENTRFN("CProgressNotifier::Construct()") |
|
435 CActiveScheduler::Add( this ); |
|
436 LOGIT("Created CProgressNotifier") |
|
437 //LOGEXITFN("CProgressNotifier::Construct()") |
|
438 } |
|
439 |
|
440 // Destructor |
|
441 CProgressNotifier::~CProgressNotifier() |
|
442 { |
|
443 if ( IsActive() ) |
|
444 { |
|
445 Cancel(); |
|
446 } |
|
447 |
|
448 iServer = NULL; |
|
449 iConnection = NULL; |
|
450 } |
|
451 |
|
452 // ----------------------------------------------------------------------------- |
|
453 // CProgressNotifier::Receive |
|
454 // Requests a new event (connection status changed) from RConnection |
|
455 // ----------------------------------------------------------------------------- |
|
456 // |
|
457 void CProgressNotifier::Receive() |
|
458 { |
|
459 if ( IsActive() ) |
|
460 { |
|
461 Cancel(); |
|
462 } |
|
463 |
|
464 iInfoBuf().iStage = 0; |
|
465 iInfoBuf().iError = 0; |
|
466 |
|
467 iConnection->ProgressNotification( iInfoBuf, iStatus ); |
|
468 SetActive(); |
|
469 } |
|
470 |
|
471 // ----------------------------------------------------------------------------- |
|
472 // CProgressNotifier::Receive |
|
473 // Requests a new event (connection status changed) from RConnection |
|
474 // Uses filtering until status reaches aFilter |
|
475 // ----------------------------------------------------------------------------- |
|
476 // |
|
477 void CProgressNotifier::Receive( const TInt aFilter ) |
|
478 { |
|
479 iFilter = aFilter; |
|
480 Receive(); |
|
481 } |
|
482 |
|
483 // ----------------------------------------------------------------------------- |
|
484 // CProgressNotifier::IsAuthDelete |
|
485 // ETrue if the user has deactivated the connection |
|
486 // by using Connection Monitor or if the applications issued |
|
487 // RConnection::Stop( RConnection::EStopAuthoritative ) |
|
488 // ----------------------------------------------------------------------------- |
|
489 // |
|
490 TBool CProgressNotifier::IsAuthDelete() |
|
491 { |
|
492 if ( iInfoBuf().iError == KErrConnectionTerminated ) |
|
493 { |
|
494 return ETrue; |
|
495 } |
|
496 else |
|
497 { |
|
498 return EFalse; |
|
499 } |
|
500 } |
|
501 |
|
502 // ----------------------------------------------------------------------------- |
|
503 // CProgressNotifier::CanReconnect |
|
504 // ETrue if might reconnect after closing. |
|
505 // ----------------------------------------------------------------------------- |
|
506 // |
|
507 TBool CProgressNotifier::CanReconnect() const |
|
508 { |
|
509 // Reconnect is disabled for the moment |
|
510 return EFalse; |
|
511 } |
|
512 |
|
513 // ----------------------------------------------------------------------------- |
|
514 // CProgressNotifier::DoCancel |
|
515 // Cancels the request from RConnection. |
|
516 // ----------------------------------------------------------------------------- |
|
517 // |
|
518 void CProgressNotifier::DoCancel() |
|
519 { |
|
520 if ( IsActive() ) |
|
521 { |
|
522 iConnection->CancelProgressNotification(); |
|
523 } |
|
524 } |
|
525 |
|
526 // ----------------------------------------------------------------------------- |
|
527 // CProgressNotifier::SendClosedEvent |
|
528 // ----------------------------------------------------------------------------- |
|
529 // |
|
530 void CProgressNotifier::SendClosedEvent() |
|
531 { |
|
532 iEventInfo.Reset(); |
|
533 |
|
534 iEventInfo.iEventType = EConnMonConnectionStatusChange; |
|
535 iEventInfo.iConnectionId = iConnectionId; |
|
536 iEventInfo.iSubConnectionId = iSubConnectionId; |
|
537 iEventInfo.iData = KLinkLayerClosed; |
|
538 |
|
539 // Send event to all clients that are listening |
|
540 iServer->EventQueue()->Add( iEventInfo ); |
|
541 } |
|
542 |
|
543 // ----------------------------------------------------------------------------- |
|
544 // CProgressNotifier::RunL |
|
545 // Handles the event that has arrived from RConnection |
|
546 // ----------------------------------------------------------------------------- |
|
547 // |
|
548 void CProgressNotifier::RunL() |
|
549 { |
|
550 //LOGENTRFN("CProgressNotifier::RunL()") |
|
551 |
|
552 // All RunL():s outside CServer-derived main class MUST NOT LEAVE. |
|
553 // Use TRAPD when needed. |
|
554 |
|
555 LOGIT(".") |
|
556 LOGIT1("RunL: CProgressNotifier, status %d", iStatus.Int()) |
|
557 |
|
558 if ( iStatus.Int() != KErrNone ) |
|
559 { |
|
560 LOGIT2("SERVER: connection status event FAILED <%d>, id %d", iStatus.Int(), iConnectionId) |
|
561 } |
|
562 else |
|
563 { |
|
564 iEventInfo.Reset(); |
|
565 |
|
566 if ( iInfoBuf().iStage != static_cast< TInt >( iEventInfo.iData ) ) |
|
567 { |
|
568 // Send only new stage info to clients |
|
569 iEventInfo.iEventType = EConnMonConnectionStatusChange; |
|
570 iEventInfo.iConnectionId = iConnectionId; |
|
571 iEventInfo.iSubConnectionId = iSubConnectionId; |
|
572 iEventInfo.iData = iInfoBuf().iStage; |
|
573 |
|
574 LOGIT3("SERVER: EVENT -> Connection %d, status %d <%d>", |
|
575 iEventInfo.iConnectionId, iEventInfo.iData, iInfoBuf().iError) |
|
576 |
|
577 if ( ( iFilter == KNoFiltering ) || ( iInfoBuf().iStage > iFilter ) ) |
|
578 { |
|
579 // Send event to all clients that are listening |
|
580 iServer->EventQueue()->Add( iEventInfo ); |
|
581 |
|
582 // Start other event watchers when the connection status reaches |
|
583 // KLinkLayerOpen for the first time. |
|
584 if ( iInfoBuf().iStage == KLinkLayerOpen ) |
|
585 { |
|
586 // Start subconnection up/down notifier when stage reaches KLinkLayerOpen |
|
587 CSubConnUpDownNotifier* subConnUpDownNotifier = 0; |
|
588 |
|
589 TInt err = iServer->Iap()->GetSubConnUpDownNotifier( |
|
590 iConnectionId, |
|
591 &subConnUpDownNotifier ); |
|
592 |
|
593 if ( KErrNone == err ) |
|
594 { |
|
595 if ( !subConnUpDownNotifier->IsActive() ) |
|
596 { |
|
597 subConnUpDownNotifier->Receive(); |
|
598 } |
|
599 } |
|
600 |
|
601 // Start activity notifier when stage reaches KLinkLayerOpen |
|
602 TRAPD( ret, ( iServer->Iap()->LaunchActivityNotifierL( iConnectionId ) ) ); |
|
603 |
|
604 if ( ret != KErrNone ) |
|
605 { |
|
606 LOGIT1("SERVER: FAILED to start activity notifier <%d>", ret) |
|
607 return; // Can't leave |
|
608 } |
|
609 |
|
610 // Start data (uplink & downlink) notifiers when stage reaches KLinkLayerOpen |
|
611 iServer->Iap()->LaunchDataNotifiers( iConnectionId ); |
|
612 |
|
613 ret = iServer->Iap()->LaunchBearerNotifier( iConnectionId ); |
|
614 if ( ret != KErrNone ) |
|
615 { |
|
616 LOGIT1("SERVER: FAILED to start bearer(new) notifier <%d>", ret) |
|
617 } |
|
618 } |
|
619 |
|
620 iFilter = KNoFiltering; |
|
621 } |
|
622 else |
|
623 { |
|
624 LOGIT("SERVER: This is old info. Packet was filtered out.") |
|
625 } |
|
626 } |
|
627 |
|
628 if ( iInfoBuf().iError == KErrNone ) |
|
629 { |
|
630 // New request |
|
631 Receive(); |
|
632 } |
|
633 else |
|
634 { |
|
635 // Connection is closing. |
|
636 CSubConnUpDownNotifier* subConnUpDownNotifier = 0; |
|
637 TInt err = iServer->Iap()->GetSubConnUpDownNotifier( |
|
638 iConnectionId, |
|
639 &subConnUpDownNotifier ); |
|
640 |
|
641 if ( KErrNone == err ) |
|
642 { |
|
643 // Subconn down notifier has stopped and allinterface closed event has arrived |
|
644 if ( !subConnUpDownNotifier->IsActive() ) |
|
645 { |
|
646 subConnUpDownNotifier->SendDeletedEvent(); |
|
647 } |
|
648 } |
|
649 |
|
650 if ( iInfoBuf().iError == KErrDisconnected ) |
|
651 { |
|
652 // Enable WLAN scan when IAP availability is check for the |
|
653 // next time because current bearer has been lost (-36). |
|
654 // MPM needs a fresh list of available iaps. |
|
655 iServer->Iap()->EnableWlanScan(); |
|
656 } |
|
657 } |
|
658 } |
|
659 //LOGEXITFN("CProgressNotifier::RunL()") |
|
660 } |
|
661 |
|
662 // ============================ MEMBER FUNCTIONS =============================== |
|
663 |
|
664 // ----------------------------------------------------------------------------- |
|
665 // CNetwStatusNotifier::CNetwStatusNotifier |
|
666 // ----------------------------------------------------------------------------- |
|
667 // |
|
668 CNetwStatusNotifier::CNetwStatusNotifier( |
|
669 CConnMonServer* aServer ) |
|
670 : |
|
671 CActive( EConnMonPriorityNormal ), |
|
672 iServer( aServer ) |
|
673 { |
|
674 } |
|
675 |
|
676 // ----------------------------------------------------------------------------- |
|
677 // CNetwStatusNotifier::Construct |
|
678 // ----------------------------------------------------------------------------- |
|
679 // |
|
680 void CNetwStatusNotifier::Construct() |
|
681 { |
|
682 //LOGENTRFN("CNetwStatusNotifier::Construct()") |
|
683 |
|
684 CActiveScheduler::Add( this ); |
|
685 TInt ret = iServer->Iap()->PacketService()->GetStatus( iPacketStatus ); |
|
686 if ( ret != KErrNone ) |
|
687 { |
|
688 iPacketStatus = RPacketService::EStatusUnattached; |
|
689 } |
|
690 LOGIT("Created CNetwStatusNotifier") |
|
691 |
|
692 //LOGEXITFN("CNetwStatusNotifier::Construct()") |
|
693 } |
|
694 |
|
695 // ----------------------------------------------------------------------------- |
|
696 // CNetwStatusNotifier::NewL |
|
697 // ----------------------------------------------------------------------------- |
|
698 // |
|
699 CNetwStatusNotifier* CNetwStatusNotifier::NewL( CConnMonServer* aServer ) |
|
700 { |
|
701 CNetwStatusNotifier* self = new( ELeave ) CNetwStatusNotifier( aServer ); |
|
702 self->Construct(); |
|
703 return self; |
|
704 } |
|
705 |
|
706 // Destructor |
|
707 CNetwStatusNotifier::~CNetwStatusNotifier() |
|
708 { |
|
709 Cancel(); |
|
710 iServer = NULL; |
|
711 } |
|
712 |
|
713 // ----------------------------------------------------------------------------- |
|
714 // CNetwStatusNotifier::Receive |
|
715 // Requests a new event (network status changed) from ETel |
|
716 // ----------------------------------------------------------------------------- |
|
717 // |
|
718 void CNetwStatusNotifier::Receive() |
|
719 { |
|
720 if ( IsActive() ) |
|
721 { |
|
722 return; |
|
723 } |
|
724 |
|
725 iServer->Iap()->PacketService()->NotifyStatusChange( iStatus, iPacketStatus ); |
|
726 SetActive(); |
|
727 } |
|
728 |
|
729 // ----------------------------------------------------------------------------- |
|
730 // CNetwStatusNotifier::DoCancel |
|
731 // Cancels the request from ETel. |
|
732 // ----------------------------------------------------------------------------- |
|
733 // |
|
734 void CNetwStatusNotifier::DoCancel() |
|
735 { |
|
736 if ( IsActive() ) |
|
737 { |
|
738 iServer->Iap()->PacketService()->CancelAsyncRequest( EPacketNotifyStatusChange ); |
|
739 } |
|
740 } |
|
741 |
|
742 // ----------------------------------------------------------------------------- |
|
743 // CNetwStatusNotifier::RunL |
|
744 // Handles the event that has arrived from ETel |
|
745 // ----------------------------------------------------------------------------- |
|
746 // |
|
747 void CNetwStatusNotifier::RunL() |
|
748 { |
|
749 //LOGENTRFN("CNetwStatusNotifier::RunL()") |
|
750 |
|
751 // All RunL():s outside CServer-derived main class MUST NOT LEAVE. |
|
752 // Use TRAPD when needed. |
|
753 |
|
754 LOGIT(".") |
|
755 LOGIT1("RunL: CNetwStatusNotifier, status %d", iStatus.Int()) |
|
756 |
|
757 if ( iStatus.Int() != KErrNone ) |
|
758 { |
|
759 LOGIT1("SERVER: network status event FAILED <%d>", iStatus.Int()) |
|
760 } |
|
761 else |
|
762 { |
|
763 iEventInfo.Reset(); |
|
764 |
|
765 iEventInfo.iEventType = EConnMonNetworkStatusChange; |
|
766 iEventInfo.iSubConnectionId = 0; |
|
767 iEventInfo.iData = iServer->Iap()->CalculateNetworkStatus( iPacketStatus ); |
|
768 |
|
769 // Find out bearer ID. |
|
770 iServer->Iap()->GetBearerId( iEventInfo.iConnectionId ); |
|
771 |
|
772 LOGIT2("SERVER: EVENT -> Network status %d, id %d", iEventInfo.iData, iEventInfo.iConnectionId) |
|
773 |
|
774 // Send event to all clients that are listening |
|
775 iServer->EventQueue()->Add( iEventInfo ); |
|
776 |
|
777 LOGIT("CNetwStatusNotifier::RunL triggered HandleAvailabilityChange()") |
|
778 iServer->AvailabilityManager()->HandleAvailabilityChange(); |
|
779 } |
|
780 |
|
781 // New request |
|
782 Receive(); |
|
783 //LOGEXITFN("CNetwStatusNotifier::RunL()") |
|
784 } |
|
785 |
|
786 // ============================ MEMBER FUNCTIONS =============================== |
|
787 |
|
788 // ----------------------------------------------------------------------------- |
|
789 // CNetwRegistrationNotifier::CNetwRegistrationNotifier |
|
790 // Notifies changes in network registration status. |
|
791 // Notifies also changes in CSD bearer availability and CSD IAP availability. |
|
792 // ----------------------------------------------------------------------------- |
|
793 // |
|
794 CNetwRegistrationNotifier::CNetwRegistrationNotifier( |
|
795 CConnMonServer* aServer, |
|
796 RMobilePhone& aMobilePhone ) |
|
797 : |
|
798 CActive( EConnMonPriorityNormal ), |
|
799 iServer( aServer ), |
|
800 iMobilePhone( aMobilePhone ) |
|
801 { |
|
802 } |
|
803 |
|
804 // ----------------------------------------------------------------------------- |
|
805 // CNetwRegistrationNotifier::Construct |
|
806 // ----------------------------------------------------------------------------- |
|
807 // |
|
808 void CNetwRegistrationNotifier::Construct() |
|
809 { |
|
810 //LOGENTRFN("CNetwRegistrationNotifier::Construct()") |
|
811 CActiveScheduler::Add( this ); |
|
812 |
|
813 iRegistration = RMobilePhone::ERegistrationUnknown; |
|
814 iEventInfo.iData = RMobilePhone::ERegistrationUnknown; |
|
815 |
|
816 TBool cellSupportsCSD( EFalse ); |
|
817 |
|
818 // Is CSD supported both by the cell and the phone |
|
819 iServer->Iap()->GetBearerSupportInfo( |
|
820 EBearerIdCSD, |
|
821 cellSupportsCSD, |
|
822 iPhoneSupportsCSD ); |
|
823 |
|
824 if ( cellSupportsCSD && iPhoneSupportsCSD ) |
|
825 { |
|
826 iCSDSupported = ETrue; |
|
827 } |
|
828 LOGIT("Created CNetwRegistrationNotifier") |
|
829 |
|
830 //LOGEXITFN("CNetwRegistrationNotifier::Construct()") |
|
831 } |
|
832 |
|
833 // ----------------------------------------------------------------------------- |
|
834 // CNetwRegistrationNotifier::NewL |
|
835 // ----------------------------------------------------------------------------- |
|
836 // |
|
837 CNetwRegistrationNotifier* CNetwRegistrationNotifier::NewL( |
|
838 CConnMonServer* aServer, |
|
839 RMobilePhone& aMobilePhone ) |
|
840 { |
|
841 CNetwRegistrationNotifier* self = new( ELeave ) CNetwRegistrationNotifier( |
|
842 aServer, |
|
843 aMobilePhone ); |
|
844 |
|
845 self->Construct(); |
|
846 return self; |
|
847 } |
|
848 |
|
849 // Destructor |
|
850 CNetwRegistrationNotifier::~CNetwRegistrationNotifier() |
|
851 { |
|
852 Cancel(); |
|
853 iServer = NULL; |
|
854 } |
|
855 |
|
856 // ----------------------------------------------------------------------------- |
|
857 // CNetwRegistrationNotifier::Receive |
|
858 // Requests a new event (network registration changed) from ETel |
|
859 // ----------------------------------------------------------------------------- |
|
860 // |
|
861 void CNetwRegistrationNotifier::Receive() |
|
862 { |
|
863 if ( IsActive() ) |
|
864 { |
|
865 return; |
|
866 } |
|
867 |
|
868 iMobilePhone.NotifyNetworkRegistrationStatusChange( iStatus, iRegistration ); |
|
869 SetActive(); |
|
870 } |
|
871 |
|
872 // ----------------------------------------------------------------------------- |
|
873 // CNetwRegistrationNotifier::DoCancel |
|
874 // Cancels the request from ETel. |
|
875 // ----------------------------------------------------------------------------- |
|
876 // |
|
877 void CNetwRegistrationNotifier::DoCancel() |
|
878 { |
|
879 if ( IsActive() ) |
|
880 { |
|
881 iMobilePhone.CancelAsyncRequest( EMobilePhoneNotifyNetworkRegistrationStatusChange ); |
|
882 } |
|
883 } |
|
884 |
|
885 // ----------------------------------------------------------------------------- |
|
886 // CNetwRegistrationNotifier::RunL |
|
887 // Handles the event that has arrived from ETel |
|
888 // ----------------------------------------------------------------------------- |
|
889 // |
|
890 void CNetwRegistrationNotifier::RunL() |
|
891 { |
|
892 //LOGENTRFN("CNetwRegistrationNotifier::RunL()") |
|
893 |
|
894 // All RunL():s outside CServer-derived main class MUST NOT LEAVE. |
|
895 // Use TRAPD when needed. |
|
896 |
|
897 LOGIT(".") |
|
898 LOGIT1("RunL: CNetwRegistrationNotifier, status <%d>", iStatus.Int()) |
|
899 |
|
900 if ( iStatus.Int() != KErrNone ) |
|
901 { |
|
902 LOGIT1("SERVER: network registration event FAILED <%d>", iStatus.Int()) |
|
903 } |
|
904 else |
|
905 { |
|
906 TUint value( RMobilePhone::ERegistrationUnknown ); |
|
907 |
|
908 value = iServer->Iap()->CalculateNetworkRegistration( iRegistration ); |
|
909 |
|
910 // Is this a new registration status value |
|
911 if ( iEventInfo.iData != value ) |
|
912 { |
|
913 // Send Network registration status changed event when FeatureFlag is ON |
|
914 if ( FeatureManager::FeatureSupported( KFeatureIdNetworkRegistration ) ) |
|
915 { |
|
916 iEventInfo.Reset(); |
|
917 |
|
918 iEventInfo.iData = value; |
|
919 iEventInfo.iEventType = EConnMonNetworkRegistrationChange; |
|
920 |
|
921 // Find out bearer ID. |
|
922 iServer->Iap()->GetBearerId( iEventInfo.iConnectionId ); |
|
923 |
|
924 if ( iEventInfo.iConnectionId == EBearerIdGPRS ) |
|
925 { |
|
926 iEventInfo.iConnectionId = EBearerIdGSM; |
|
927 } |
|
928 |
|
929 iServer->EventQueue()->Add( iEventInfo ); |
|
930 } |
|
931 |
|
932 LOGIT2("SERVER: EVENT -> Network registration %d, id %d", iEventInfo.iData, iEventInfo.iConnectionId) |
|
933 |
|
934 if ( iPhoneSupportsCSD ) |
|
935 { |
|
936 iEventInfo.Reset(); |
|
937 iEventInfo.iEventType = EConnMonBearerAvailabilityChange; |
|
938 |
|
939 if ( iRegistration == RMobilePhone::ERegisteredBusy || |
|
940 iRegistration == RMobilePhone::ERegisteredOnHomeNetwork || |
|
941 iRegistration == RMobilePhone::ERegisteredRoaming ) |
|
942 { |
|
943 iEventInfo.iData = ETrue; |
|
944 } |
|
945 |
|
946 if ( static_cast< TUint >( iCSDSupported ) != iEventInfo.iData ) |
|
947 { |
|
948 // Find out bearer ID for CSD. |
|
949 iServer->Iap()->GetBearerId( iEventInfo.iConnectionId, ETrue ); |
|
950 |
|
951 // Send the event only if threshold is set by some of the clients. |
|
952 TUint threshold( 0 ); |
|
953 |
|
954 iServer->CalculateThreshold( |
|
955 EBearerIdAll, |
|
956 EBearerAvailabilityThreshold, |
|
957 threshold ); |
|
958 |
|
959 if ( threshold > 0 ) |
|
960 { |
|
961 iServer->EventQueue()->Add( iEventInfo ); |
|
962 } |
|
963 |
|
964 iCSDSupported = iEventInfo.iData; |
|
965 |
|
966 LOGIT2("SERVER: EVENT -> Bearer availability changed: data %d, id %d", iEventInfo.iData, iEventInfo.iConnectionId) |
|
967 |
|
968 // Send CSD IAP availability event only when packet services are not available. |
|
969 // Otherwise CSD IAP availability information goes along with packet IAP event. |
|
970 TUint32 capsPhone( 0 ); |
|
971 TInt err = iMobilePhone.GetMultimodeCaps( capsPhone ); |
|
972 } |
|
973 } |
|
974 |
|
975 // Store to compare next event correctly |
|
976 iEventInfo.iData = value; |
|
977 } |
|
978 LOGIT("CNetwRegistrationNotifier::RunL triggered HandleAvailabilityChange()") |
|
979 iServer->AvailabilityManager()->HandleAvailabilityChange(); |
|
980 } |
|
981 // New request |
|
982 Receive(); |
|
983 //LOGEXITFN("CNetwRegistrationNotifier::RunL()") |
|
984 } |
|
985 |
|
986 // ============================ MEMBER FUNCTIONS =============================== |
|
987 |
|
988 // ----------------------------------------------------------------------------- |
|
989 // CBearerNotifier::CBearerNotifier |
|
990 // Notifies when the bearer changes from EGPRS to GPRS on vice versa. |
|
991 // This information is cell specific. |
|
992 // ----------------------------------------------------------------------------- |
|
993 // |
|
994 CBearerNotifier::CBearerNotifier( |
|
995 CConnMonServer* aServer, |
|
996 RMobilePhone& aMobilePhone ) |
|
997 : |
|
998 CActive( EConnMonPriorityNormal ), |
|
999 iServer( aServer ), |
|
1000 iMobilePhone( aMobilePhone ), |
|
1001 iGprsInfo(), |
|
1002 iGprsInfoPckg( iGprsInfo ), |
|
1003 iErrorCounter( 0 ) |
|
1004 { |
|
1005 } |
|
1006 |
|
1007 // ----------------------------------------------------------------------------- |
|
1008 // CBearerNotifier::ConstructL |
|
1009 // ----------------------------------------------------------------------------- |
|
1010 // |
|
1011 void CBearerNotifier::ConstructL() |
|
1012 { |
|
1013 //LOGENTRFN("CBearerNotifier::ConstructL()") |
|
1014 CActiveScheduler::Add( this ); |
|
1015 |
|
1016 // Open ETel custom API |
|
1017 TInt ret = iCustomApi.Open( iMobilePhone ); |
|
1018 if ( ret != KErrNone ) |
|
1019 { |
|
1020 LOGIT1("ERROR starting bearer notifier. RMmCustomAPI.Open() failed <%d>", ret) |
|
1021 User::Leave( ret ); |
|
1022 } |
|
1023 |
|
1024 iEventInfo.iData = EBearerUnknown; |
|
1025 LOGIT("Created CBearerNotifier") |
|
1026 |
|
1027 //LOGEXITFN("CBearerNotifier::ConstructL()") |
|
1028 } |
|
1029 |
|
1030 // ----------------------------------------------------------------------------- |
|
1031 // CBearerNotifier::NewL |
|
1032 // ----------------------------------------------------------------------------- |
|
1033 // |
|
1034 CBearerNotifier* CBearerNotifier::NewL( |
|
1035 CConnMonServer* aServer, |
|
1036 RMobilePhone& aMobilePhone ) |
|
1037 { |
|
1038 CBearerNotifier* self = new( ELeave ) CBearerNotifier( |
|
1039 aServer, |
|
1040 aMobilePhone ); |
|
1041 |
|
1042 CleanupStack::PushL( self ); |
|
1043 self->ConstructL(); |
|
1044 CleanupStack::Pop( self ); |
|
1045 |
|
1046 return self; |
|
1047 } |
|
1048 |
|
1049 // Destructor |
|
1050 CBearerNotifier::~CBearerNotifier() |
|
1051 { |
|
1052 Cancel(); |
|
1053 |
|
1054 // Close ETel custom API |
|
1055 iCustomApi.Close(); |
|
1056 |
|
1057 iServer = NULL; |
|
1058 } |
|
1059 |
|
1060 // ----------------------------------------------------------------------------- |
|
1061 // CBearerNotifier::Receive |
|
1062 // Requests a new event (bearer changed) from ETel Custom API |
|
1063 // ----------------------------------------------------------------------------- |
|
1064 // |
|
1065 void CBearerNotifier::Receive() |
|
1066 { |
|
1067 if ( IsActive() ) |
|
1068 { |
|
1069 return; |
|
1070 } |
|
1071 |
|
1072 iCustomApi.NotifyEGprsInfoChange( iStatus, iGprsInfoPckg ); |
|
1073 |
|
1074 SetActive(); |
|
1075 } |
|
1076 |
|
1077 // ----------------------------------------------------------------------------- |
|
1078 // CBearerNotifier::DoCancel |
|
1079 // Cancels the request from ETel Custom API. |
|
1080 // ----------------------------------------------------------------------------- |
|
1081 // |
|
1082 void CBearerNotifier::DoCancel() |
|
1083 { |
|
1084 if ( IsActive() ) |
|
1085 { |
|
1086 iCustomApi.CancelAsyncRequest( ECustomNotifyEGprsInfoChange ); |
|
1087 } |
|
1088 } |
|
1089 |
|
1090 // ----------------------------------------------------------------------------- |
|
1091 // CBearerNotifier::RunL |
|
1092 // Handles the event that has arrived from ETel |
|
1093 // ----------------------------------------------------------------------------- |
|
1094 // |
|
1095 void CBearerNotifier::RunL() |
|
1096 { |
|
1097 //LOGENTRFN("CBearerNotifier::RunL()") |
|
1098 |
|
1099 // All RunL():s outside CServer-derived main class MUST NOT LEAVE. |
|
1100 // Use TRAPD when needed. |
|
1101 |
|
1102 LOGIT(".") |
|
1103 LOGIT1("RunL: CBearerNotifier, status <%d>", iStatus.Int()) |
|
1104 |
|
1105 if ( iStatus.Int() != KErrNone ) |
|
1106 { |
|
1107 iErrorCounter++; |
|
1108 if ( iErrorCounter > KConnMonEventErrorThreshold ) |
|
1109 { |
|
1110 LOGIT1("Over %d consecutive errors, stopping", KConnMonEventErrorThreshold) |
|
1111 //LOGEXITFN("CBearerNotifier::RunL()") |
|
1112 return; |
|
1113 } |
|
1114 } |
|
1115 else |
|
1116 { |
|
1117 iErrorCounter = 0; |
|
1118 LOGIT1("SERVER: CBearerNotifier: iGprsInfo <%d>", iGprsInfoPckg().iGprsInfo) |
|
1119 iEventInfo.Reset(); |
|
1120 |
|
1121 // Check that that we are in GSM mode. This event will be sent only in GSM mode. |
|
1122 RMobilePhone::TMobilePhoneNetworkMode mode( RMobilePhone::ENetworkModeUnknown ); |
|
1123 |
|
1124 TInt ret = iMobilePhone.GetCurrentMode( mode ); |
|
1125 |
|
1126 if ( ( ret == KErrNone ) && ( mode == RMobilePhone::ENetworkModeGsm ) ) |
|
1127 { |
|
1128 if ( iGprsInfoPckg().iGprsInfo == RMmCustomAPI::EEdgeGprs ) |
|
1129 { |
|
1130 iEventInfo.iData = EBearerEdgeGPRS; |
|
1131 } |
|
1132 else |
|
1133 { |
|
1134 iEventInfo.iData = EBearerGPRS; |
|
1135 } |
|
1136 |
|
1137 iEventInfo.iEventType = EConnMonBearerChange; |
|
1138 iEventInfo.iConnectionId = EBearerIdGPRS; |
|
1139 |
|
1140 iServer->EventQueue()->Add( iEventInfo ); |
|
1141 |
|
1142 LOGIT3("SERVER: EVENT -> Bearer changed: %d, data %d, id %d", iGprsInfoPckg().iGprsInfo, iEventInfo.iData, iEventInfo.iConnectionId) |
|
1143 |
|
1144 // New Impl. |
|
1145 iEventInfo.Reset(); |
|
1146 iEventInfo.iEventType = EConnMonBearerInfoChange; |
|
1147 iEventInfo.iConnectionId = EBearerIdAll; // means that this is not a connection related event |
|
1148 |
|
1149 if ( iGprsInfoPckg().iGprsInfo == RMmCustomAPI::EEdgeGprs ) |
|
1150 { |
|
1151 iEventInfo.iData = EBearerInfoEdgeGPRS; |
|
1152 } |
|
1153 else |
|
1154 { |
|
1155 iEventInfo.iData = EBearerInfoGPRS; |
|
1156 } |
|
1157 |
|
1158 iServer->EventQueue()->Add( iEventInfo ); |
|
1159 |
|
1160 LOGIT2("SERVER: EVENT -> Bearer info changed: %d, data %d", iGprsInfoPckg().iGprsInfo, iEventInfo.iData) |
|
1161 } |
|
1162 } |
|
1163 |
|
1164 // New request |
|
1165 Receive(); |
|
1166 //LOGEXITFN("CBearerNotifier::RunL()") |
|
1167 } |
|
1168 |
|
1169 // ----------------------------------------------------------------------------- |
|
1170 // CBearerNotifier::CWcdmaBearerNotifier |
|
1171 // Notifies when the bearer changes from Wcdma to Hsdpa on vice versa. |
|
1172 // This information is cell specific. |
|
1173 // ----------------------------------------------------------------------------- |
|
1174 // |
|
1175 CWcdmaBearerNotifier::CWcdmaBearerNotifier( |
|
1176 CConnMonServer* aServer, |
|
1177 RTelServer& aTelServer ) |
|
1178 : |
|
1179 CActive( EConnMonPriorityNormal ), |
|
1180 iServer( aServer ), |
|
1181 iTelServer( aTelServer ), |
|
1182 iNetInfo(), |
|
1183 iNetInfoPckg( iNetInfo ) |
|
1184 { |
|
1185 } |
|
1186 |
|
1187 // ----------------------------------------------------------------------------- |
|
1188 // CWcdmaBearerNotifier::ConstructL |
|
1189 // ----------------------------------------------------------------------------- |
|
1190 // |
|
1191 void CWcdmaBearerNotifier::ConstructL() |
|
1192 { |
|
1193 //LOGENTRFN("CWcdmaBearerNotifier::ConstructL()") |
|
1194 CActiveScheduler::Add( this ); |
|
1195 |
|
1196 iPreviousBearerInfo = EBearerInfoWCDMA; |
|
1197 iEventInfo.iData = EBearerUnknown; |
|
1198 |
|
1199 RTelServer::TPhoneInfo info; |
|
1200 User::LeaveIfError( iTelServer.GetPhoneInfo( 0, info ) ); |
|
1201 User::LeaveIfError( iMobilePhone.Open( iTelServer, info.iName ) ); |
|
1202 |
|
1203 LOGIT("Created CWcdmaBearerNotifier") |
|
1204 //LOGEXITFN("CWcdmaBearerNotifier::ConstructL()") |
|
1205 } |
|
1206 |
|
1207 // ----------------------------------------------------------------------------- |
|
1208 // CWcdmaBearerNotifier::NewL |
|
1209 // ----------------------------------------------------------------------------- |
|
1210 // |
|
1211 CWcdmaBearerNotifier* CWcdmaBearerNotifier::NewL( |
|
1212 CConnMonServer* aServer, |
|
1213 RTelServer& aTelServer ) |
|
1214 { |
|
1215 CWcdmaBearerNotifier* self = new( ELeave ) CWcdmaBearerNotifier( |
|
1216 aServer, |
|
1217 aTelServer ); |
|
1218 CleanupStack::PushL( self ); |
|
1219 self->ConstructL(); |
|
1220 CleanupStack::Pop( self ); |
|
1221 |
|
1222 return self; |
|
1223 } |
|
1224 |
|
1225 // Destructor |
|
1226 CWcdmaBearerNotifier::~CWcdmaBearerNotifier() |
|
1227 { |
|
1228 Cancel(); |
|
1229 iServer = NULL; |
|
1230 |
|
1231 iMobilePhone.Close(); |
|
1232 } |
|
1233 |
|
1234 // ----------------------------------------------------------------------------- |
|
1235 // CWcdmaBearerNotifier::Receive |
|
1236 // Requests a new event (bearer changed) from ETel Custom API |
|
1237 // ----------------------------------------------------------------------------- |
|
1238 // |
|
1239 void CWcdmaBearerNotifier::Receive() |
|
1240 { |
|
1241 if ( IsActive() ) |
|
1242 { |
|
1243 return; |
|
1244 } |
|
1245 |
|
1246 iMobilePhone.NotifyCurrentNetworkChange( iStatus, iNetInfoPckg ); |
|
1247 SetActive(); |
|
1248 } |
|
1249 |
|
1250 // ----------------------------------------------------------------------------- |
|
1251 // CWcdmaBearerNotifier::DoCancel |
|
1252 // Cancels the request from ETel Custom API. |
|
1253 // ----------------------------------------------------------------------------- |
|
1254 // |
|
1255 void CWcdmaBearerNotifier::DoCancel() |
|
1256 { |
|
1257 if ( IsActive() ) |
|
1258 { |
|
1259 iMobilePhone.CancelAsyncRequest( EMobilePhoneNotifyCurrentNetworkNoLocationChange ); |
|
1260 } |
|
1261 } |
|
1262 |
|
1263 // ----------------------------------------------------------------------------- |
|
1264 // CWcdmaBearerNotifier::RunL |
|
1265 // Handles the event that has arrived from ETel |
|
1266 // ----------------------------------------------------------------------------- |
|
1267 // |
|
1268 void CWcdmaBearerNotifier::RunL() |
|
1269 { |
|
1270 //LOGENTRFN("CWcdmaBearerNotifier::RunL()") |
|
1271 |
|
1272 // All RunL():s outside CServer-derived main class MUST NOT LEAVE. |
|
1273 // Use TRAPD when needed. |
|
1274 |
|
1275 LOGIT(".") |
|
1276 LOGIT1("RunL: CWcdmaBearerNotifier, status <%d>", iStatus.Int()) |
|
1277 |
|
1278 if ( KErrNone != iStatus.Int() ) |
|
1279 { |
|
1280 LOGIT1("SERVER: CWcdmaBearerNotifier:Bearer changed event FAILED <%d>", iStatus.Int()) |
|
1281 } |
|
1282 else |
|
1283 { |
|
1284 LOGIT2("SERVER: CWcdmaBearerNotifier: EGPRS %d, HSDPA %d", |
|
1285 iNetInfoPckg().iEgprsAvailableIndicator, iNetInfoPckg().iHsdpaAvailableIndicator) |
|
1286 iEventInfo.Reset(); |
|
1287 |
|
1288 // Check that that we are in Wcdma mode. This event will be |
|
1289 // sent only in Wcdma mode. |
|
1290 RMobilePhone::TMobilePhoneNetworkMode mode( RMobilePhone::ENetworkModeUnknown ); |
|
1291 |
|
1292 TInt ret = iMobilePhone.GetCurrentMode( mode ); |
|
1293 LOGIT1("SERVER: CWcdmaBearerNotifier: current mode %d", mode) |
|
1294 |
|
1295 if ( ( KErrNone == ret ) && ( mode == RMobilePhone::ENetworkModeWcdma ) ) |
|
1296 { |
|
1297 iEventInfo.iEventType = EConnMonBearerInfoChange; |
|
1298 iEventInfo.iConnectionId = EBearerIdAll; // Means that this is not a connection related event |
|
1299 |
|
1300 if ( iNetInfoPckg().iHsdpaAvailableIndicator ) |
|
1301 { |
|
1302 iEventInfo.iData = EBearerInfoHSDPA; |
|
1303 } |
|
1304 else |
|
1305 { |
|
1306 iEventInfo.iData = EBearerInfoWCDMA; |
|
1307 } |
|
1308 |
|
1309 if ( iPreviousBearerInfo != iEventInfo.iData ) |
|
1310 { |
|
1311 iPreviousBearerInfo = (TConnMonBearerInfo)iEventInfo.iData; |
|
1312 |
|
1313 LOGIT1("SERVER: EVENT -> Wcdma bearer info changed, new bearer info %d", iEventInfo.iData) |
|
1314 iServer->EventQueue()->Add( iEventInfo ); |
|
1315 } |
|
1316 else |
|
1317 { |
|
1318 LOGIT1("SERVER: Wcdma bearer info NOT changed, bearer info %d", iEventInfo.iData) |
|
1319 } |
|
1320 } |
|
1321 } |
|
1322 // New request |
|
1323 Receive(); |
|
1324 //LOGEXITFN("CWcdmaBearerNotifier::RunL()") |
|
1325 } |
|
1326 |
|
1327 // ============================ MEMBER FUNCTIONS =============================== |
|
1328 |
|
1329 // ----------------------------------------------------------------------------- |
|
1330 // CModeNotifier::CModeNotifier |
|
1331 // Notifies when the bearer changes from 3G (WCDMA) to 2G (GPRS/EGPRS) or vice versa. |
|
1332 // ----------------------------------------------------------------------------- |
|
1333 // |
|
1334 CModeNotifier::CModeNotifier( |
|
1335 CConnMonServer* aServer, |
|
1336 RMobilePhone& aMobilePhone ) |
|
1337 : |
|
1338 CActive( EConnMonPriorityNormal ), |
|
1339 iServer( aServer ), |
|
1340 iMobilePhone( aMobilePhone ) |
|
1341 { |
|
1342 } |
|
1343 |
|
1344 // ----------------------------------------------------------------------------- |
|
1345 // CModeNotifier::Construct |
|
1346 // ----------------------------------------------------------------------------- |
|
1347 // |
|
1348 void CModeNotifier::Construct() |
|
1349 { |
|
1350 //LOGENTRFN("CModeNotifier::Construct()") |
|
1351 CActiveScheduler::Add( this ); |
|
1352 LOGIT("Created CModeNotifier") |
|
1353 //LOGEXITFN("CModeNotifier::Construct()") |
|
1354 } |
|
1355 |
|
1356 // ----------------------------------------------------------------------------- |
|
1357 // CModeNotifier::NewL |
|
1358 // ----------------------------------------------------------------------------- |
|
1359 // |
|
1360 CModeNotifier* CModeNotifier::NewL( |
|
1361 CConnMonServer* aServer, |
|
1362 RMobilePhone& aMobilePhone ) |
|
1363 { |
|
1364 CModeNotifier* self = new( ELeave ) CModeNotifier( aServer, aMobilePhone ); |
|
1365 self->Construct(); |
|
1366 return self; |
|
1367 } |
|
1368 |
|
1369 // Destructor |
|
1370 CModeNotifier::~CModeNotifier() |
|
1371 { |
|
1372 Cancel(); |
|
1373 iServer = NULL; |
|
1374 } |
|
1375 |
|
1376 // ----------------------------------------------------------------------------- |
|
1377 // CModeNotifier::Receive |
|
1378 // Requests a new event (bearer changed) from ETel Custom API |
|
1379 // ----------------------------------------------------------------------------- |
|
1380 // |
|
1381 void CModeNotifier::Receive() |
|
1382 { |
|
1383 if ( IsActive() ) |
|
1384 { |
|
1385 return; |
|
1386 } |
|
1387 |
|
1388 iMobilePhone.NotifyModeChange( iStatus, iMode ); |
|
1389 |
|
1390 SetActive(); |
|
1391 } |
|
1392 |
|
1393 // ----------------------------------------------------------------------------- |
|
1394 // CModeNotifier::DoCancel |
|
1395 // Cancels the request from ETel Custom API. |
|
1396 // ----------------------------------------------------------------------------- |
|
1397 // |
|
1398 void CModeNotifier::DoCancel() |
|
1399 { |
|
1400 if ( IsActive() ) |
|
1401 { |
|
1402 iMobilePhone.CancelAsyncRequest( EMobilePhoneNotifyModeChange ); |
|
1403 } |
|
1404 } |
|
1405 |
|
1406 // ----------------------------------------------------------------------------- |
|
1407 // CModeNotifier::RunL |
|
1408 // Handles the event that has arrived from ETel |
|
1409 // ----------------------------------------------------------------------------- |
|
1410 // |
|
1411 void CModeNotifier::RunL() |
|
1412 { |
|
1413 //LOGENTRFN("CModeNotifier::RunL()") |
|
1414 TBool edgeCellDetected = EFalse; |
|
1415 |
|
1416 // All RunL():s outside CServer-derived main class MUST NOT LEAVE. |
|
1417 // Use TRAPD when needed. |
|
1418 |
|
1419 LOGIT(".") |
|
1420 LOGIT1("RunL: CModeNotifier, status %d", iStatus.Int()) |
|
1421 |
|
1422 if ( iStatus.Int() != KErrNone ) |
|
1423 { |
|
1424 LOGIT1("SERVER: Mode changed event FAILED <%d>", iStatus.Int() ) |
|
1425 } |
|
1426 else |
|
1427 { |
|
1428 LOGIT1("SERVER: CModeNotifier: mode <%d>", iMode ) |
|
1429 iEventInfo.Reset(); |
|
1430 |
|
1431 iEventInfo.iEventType = EConnMonBearerChange; |
|
1432 |
|
1433 if ( iMode == RMobilePhone::ENetworkModeWcdma ) |
|
1434 { |
|
1435 iEventInfo.iConnectionId = EBearerIdWCDMA; |
|
1436 iEventInfo.iData = EBearerWCDMA; |
|
1437 } |
|
1438 else if ( iMode == RMobilePhone::ENetworkModeGsm ) |
|
1439 { |
|
1440 iEventInfo.iConnectionId = EBearerIdGPRS; |
|
1441 |
|
1442 edgeCellDetected = iServer->Iap()->IsEdgeCell(); |
|
1443 if ( edgeCellDetected ) |
|
1444 { |
|
1445 iEventInfo.iData = EBearerEdgeGPRS; |
|
1446 } |
|
1447 else |
|
1448 { |
|
1449 iEventInfo.iData = EBearerGPRS; |
|
1450 } |
|
1451 } |
|
1452 else |
|
1453 { |
|
1454 // Unknown |
|
1455 iEventInfo.iData = 0; |
|
1456 } |
|
1457 |
|
1458 if ( iEventInfo.iData != 0 ) |
|
1459 { |
|
1460 iServer->EventQueue()->Add( iEventInfo ); |
|
1461 |
|
1462 LOGIT3("SERVER: EVENT -> Mode changed: %d, data %d, id %d", |
|
1463 iMode, iEventInfo.iData, iEventInfo.iConnectionId) |
|
1464 } |
|
1465 |
|
1466 // New implemantation |
|
1467 iEventInfo.Reset(); |
|
1468 |
|
1469 iEventInfo.iEventType = EConnMonBearerInfoChange; |
|
1470 iEventInfo.iConnectionId = EBearerIdAll; // means that this is not a connection related event |
|
1471 |
|
1472 if ( iMode == RMobilePhone::ENetworkModeWcdma ) |
|
1473 { |
|
1474 iEventInfo.iData = (TUint)iServer->Iap()->HsxpaStatus(); |
|
1475 } |
|
1476 else if ( iMode == RMobilePhone::ENetworkModeGsm ) |
|
1477 { |
|
1478 if ( edgeCellDetected ) |
|
1479 { |
|
1480 iEventInfo.iData = EBearerInfoEdgeGPRS; |
|
1481 } |
|
1482 else |
|
1483 { |
|
1484 iEventInfo.iData = EBearerInfoGPRS; |
|
1485 } |
|
1486 } |
|
1487 else |
|
1488 { |
|
1489 // Unknown |
|
1490 iEventInfo.iData = 0; |
|
1491 } |
|
1492 |
|
1493 if ( iEventInfo.iData != 0 ) |
|
1494 { |
|
1495 iServer->EventQueue()->Add( iEventInfo ); |
|
1496 LOGIT2("SERVER: EVENT -> Mode changed(new impl.): %d, bearerinfo %d", iMode, iEventInfo.iData) |
|
1497 } |
|
1498 |
|
1499 TConnMonBearerInfo bI = ( TConnMonBearerInfo ) iEventInfo.iData; |
|
1500 iServer->Iap()->SendConnectionEvents( bI ); // BearerInfoChanged, BearerGroupChanged |
|
1501 } |
|
1502 |
|
1503 // New request |
|
1504 Receive(); |
|
1505 //LOGEXITFN("CModeNotifier::RunL()") |
|
1506 } |
|
1507 |
|
1508 // ============================ MEMBER FUNCTIONS =============================== |
|
1509 |
|
1510 // ----------------------------------------------------------------------------- |
|
1511 // CBearerAvailabilityNotifier::CBearerAvailabilityNotifier |
|
1512 // Notifies when GPRS/WCDMA bearer availability changes. |
|
1513 // Notifies also changes in GPRS/WCDMA IAP availability. |
|
1514 // ----------------------------------------------------------------------------- |
|
1515 // |
|
1516 CBearerAvailabilityNotifier::CBearerAvailabilityNotifier( |
|
1517 CConnMonServer* aServer ) |
|
1518 : |
|
1519 CActive( EConnMonPriorityNormal ), |
|
1520 iServer( aServer ) |
|
1521 { |
|
1522 } |
|
1523 |
|
1524 // ----------------------------------------------------------------------------- |
|
1525 // CBearerAvailabilityNotifier::Construct |
|
1526 // ----------------------------------------------------------------------------- |
|
1527 // |
|
1528 void CBearerAvailabilityNotifier::Construct() |
|
1529 { |
|
1530 //LOGENTRFN("CBearerAvailabilityNotifier::Construct()") |
|
1531 CActiveScheduler::Add( this ); |
|
1532 iRegStatus = RPacketService::EUnknown; |
|
1533 LOGIT("Created CBearerAvailabilityNotifier") |
|
1534 //LOGEXITFN("CBearerAvailabilityNotifier::Construct()") |
|
1535 } |
|
1536 |
|
1537 // ----------------------------------------------------------------------------- |
|
1538 // CBearerAvailabilityNotifier::NewL |
|
1539 // ----------------------------------------------------------------------------- |
|
1540 // |
|
1541 CBearerAvailabilityNotifier* CBearerAvailabilityNotifier::NewL( CConnMonServer* aServer ) |
|
1542 { |
|
1543 CBearerAvailabilityNotifier* self = new( ELeave ) CBearerAvailabilityNotifier( aServer ); |
|
1544 self->Construct(); |
|
1545 return self; |
|
1546 } |
|
1547 |
|
1548 // Destructor |
|
1549 CBearerAvailabilityNotifier::~CBearerAvailabilityNotifier() |
|
1550 { |
|
1551 Cancel(); |
|
1552 iServer = NULL; |
|
1553 } |
|
1554 |
|
1555 // ----------------------------------------------------------------------------- |
|
1556 // CBearerAvailabilityNotifier::Receive |
|
1557 // Requests a new event (bearer (GPRS or WCDMA availability changed) from ETel |
|
1558 // ----------------------------------------------------------------------------- |
|
1559 // |
|
1560 void CBearerAvailabilityNotifier::Receive( TBool aKickOff ) |
|
1561 { |
|
1562 if ( IsActive() ) |
|
1563 { |
|
1564 return; |
|
1565 } |
|
1566 |
|
1567 if ( aKickOff ) |
|
1568 { |
|
1569 // Get current status of iPSD |
|
1570 TBool byCell( EFalse ); |
|
1571 |
|
1572 // Is GPRS or WCDMA supported |
|
1573 iServer->Iap()->GetBearerSupportInfo( |
|
1574 EBearerIdGPRS, |
|
1575 byCell, |
|
1576 iGPRSSupportedByPhone ); |
|
1577 |
|
1578 iServer->Iap()->GetBearerSupportInfo( |
|
1579 EBearerIdWCDMA, |
|
1580 byCell, |
|
1581 iWCDMASupportedByPhone ); |
|
1582 |
|
1583 if ( byCell && ( iGPRSSupportedByPhone || iWCDMASupportedByPhone ) ) |
|
1584 { |
|
1585 iPSD = ETrue; |
|
1586 } |
|
1587 } |
|
1588 |
|
1589 // Start receiving notifications if the phone supports some bearer |
|
1590 if ( iGPRSSupportedByPhone || iWCDMASupportedByPhone ) |
|
1591 { |
|
1592 iServer->Iap()->PacketService()->NotifyChangeOfNtwkRegStatus( |
|
1593 iStatus, |
|
1594 iRegStatus ); |
|
1595 SetActive(); |
|
1596 } |
|
1597 } |
|
1598 |
|
1599 // ----------------------------------------------------------------------------- |
|
1600 // CBearerAvailabilityNotifier::DoCancel |
|
1601 // Cancels the request from ETel. |
|
1602 // ----------------------------------------------------------------------------- |
|
1603 // |
|
1604 void CBearerAvailabilityNotifier::DoCancel() |
|
1605 { |
|
1606 if ( IsActive() ) |
|
1607 { |
|
1608 iServer->Iap()->PacketService()->CancelAsyncRequest( EPacketNotifyChangeOfNtwkRegStatus ); |
|
1609 } |
|
1610 } |
|
1611 |
|
1612 // ----------------------------------------------------------------------------- |
|
1613 // CBearerAvailabilityNotifier::RunL |
|
1614 // Handles the event that has arrived from ETel |
|
1615 // ----------------------------------------------------------------------------- |
|
1616 // |
|
1617 void CBearerAvailabilityNotifier::RunL() |
|
1618 { |
|
1619 //LOGENTRFN("CBearerAvailabilityNotifier::RunL()") |
|
1620 |
|
1621 // All RunL():s outside CServer-derived main class MUST NOT LEAVE. |
|
1622 // Use TRAPD when needed. |
|
1623 |
|
1624 LOGIT(".") |
|
1625 LOGIT1("RunL: CBearerAvailabilityNotifier, status %d", iStatus.Int()) |
|
1626 |
|
1627 if ( iStatus.Int() != KErrNone ) |
|
1628 { |
|
1629 LOGIT1("SERVER: Bearer availability event FAILED <%d>", iStatus.Int() ) |
|
1630 } |
|
1631 else |
|
1632 { |
|
1633 iEventInfo.Reset(); |
|
1634 |
|
1635 iEventInfo.iEventType = EConnMonBearerAvailabilityChange; |
|
1636 |
|
1637 if ( iGPRSSupportedByPhone || iWCDMASupportedByPhone ) |
|
1638 { |
|
1639 if ( iRegStatus != RPacketService::ENotRegisteredNotSearching && |
|
1640 iRegStatus != RPacketService::ENotRegisteredSearching && |
|
1641 iRegStatus != RPacketService::ERegistrationDenied && |
|
1642 iRegStatus != RPacketService::ENotRegisteredAndNotAvailable ) |
|
1643 { |
|
1644 // Check the capabilities of the cell |
|
1645 RPacketService::TDynamicCapsFlags capsDynamic; |
|
1646 TInt err = iServer->Iap()->PacketService()->GetDynamicCaps( capsDynamic ); |
|
1647 |
|
1648 if ( err != KErrNone ) |
|
1649 { |
|
1650 capsDynamic = 0; |
|
1651 } |
|
1652 |
|
1653 if ( ( capsDynamic & RPacketService::KCapsManualAttach ) || |
|
1654 ( capsDynamic & RPacketService::KCapsManualDetach ) ) |
|
1655 { |
|
1656 // Query the TSY for the attach mode |
|
1657 RPacketService::TAttachMode attachMode( RPacketService::EAttachWhenNeeded ); |
|
1658 err = iServer->Iap()->PacketService()->GetAttachMode( attachMode ); |
|
1659 |
|
1660 // Query packet network status (but only if the TSY is set to attach when possible) |
|
1661 if ( err == KErrNone && attachMode == RPacketService::EAttachWhenPossible ) |
|
1662 { |
|
1663 RPacketService::TStatus status( RPacketService::EStatusUnattached ); |
|
1664 err = iServer->Iap()->PacketService()->GetStatus( status ); |
|
1665 |
|
1666 if ( err == KErrNone && status != RPacketService::EStatusUnattached ) |
|
1667 { |
|
1668 iEventInfo.iData = ETrue; |
|
1669 } |
|
1670 } |
|
1671 else |
|
1672 { |
|
1673 // Attach mode is 'WhenNeeded' |
|
1674 iEventInfo.iData = ETrue; |
|
1675 } |
|
1676 } |
|
1677 } |
|
1678 |
|
1679 if ( static_cast< TUint >( iPSD ) != iEventInfo.iData ) |
|
1680 { |
|
1681 // Send BEARER availability changed -event. |
|
1682 // Find out the bearer ID (GPRS/WCDMA). |
|
1683 iServer->Iap()->GetBearerId( iEventInfo.iConnectionId ); |
|
1684 |
|
1685 // Send the event only if threshold is set by some of the clients. |
|
1686 TUint threshold( 0 ); |
|
1687 |
|
1688 iServer->CalculateThreshold( |
|
1689 EBearerIdAll, |
|
1690 EBearerAvailabilityThreshold, |
|
1691 threshold ); |
|
1692 |
|
1693 // Don't send the BEARER availability -event if nobody wants it (threshold = 0) |
|
1694 if ( threshold > 0 ) |
|
1695 { |
|
1696 iServer->EventQueue()->Add( iEventInfo ); |
|
1697 } |
|
1698 |
|
1699 LOGIT2("SERVER: EVENT -> Bearer availability changed: data %d, id %d", |
|
1700 iEventInfo.iData, iEventInfo.iConnectionId) |
|
1701 |
|
1702 iPSD = iEventInfo.iData; |
|
1703 } |
|
1704 } |
|
1705 |
|
1706 LOGIT("CBearerAvailabilityNotifier::RunL triggered HandleAvailabilityChange()") |
|
1707 iServer->AvailabilityManager()->HandleAvailabilityChange(); |
|
1708 |
|
1709 // This is due to off-line mode not triggering the event and user might |
|
1710 // think that the packet data is available still.. |
|
1711 iServer->Iap()->DtmStateChanged(); |
|
1712 } |
|
1713 // New request (with no initializations) |
|
1714 Receive( EFalse ); |
|
1715 //LOGEXITFN("CBearerAvailabilityNotifier::RunL()") |
|
1716 } |
|
1717 |
|
1718 // ============================ MEMBER FUNCTIONS =============================== |
|
1719 |
|
1720 // ----------------------------------------------------------------------------- |
|
1721 // CGsmSignalNotifier::CGsmSignalNotifier |
|
1722 // Notifies when GSM signal strength changes. |
|
1723 // ----------------------------------------------------------------------------- |
|
1724 // |
|
1725 CGsmSignalNotifier::CGsmSignalNotifier( |
|
1726 CConnMonServer* aServer, |
|
1727 RMobilePhone& aMobilePhone ) |
|
1728 : |
|
1729 CActive( EConnMonPriorityNormal ), |
|
1730 iServer( aServer ), |
|
1731 iMobilePhone( aMobilePhone ) |
|
1732 { |
|
1733 } |
|
1734 |
|
1735 // ----------------------------------------------------------------------------- |
|
1736 // CGsmSignalNotifier::Construct |
|
1737 // ----------------------------------------------------------------------------- |
|
1738 // |
|
1739 void CGsmSignalNotifier::Construct() |
|
1740 { |
|
1741 //LOGENTRFN("CGsmSignalNotifier::Construct()") |
|
1742 CActiveScheduler::Add( this ); |
|
1743 LOGIT("Created CGsmSignalNotifier") |
|
1744 //LOGEXITFN("CGsmSignalNotifier::Construct()") |
|
1745 } |
|
1746 |
|
1747 // ----------------------------------------------------------------------------- |
|
1748 // CGsmSignalNotifier::NewL |
|
1749 // ----------------------------------------------------------------------------- |
|
1750 // |
|
1751 CGsmSignalNotifier* CGsmSignalNotifier::NewL( |
|
1752 CConnMonServer* aServer, |
|
1753 RMobilePhone& aMobilePhone ) |
|
1754 { |
|
1755 CGsmSignalNotifier* self = new( ELeave ) CGsmSignalNotifier( aServer, aMobilePhone ); |
|
1756 self->Construct(); |
|
1757 return self; |
|
1758 } |
|
1759 |
|
1760 // Destructor |
|
1761 CGsmSignalNotifier::~CGsmSignalNotifier() |
|
1762 { |
|
1763 Cancel(); |
|
1764 |
|
1765 iServer = NULL; |
|
1766 } |
|
1767 |
|
1768 // ----------------------------------------------------------------------------- |
|
1769 // CGsmSignalNotifier::Receive |
|
1770 // Requests a new event (signal strength changed) from ETel |
|
1771 // ----------------------------------------------------------------------------- |
|
1772 // |
|
1773 void CGsmSignalNotifier::Receive() |
|
1774 { |
|
1775 if ( IsActive() ) |
|
1776 { |
|
1777 return; |
|
1778 } |
|
1779 |
|
1780 TUint threshold( 0 ); |
|
1781 |
|
1782 // Threshold is owned by the session (not connection) |
|
1783 iServer->CalculateThreshold( EBearerIdAll, ESignalStrengthThreshold, threshold ); |
|
1784 |
|
1785 if ( threshold > 0 ) |
|
1786 { |
|
1787 iMobilePhone.NotifySignalStrengthChange( iStatus, iSignalStrength, iBar ); |
|
1788 SetActive(); |
|
1789 } |
|
1790 } |
|
1791 |
|
1792 // ----------------------------------------------------------------------------- |
|
1793 // CGsmSignalNotifier::DoCancel |
|
1794 // Cancels the request from ETel. |
|
1795 // ----------------------------------------------------------------------------- |
|
1796 // |
|
1797 void CGsmSignalNotifier::DoCancel() |
|
1798 { |
|
1799 if ( IsActive() ) |
|
1800 { |
|
1801 iMobilePhone.CancelAsyncRequest( EMobilePhoneNotifySignalStrengthChange ); |
|
1802 } |
|
1803 } |
|
1804 |
|
1805 // ----------------------------------------------------------------------------- |
|
1806 // CGsmSignalNotifier::RunL |
|
1807 // Handles the event that has arrived from ETel |
|
1808 // ----------------------------------------------------------------------------- |
|
1809 // |
|
1810 void CGsmSignalNotifier::RunL() |
|
1811 { |
|
1812 LOGENTRFN("CGsmSignalNotifier::RunL()") |
|
1813 |
|
1814 // All RunL():s outside CServer-derived main class MUST NOT LEAVE. |
|
1815 // Use TRAPD when needed. |
|
1816 |
|
1817 if ( iStatus.Int() != KErrNone ) |
|
1818 { |
|
1819 LOGIT1("SERVER: GSM signal strength event FAILED <%d>", iStatus.Int() ) |
|
1820 } |
|
1821 else |
|
1822 { |
|
1823 // Is this a new registration status value |
|
1824 if ( iEventInfo.iData != static_cast< TUint >( iSignalStrength ) ) |
|
1825 { |
|
1826 iEventInfo.Reset(); |
|
1827 |
|
1828 iEventInfo.iData = iSignalStrength; |
|
1829 iEventInfo.iEventType = EConnMonSignalStrengthChange; |
|
1830 |
|
1831 // Find out bearer ID. |
|
1832 TInt err = iServer->Iap()->GetBearerId( iEventInfo.iConnectionId ); |
|
1833 |
|
1834 if ( err == KErrNone ) |
|
1835 { |
|
1836 iServer->EventQueue()->Add( iEventInfo ); |
|
1837 } |
|
1838 } |
|
1839 |
|
1840 LOGIT2("SERVER: EVENT -> Signal strength <%d>, id <%d>", iEventInfo.iData, iEventInfo.iConnectionId ) |
|
1841 |
|
1842 // New request |
|
1843 Receive(); |
|
1844 } |
|
1845 LOGEXITFN("CGsmSignalNotifier::RunL()") |
|
1846 } |
|
1847 |
|
1848 // ============================ MEMBER FUNCTIONS =============================== |
|
1849 |
|
1850 // ----------------------------------------------------------------------------- |
|
1851 // CActivityNotifier::CActivityNotifier |
|
1852 // ----------------------------------------------------------------------------- |
|
1853 // |
|
1854 CActivityNotifier::CActivityNotifier( |
|
1855 CConnMonServer* aServer, |
|
1856 RConnection* aConnection, |
|
1857 const TUint& aConnectionId, |
|
1858 const TUint& aSubConnectionId ) |
|
1859 : |
|
1860 CActive( EConnMonPriorityNormal ), |
|
1861 iServer( aServer ), |
|
1862 iConnection( aConnection ), |
|
1863 iConnectionId( aConnectionId), |
|
1864 iSubConnectionId( aSubConnectionId ), |
|
1865 iActivity( 0 ), |
|
1866 iPckgActivity( iActivity ) |
|
1867 { |
|
1868 } |
|
1869 |
|
1870 // ----------------------------------------------------------------------------- |
|
1871 // CActivityNotifier::Construct |
|
1872 // ----------------------------------------------------------------------------- |
|
1873 // |
|
1874 void CActivityNotifier::Construct() |
|
1875 { |
|
1876 //LOGENTRFN("CActivityNotifier::Construct()") |
|
1877 CActiveScheduler::Add( this ); |
|
1878 LOGIT("Created CActivityNotifier") |
|
1879 //LOGEXITFN("CActivityNotifier::Construct()") |
|
1880 } |
|
1881 |
|
1882 // Destructor |
|
1883 CActivityNotifier::~CActivityNotifier() |
|
1884 { |
|
1885 Cancel(); |
|
1886 |
|
1887 iServer = NULL; |
|
1888 iConnection = NULL; |
|
1889 } |
|
1890 |
|
1891 // ----------------------------------------------------------------------------- |
|
1892 // CActivityNotifier::Receive |
|
1893 // Requests a new event (activity changed) from RConnection |
|
1894 // ----------------------------------------------------------------------------- |
|
1895 // |
|
1896 void CActivityNotifier::Receive( TBool aActivity ) |
|
1897 { |
|
1898 if ( IsActive() ) |
|
1899 { |
|
1900 return; |
|
1901 } |
|
1902 |
|
1903 // Don't make a new request if previous |
|
1904 // status indicates that connection is closing |
|
1905 if ( iStatus == KErrDisconnected ) |
|
1906 { |
|
1907 return; |
|
1908 } |
|
1909 |
|
1910 iActivity = aActivity; |
|
1911 iServer->CalculateThreshold( iConnectionId, EActivityTimeThreshold, iThreshold ); |
|
1912 |
|
1913 if ( iThreshold > 0 ) |
|
1914 { |
|
1915 // Will complete when the connection activity has changed from given |
|
1916 // value (iActivity) for given period (threshold). |
|
1917 iConnection->IsConnectionActiveRequest( iThreshold, iPckgActivity, iStatus ); |
|
1918 SetActive(); |
|
1919 } |
|
1920 } |
|
1921 |
|
1922 // ----------------------------------------------------------------------------- |
|
1923 // CActivityNotifier::ReceiveOne |
|
1924 // Requests a new event (activity changed) from RConnection |
|
1925 // ----------------------------------------------------------------------------- |
|
1926 // |
|
1927 void CActivityNotifier::ReceiveOne( TBool aActivity ) |
|
1928 { |
|
1929 if ( IsActive() ) |
|
1930 { |
|
1931 Cancel(); |
|
1932 } |
|
1933 |
|
1934 iActivity = aActivity; |
|
1935 iThreshold = KOneTimeQueryThreshold; // 1 second |
|
1936 |
|
1937 // NOTE. Timer will expire once in a second. |
|
1938 // This should be used only with one shot querries ( -> cancel after a period |
|
1939 // if this has not completed otherwise ). |
|
1940 iConnection->IsConnectionActiveRequest( iThreshold, iPckgActivity, iStatus ); |
|
1941 SetActive(); |
|
1942 } |
|
1943 |
|
1944 // ----------------------------------------------------------------------------- |
|
1945 // CActivityNotifier::DoCancel |
|
1946 // Cancels the request from RConnection. |
|
1947 // ----------------------------------------------------------------------------- |
|
1948 // |
|
1949 void CActivityNotifier::DoCancel() |
|
1950 { |
|
1951 if ( IsActive() ) |
|
1952 { |
|
1953 // Complete any outstanding one time queries if the are any |
|
1954 iServer->SendActivityToSessions( iConnectionId, iPckgActivity(), 0 ); |
|
1955 |
|
1956 LOGIT2("Activity completed (DoCancel): %d, id %d", iPckgActivity(), iConnectionId) |
|
1957 |
|
1958 // Cancel the request from RConnection |
|
1959 iConnection->IsConnectionActiveCancel(); |
|
1960 } |
|
1961 } |
|
1962 |
|
1963 // ----------------------------------------------------------------------------- |
|
1964 // CActivityNotifier::RunL |
|
1965 // Handles the event that has arrived from RConnection |
|
1966 // ----------------------------------------------------------------------------- |
|
1967 // |
|
1968 void CActivityNotifier::RunL() |
|
1969 { |
|
1970 //LOGENTRFN("CActivityNotifier::RunL()") |
|
1971 |
|
1972 // All RunL():s outside CServer-derived main class MUST NOT LEAVE. |
|
1973 // Use TRAPD when needed. |
|
1974 |
|
1975 LOGIT(".") |
|
1976 LOGIT1("RunL: CActivityNotifier, status %d", iStatus.Int()) |
|
1977 |
|
1978 if ( iThreshold == KOneTimeQueryThreshold ) |
|
1979 { |
|
1980 // One time query has been issued |
|
1981 iServer->SendActivityToSessions( iConnectionId, iPckgActivity(), iStatus.Int() ); |
|
1982 |
|
1983 LOGIT2("Activity req completed: %d, id %d", iPckgActivity(), iConnectionId) |
|
1984 |
|
1985 // Update internal table |
|
1986 iActivity = iPckgActivity(); |
|
1987 iServer->Iap()->UpdateActivity( iConnectionId, iActivity ); |
|
1988 |
|
1989 // Somebody has started notifications while we were waiting |
|
1990 // one time call to return -> go on with notifications |
|
1991 if ( ( iServer->NumberOfListeners() > 0 ) && ( iStatus.Int() == KErrNone ) ) |
|
1992 { |
|
1993 // Send event to clients |
|
1994 iEventInfo.Reset(); |
|
1995 |
|
1996 iEventInfo.iConnectionId = iConnectionId; |
|
1997 iEventInfo.iSubConnectionId = iSubConnectionId; |
|
1998 iEventInfo.iEventType = EConnMonConnectionActivityChange; |
|
1999 iEventInfo.iData = iPckgActivity(); |
|
2000 |
|
2001 iServer->EventQueue()->Add( iEventInfo ); |
|
2002 |
|
2003 Receive( iActivity ); |
|
2004 } |
|
2005 } |
|
2006 else |
|
2007 { |
|
2008 // A real event has been requested |
|
2009 if ( iStatus.Int() != KErrNone ) |
|
2010 { |
|
2011 if ( iStatus.Int() == KErrCancel ) |
|
2012 { |
|
2013 iStatus = KErrDisconnected; |
|
2014 } |
|
2015 |
|
2016 LOGIT2("Activity event FAILED <%d>, id %d", iStatus.Int(), iConnectionId) |
|
2017 } |
|
2018 else |
|
2019 { |
|
2020 iEventInfo.Reset(); |
|
2021 |
|
2022 // Send event(s) to clients |
|
2023 iEventInfo.iConnectionId = iConnectionId; |
|
2024 iEventInfo.iSubConnectionId = iSubConnectionId; |
|
2025 iEventInfo.iEventType = EConnMonConnectionActivityChange; |
|
2026 iEventInfo.iData = iPckgActivity(); |
|
2027 |
|
2028 LOGIT2("SERVER: EVENT -> Activity change: %d, id %d", iEventInfo.iData, iEventInfo.iConnectionId) |
|
2029 |
|
2030 iServer->EventQueue()->Add( iEventInfo ); |
|
2031 |
|
2032 // Update internal table |
|
2033 iActivity = iPckgActivity(); |
|
2034 iServer->Iap()->UpdateActivity( iConnectionId, iActivity ); |
|
2035 |
|
2036 // New request |
|
2037 Receive( iActivity ); |
|
2038 } |
|
2039 } |
|
2040 //LOGEXITFN("CActivityNotifier::RunL()") |
|
2041 } |
|
2042 |
|
2043 // ============================ MEMBER FUNCTIONS =============================== |
|
2044 |
|
2045 // ----------------------------------------------------------------------------- |
|
2046 // CSubConnUpDownNotifier::CSubConnUpDownNotifier |
|
2047 // ----------------------------------------------------------------------------- |
|
2048 // |
|
2049 CSubConnUpDownNotifier::CSubConnUpDownNotifier( |
|
2050 CConnMonServer* aServer, |
|
2051 RConnection* aConnection, |
|
2052 const TUint& aConnectionId, |
|
2053 const TUint& aSubConnectionId ) |
|
2054 : |
|
2055 CActive( EConnMonPriorityMedium ), |
|
2056 iServer( aServer ), |
|
2057 iConnection( aConnection ), |
|
2058 iConnectionId( aConnectionId), |
|
2059 iSubConnectionId( aSubConnectionId ) |
|
2060 { |
|
2061 } |
|
2062 |
|
2063 // ----------------------------------------------------------------------------- |
|
2064 // CSubConnUpDownNotifier::Construct |
|
2065 // ----------------------------------------------------------------------------- |
|
2066 // |
|
2067 void CSubConnUpDownNotifier::Construct() |
|
2068 { |
|
2069 //LOGENTRFN("CSubConnUpDownNotifier::Construct()") |
|
2070 CActiveScheduler::Add( this ); |
|
2071 LOGIT("Created CSubConnUpDownNotifier") |
|
2072 //LOGEXITFN("CSubConnUpDownNotifier::Construct()") |
|
2073 } |
|
2074 |
|
2075 // Destructor |
|
2076 CSubConnUpDownNotifier::~CSubConnUpDownNotifier() |
|
2077 { |
|
2078 if ( IsActive() ) |
|
2079 { |
|
2080 Cancel(); |
|
2081 } |
|
2082 |
|
2083 iServer = NULL; |
|
2084 iConnection = NULL; |
|
2085 } |
|
2086 |
|
2087 // ----------------------------------------------------------------------------- |
|
2088 // CSubConnUpDownNotifier::Receive |
|
2089 // Requests a new event (subconnection up/down) from RConnection |
|
2090 // ----------------------------------------------------------------------------- |
|
2091 // |
|
2092 void CSubConnUpDownNotifier::Receive() |
|
2093 { |
|
2094 if ( IsActive() ) |
|
2095 { |
|
2096 Cancel(); |
|
2097 } |
|
2098 |
|
2099 if ( iStatus == KErrDisconnected ) |
|
2100 { |
|
2101 return; |
|
2102 } |
|
2103 |
|
2104 iConnection->AllSubConnectionNotification( iSubConnEventBuf, iStatus ); |
|
2105 SetActive(); |
|
2106 } |
|
2107 |
|
2108 // ----------------------------------------------------------------------------- |
|
2109 // CSubConnUpDownNotifier::SendDeletedEvent |
|
2110 // Sends connection deleted event to the clients |
|
2111 // ----------------------------------------------------------------------------- |
|
2112 // |
|
2113 void CSubConnUpDownNotifier::SendDeletedEvent() |
|
2114 { |
|
2115 if ( !iDeleteSent ) |
|
2116 { |
|
2117 iEventInfo.Reset(); |
|
2118 |
|
2119 iEventInfo.iEventType = EConnMonDeleteConnection; |
|
2120 iEventInfo.iConnectionId = iConnectionId; |
|
2121 iEventInfo.iSubConnectionId = iSubConnectionId; |
|
2122 iEventInfo.iData = iTotalDownlinkDataVolume; |
|
2123 iEventInfo.iData2 = iTotalUplinkDataVolume; |
|
2124 |
|
2125 // Find out type of the delete |
|
2126 CProgressNotifier* progressNotifier = 0; |
|
2127 TInt err = iServer->Iap()->GetProgressNotifier( iConnectionId, &progressNotifier ); |
|
2128 |
|
2129 if ( err == KErrNone ) |
|
2130 { |
|
2131 iEventInfo.iData3 = progressNotifier->IsAuthDelete(); |
|
2132 } |
|
2133 |
|
2134 // Send event to all clients that are listening |
|
2135 iServer->EventQueue()->Add( iEventInfo ); |
|
2136 |
|
2137 iDeleteSent = ETrue; |
|
2138 |
|
2139 if ( iInterfaceClosed ) |
|
2140 { |
|
2141 // Remove connection from the connection table if interface |
|
2142 // has closed. |
|
2143 TBearerInfo bearerInfo; |
|
2144 TConnInfo connInfo( 0, 0, iConnectionId, 0, bearerInfo ); |
|
2145 iServer->Iap()->RemoveConnection( connInfo ); |
|
2146 } |
|
2147 else |
|
2148 { |
|
2149 if ( progressNotifier->CanReconnect() ) |
|
2150 { |
|
2151 // Go on listening subinterface events |
|
2152 iConnection->AllSubConnectionNotification( iSubConnEventBuf, iStatus ); |
|
2153 SetActive(); |
|
2154 } |
|
2155 } |
|
2156 } |
|
2157 } |
|
2158 |
|
2159 // ----------------------------------------------------------------------------- |
|
2160 // CSubConnUpDownNotifier::DeleteSent |
|
2161 // ----------------------------------------------------------------------------- |
|
2162 // |
|
2163 TBool CSubConnUpDownNotifier::DeleteSent() const |
|
2164 { |
|
2165 return iDeleteSent; |
|
2166 } |
|
2167 |
|
2168 // ----------------------------------------------------------------------------- |
|
2169 // CSubConnUpDownNotifier::SetInterfaceClosed |
|
2170 // ----------------------------------------------------------------------------- |
|
2171 // |
|
2172 void CSubConnUpDownNotifier::SetInterfaceClosed() |
|
2173 { |
|
2174 iInterfaceClosed = ETrue; |
|
2175 } |
|
2176 |
|
2177 |
|
2178 // ----------------------------------------------------------------------------- |
|
2179 // CSubConnUpDownNotifier::DoCancel |
|
2180 // Cancels the request from RConnection. |
|
2181 // ----------------------------------------------------------------------------- |
|
2182 // |
|
2183 void CSubConnUpDownNotifier::DoCancel() |
|
2184 { |
|
2185 if ( IsActive() ) |
|
2186 { |
|
2187 iConnection->CancelAllSubConnectionNotification(); |
|
2188 } |
|
2189 } |
|
2190 |
|
2191 // ----------------------------------------------------------------------------- |
|
2192 // CSubConnUpDownNotifier::RunL |
|
2193 // Handles the event that has arrived from RConnection |
|
2194 // ----------------------------------------------------------------------------- |
|
2195 // |
|
2196 void CSubConnUpDownNotifier::RunL() |
|
2197 { |
|
2198 //LOGENTRFN("CSubConnUpDownNotifier::RunL()") |
|
2199 |
|
2200 // All RunL():s outside CServer-derived main class MUST NOT LEAVE. |
|
2201 // Use TRAPD when needed. |
|
2202 |
|
2203 LOGIT(".") |
|
2204 LOGIT1("RunL: CSubConnUpDownNotifier, status %d", iStatus.Int()) |
|
2205 |
|
2206 if ( iStatus.Int() != KErrNone ) |
|
2207 { |
|
2208 LOGIT2("SERVER: subconn up/down event for id %d FAILED <%d>", iConnectionId, iStatus.Int()) |
|
2209 |
|
2210 if ( iStatus.Int() == KErrNotReady ) |
|
2211 { |
|
2212 // Subinterface has disappered |
|
2213 CProgressNotifier* progressNotifier = 0; |
|
2214 TInt err = iServer->Iap()->GetProgressNotifier( iConnectionId, &progressNotifier ); |
|
2215 if ( err == KErrNone ) |
|
2216 { |
|
2217 // Is progress notifier still alive |
|
2218 if ( !progressNotifier->IsActive() ) |
|
2219 { |
|
2220 SendDeletedEvent(); |
|
2221 } |
|
2222 } |
|
2223 } |
|
2224 |
|
2225 iStatus = KErrDied; |
|
2226 } |
|
2227 else |
|
2228 { |
|
2229 TSubConnectionEvent& event = ( TSubConnectionEvent& )( *iSubConnEventBuf.Ptr() ); |
|
2230 |
|
2231 if ( event.iSubConnectionUniqueId == 0 && event.iEventType == ESubConnectionClosed ) |
|
2232 { |
|
2233 TSubConnectionClosedEvent& closedEvent = |
|
2234 (TSubConnectionClosedEvent&)( *iSubConnEventBuf.Ptr() ); |
|
2235 iTotalDownlinkDataVolume = closedEvent.iTotalDownlinkDataVolume; |
|
2236 iTotalUplinkDataVolume = closedEvent.iTotalUplinkDataVolume; |
|
2237 |
|
2238 LOGIT3("SERVER: EVENT -> Connection %d closed, u: %d, d: %d", |
|
2239 iConnectionId, iTotalUplinkDataVolume, iTotalDownlinkDataVolume) |
|
2240 |
|
2241 CProgressNotifier* progressNotifier = 0; |
|
2242 TInt err = iServer->Iap()->GetProgressNotifier( iConnectionId, &progressNotifier ); |
|
2243 if ( err == KErrNone ) |
|
2244 { |
|
2245 // Progess notifier has stopped and allinterface closed event has arrived |
|
2246 if ( !progressNotifier->IsActive() ) |
|
2247 { |
|
2248 SendDeletedEvent(); |
|
2249 } |
|
2250 } |
|
2251 else |
|
2252 { |
|
2253 SendDeletedEvent(); |
|
2254 } |
|
2255 |
|
2256 iStatus = KErrDisconnected; |
|
2257 } |
|
2258 else if ( ( event.iSubConnectionUniqueId == 0 ) && |
|
2259 ( event.iEventType == ESubConnectionOpened ) ) |
|
2260 { |
|
2261 // IS THIS A RECONNECT |
|
2262 if ( iDeleteSent && !iInterfaceClosed ) |
|
2263 { |
|
2264 TUint newId( iConnectionId ); |
|
2265 TInt err = iServer->Iap()->Reconnect( newId ); |
|
2266 |
|
2267 if ( err == KErrNone ) |
|
2268 { |
|
2269 iEventInfo.Reset(); |
|
2270 iEventInfo.iEventType = EConnMonCreateConnection; |
|
2271 iEventInfo.iConnectionId = newId; |
|
2272 |
|
2273 // Send event to all clients that are listening |
|
2274 iServer->EventQueue()->Add( iEventInfo ); |
|
2275 |
|
2276 LOGIT1("SERVER: EVENT -> new connection %d created (RECONNECTED)", newId) |
|
2277 delete this; |
|
2278 } |
|
2279 } |
|
2280 else |
|
2281 { |
|
2282 // New request |
|
2283 Receive(); |
|
2284 } |
|
2285 } |
|
2286 else |
|
2287 { |
|
2288 // New request |
|
2289 iConnection->AllSubConnectionNotification( iSubConnEventBuf, iStatus ); |
|
2290 SetActive(); |
|
2291 } |
|
2292 } |
|
2293 //LOGEXITFN("CSubConnUpDownNotifier::RunL()") |
|
2294 } |
|
2295 |
|
2296 // ============================ MEMBER FUNCTIONS =============================== |
|
2297 |
|
2298 // ----------------------------------------------------------------------------- |
|
2299 // CTimerAO::CTimerAO |
|
2300 // ----------------------------------------------------------------------------- |
|
2301 // |
|
2302 CTimerAO::CTimerAO( |
|
2303 CConnMonServer* aServer, |
|
2304 const TUint& aConnectionId, |
|
2305 const TUint8& aActivity ) |
|
2306 : |
|
2307 CActive( EConnMonPriorityNormal ), |
|
2308 iServer( aServer ), |
|
2309 iConnectionId( aConnectionId ), |
|
2310 iActivity( aActivity ) |
|
2311 { |
|
2312 } |
|
2313 |
|
2314 // ----------------------------------------------------------------------------- |
|
2315 // CTimerAO::ConstructL |
|
2316 // ----------------------------------------------------------------------------- |
|
2317 // |
|
2318 void CTimerAO::ConstructL() |
|
2319 { |
|
2320 //LOGENTRFN("CTimerAO::ConstructL()") |
|
2321 CActiveScheduler::Add( this ); |
|
2322 User::LeaveIfError( iTimer.CreateLocal() ); |
|
2323 //LOGEXITFN("CTimerAO::ConstructL()") |
|
2324 } |
|
2325 |
|
2326 // Destructor |
|
2327 CTimerAO::~CTimerAO() |
|
2328 { |
|
2329 Cancel(); |
|
2330 iTimer.Close(); |
|
2331 |
|
2332 iServer = NULL; |
|
2333 } |
|
2334 |
|
2335 // ----------------------------------------------------------------------------- |
|
2336 // CTimerAO::Start |
|
2337 // ----------------------------------------------------------------------------- |
|
2338 // |
|
2339 void CTimerAO::Start() |
|
2340 { |
|
2341 if ( !IsActive() ) |
|
2342 { |
|
2343 iTimer.After( iStatus, KActivityTimeout ); |
|
2344 SetActive(); |
|
2345 } |
|
2346 } |
|
2347 |
|
2348 // ----------------------------------------------------------------------------- |
|
2349 // CTimerAO::DoCancel |
|
2350 // ----------------------------------------------------------------------------- |
|
2351 // |
|
2352 void CTimerAO::DoCancel() |
|
2353 { |
|
2354 if ( IsActive() ) |
|
2355 { |
|
2356 iTimer.Cancel(); |
|
2357 } |
|
2358 } |
|
2359 |
|
2360 // ----------------------------------------------------------------------------- |
|
2361 // CTimerAO::RunL |
|
2362 // ----------------------------------------------------------------------------- |
|
2363 // |
|
2364 void CTimerAO::RunL() |
|
2365 { |
|
2366 CActivityNotifier* activityNotifier = 0; |
|
2367 |
|
2368 TInt err = iServer->Iap()->GetActivityNotifier( iConnectionId, &activityNotifier ); |
|
2369 |
|
2370 if ( ( err == KErrNone ) && ( activityNotifier != 0 ) ) |
|
2371 { |
|
2372 if ( activityNotifier->IsActive() ) |
|
2373 { |
|
2374 TUint threshold( activityNotifier->Threshold() ); |
|
2375 |
|
2376 if ( threshold == KOneTimeQueryThreshold ) |
|
2377 { |
|
2378 // Timer has completed before one time activity query. |
|
2379 // Cancel it to complete client requests |
|
2380 activityNotifier->Cancel(); |
|
2381 |
|
2382 // Someboby has started notifications while we were waiting this to |
|
2383 // complete -> go on with the notifications |
|
2384 if ( iServer->NumberOfListeners() > 0 ) |
|
2385 { |
|
2386 activityNotifier->Receive( iActivity ); |
|
2387 } |
|
2388 } |
|
2389 } |
|
2390 } |
|
2391 |
|
2392 delete this; |
|
2393 } |
|
2394 |
|
2395 // End-of-file |