|
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 session. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <featmgr.h> |
|
19 #include <etelmm.h> |
|
20 #include <rconnmon.h> |
|
21 |
|
22 #include "ConnMonSess.h" |
|
23 #include "ConnMonServ.h" |
|
24 #include "ConnMonIAP.h" |
|
25 #include "ConnMonDef.h" |
|
26 #include "CEventQueue.h" |
|
27 #include "CIapSupport.h" |
|
28 #include "CUiDialogAO.h" |
|
29 #include "ConnMonUtils.h" |
|
30 #include "ConnMonAvailabilityManager.h" |
|
31 #include "ConnMonBearerGroupManager.h" |
|
32 #include "connmonwlannetwork.h" |
|
33 #include "CPlugin.h" |
|
34 #include "log.h" |
|
35 |
|
36 |
|
37 // ============================ MEMBER FUNCTIONS =============================== |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // TConnSettings::TConnSettings |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 TConnSettings::TConnSettings( |
|
44 TUint aActivityTimeThreshold, |
|
45 TUint aDLDataThreshold, |
|
46 TUint aULDataThreshold ) |
|
47 : |
|
48 iActivityTimeThreshold( aActivityTimeThreshold ), |
|
49 iDLDataThreshold( aDLDataThreshold ), |
|
50 iULDataThreshold( aULDataThreshold ) |
|
51 { |
|
52 } |
|
53 |
|
54 |
|
55 // ============================ MEMBER FUNCTIONS =============================== |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // TConnRequest::TConnRequest |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 TConnRequest::TConnRequest( TUint8 aType, const RMessage2 aMessage ) |
|
62 : |
|
63 iType( aType ), |
|
64 iMessage( aMessage ) |
|
65 { |
|
66 } |
|
67 |
|
68 |
|
69 // ============================ MEMBER FUNCTIONS =============================== |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // TConnParams::TConnParams |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 TConnParams::TConnParams( TUint aConnectionId ) |
|
76 : |
|
77 iConnectionId( aConnectionId ), |
|
78 iSettings( 0, 0, 0 ) |
|
79 { |
|
80 iRequests.Reset(); |
|
81 } |
|
82 |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // TConnParams::MatchId |
|
86 // Finds TConnParams item matching by connection Id. |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 TBool TConnParams::MatchId( const TConnParams& aFirst, const TConnParams& aSecond ) |
|
90 { |
|
91 if ( aFirst.iConnectionId == aSecond.iConnectionId ) |
|
92 { |
|
93 return ETrue; |
|
94 } |
|
95 return EFalse; |
|
96 } |
|
97 |
|
98 |
|
99 // ============================ MEMBER FUNCTIONS =============================== |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CConnMonSession::CConnMonSession |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 CConnMonSession::CConnMonSession( CConnMonServer* aServer ) |
|
106 : |
|
107 CSession2(), |
|
108 iCmServer( aServer ) |
|
109 { |
|
110 } |
|
111 |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CConnMonSession::ConstructL |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 void CConnMonSession::ConstructL() |
|
118 { |
|
119 //LOGENTRFN("CConnMonSession::ConstructL()") |
|
120 |
|
121 iListening = EFalse; |
|
122 iEnumConnInfo = new( ELeave ) CArrayFixFlat<TUint>( 1 ); |
|
123 iEnumConnInfo->Reset(); |
|
124 |
|
125 // Initialize last event time |
|
126 iLastEventTime = iCmServer->EventQueue()->LastEventTime(); |
|
127 |
|
128 // Create a new object index (it stores the plug-in objects owned by this session) |
|
129 iPlugins = CObjectIx::NewL(); |
|
130 |
|
131 // Initialize the object container using the object container index in the server |
|
132 // (Object container provides unique ids for the objects owned by this session) |
|
133 iContainer = iCmServer->NewContainerL(); |
|
134 |
|
135 //LOGEXITFN("CConnMonSession::ConstructL()") |
|
136 } |
|
137 |
|
138 |
|
139 // ----------------------------------------------------------------------------- |
|
140 // CConnMonSession::~CConnMonSession |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 CConnMonSession::~CConnMonSession() |
|
144 { |
|
145 LOGIT(".") |
|
146 LOGENTRFN("CConnMonSession::~CConnMonSession()") |
|
147 |
|
148 if ( iListening && ( iBearerAvailabilityThreshold == 1 ) ) |
|
149 { |
|
150 // Resets plugin threshold, so plugin can stop sending bearer |
|
151 // availability events when no longer needed. |
|
152 SetPluginThreshold( EBearerAvailabilityThreshold, 0 ); |
|
153 } |
|
154 |
|
155 // Cancel any 'receive' request |
|
156 CancelReceiveEvent(); |
|
157 |
|
158 for ( TInt i = 0; i < iConnParams.Count(); i++ ) |
|
159 { |
|
160 iConnParams[i].iRequests.Close(); |
|
161 } |
|
162 |
|
163 iConnParams.Close(); |
|
164 |
|
165 if ( iEnumConnInfo != 0 ) |
|
166 { |
|
167 iEnumConnInfo->Reset(); |
|
168 delete iEnumConnInfo; |
|
169 iEnumConnInfo = NULL; |
|
170 } |
|
171 |
|
172 // Delete the object index |
|
173 delete iPlugins; |
|
174 iPlugins = NULL; |
|
175 |
|
176 // Delete the object container |
|
177 if ( iContainer != 0 ) |
|
178 { |
|
179 iCmServer->RemoveContainer( iContainer ); |
|
180 iContainer = NULL; |
|
181 } |
|
182 |
|
183 // Check WLAN support |
|
184 if ( iCmServer->Iap()->WlanSupport() ) |
|
185 { |
|
186 // Delete WLAN session from WlanSessions array if exists |
|
187 iCmServer->Iap()->WlanSupport()->DeleteWlanSession( this ); |
|
188 } |
|
189 |
|
190 // Decrement session count, so server may terminate if no longer needed |
|
191 iCmServer->DecrementSessions(); |
|
192 |
|
193 iCmServer = NULL; |
|
194 iReceiveBuffer = NULL; |
|
195 |
|
196 LOGEXITFN("CConnMonSession::~CConnMonSession()") |
|
197 } |
|
198 |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // CConnMonSession::ServiceL |
|
202 // ----------------------------------------------------------------------------- |
|
203 // |
|
204 void CConnMonSession::ServiceL( const RMessage2& aMessage ) |
|
205 { |
|
206 //LOGENTRFN("CConnMonSession::ServiceL()") |
|
207 TInt rc( KErrNone ); |
|
208 |
|
209 #ifdef _DEBUG |
|
210 if ( aMessage.Function() != EReqReceiveEvent ) |
|
211 { |
|
212 LOGIT(".") |
|
213 LOGIT2("ServiceL: function %d, id %X", aMessage.Function(), aMessage.SecureId().iId) |
|
214 } |
|
215 #endif // _DEBUG |
|
216 |
|
217 iMessage2 = aMessage; |
|
218 switch ( aMessage.Function() ) |
|
219 { |
|
220 case EReqGetConnectionCount: |
|
221 rc = GetConnectionCountL(); |
|
222 CompleteMessage( rc ); |
|
223 break; |
|
224 |
|
225 case EReqGetConnectionInfo: |
|
226 rc = GetConnectionInfo(); |
|
227 CompleteMessage( rc ); |
|
228 break; |
|
229 |
|
230 case EReqGetSubConnectionInfo: |
|
231 rc = GetSubConnectionInfo(); |
|
232 CompleteMessage( rc ); |
|
233 break; |
|
234 |
|
235 case EReqGetIntAttribute: |
|
236 rc = GetIntAttributeL(); |
|
237 CompleteMessage( rc ); |
|
238 break; |
|
239 |
|
240 case EReqGetUintAttribute: |
|
241 rc = GetUintAttributeL(); |
|
242 CompleteMessage( rc ); |
|
243 break; |
|
244 |
|
245 case EReqGetBoolAttribute: |
|
246 rc = GetBoolAttributeL(); |
|
247 CompleteMessage( rc ); |
|
248 break; |
|
249 |
|
250 case EReqGetStringAttribute: |
|
251 rc = GetStringAttributeL(); |
|
252 CompleteMessage( rc ); |
|
253 break; |
|
254 |
|
255 case EReqGetPckgAttribute: |
|
256 rc = GetPckgAttributeL(); |
|
257 CompleteMessage( rc ); |
|
258 break; |
|
259 |
|
260 case EReqSetIntAttribute: |
|
261 rc = SetIntAttributeL(); |
|
262 CompleteMessage( rc ); |
|
263 break; |
|
264 |
|
265 case EReqSetUintAttribute: |
|
266 rc = SetUintAttributeL(); |
|
267 CompleteMessage( rc ); |
|
268 break; |
|
269 |
|
270 case EReqSetBoolAttribute: |
|
271 rc = SetBoolAttribute(); |
|
272 CompleteMessage( rc ); |
|
273 break; |
|
274 |
|
275 case EReqSetStringAttribute: |
|
276 rc = SetStringAttributeL(); |
|
277 CompleteMessage( rc ); |
|
278 break; |
|
279 |
|
280 case EReqSetPckgAttribute: |
|
281 rc = SetPckgAttribute(); |
|
282 CompleteMessage( rc ); |
|
283 break; |
|
284 |
|
285 case EReqCancelAsyncRequest: |
|
286 rc = CancelAsyncRequest(); |
|
287 CompleteMessage( rc ); |
|
288 break; |
|
289 |
|
290 case EReqReceiveEvent: // TAny& aBuffer - async |
|
291 ReceiveEventL( aMessage.Ptr0() ); |
|
292 break; |
|
293 |
|
294 case EReqCancelReceiveEvent: |
|
295 CancelReceiveEvent(); |
|
296 CompleteMessage( 0 ); |
|
297 break; |
|
298 |
|
299 // Plug-in specific, fall-through intended |
|
300 case EReqPluginCreateSubSession: |
|
301 case EReqPluginCloseSubSession: |
|
302 case EReqPluginRegisterAttribute: |
|
303 case EReqPluginCancelRegisterAttribute: |
|
304 case EReqPluginEvent: |
|
305 case EReqPluginGetQuery: |
|
306 case EReqPluginCancelGetQuery: |
|
307 case EReqPluginAttribute: |
|
308 ServicePluginL( aMessage ); |
|
309 break; |
|
310 |
|
311 default: |
|
312 iCmServer->PanicClient( EBadRequest ); |
|
313 break; |
|
314 } |
|
315 //LOGEXITFN("CConnMonSession::ServiceL()") |
|
316 } |
|
317 |
|
318 |
|
319 // ----------------------------------------------------------------------------- |
|
320 // CConnMonSession::CompleteMessage |
|
321 // ----------------------------------------------------------------------------- |
|
322 // |
|
323 void CConnMonSession::CompleteMessage( const TInt aStatus ) |
|
324 { |
|
325 // Check if async message |
|
326 if ( aStatus != KRequestPending ) |
|
327 { |
|
328 // Complete message |
|
329 Message().Complete( aStatus ); |
|
330 } |
|
331 } |
|
332 |
|
333 |
|
334 // ----------------------------------------------------------------------------- |
|
335 // CConnMonSession::GetConnectionCountL |
|
336 // ----------------------------------------------------------------------------- |
|
337 // |
|
338 TInt CConnMonSession::GetConnectionCountL() |
|
339 { |
|
340 LOGENTRFN("CConnMonSession::GetConnectionCountL()") |
|
341 TInt err( KErrNone ); |
|
342 TUint count( 0 ); |
|
343 |
|
344 // Call comms APIs |
|
345 err = iCmServer->Iap()->EnumerateConnectionsL( count, *iEnumConnInfo ); |
|
346 LOGIT2("SERVER: EReqGetConnectionCount OUT: -> count %d, ret <%d>", count, err) |
|
347 |
|
348 if ( KErrNone == err ) |
|
349 { |
|
350 // Write "count" back to the client's address space |
|
351 TPtrC8 d( reinterpret_cast<TUint8*>( &count ), sizeof( count ) ); |
|
352 |
|
353 err = Message().Write( 0, d ); |
|
354 if ( err != KErrNone ) |
|
355 { |
|
356 LOGIT1("SERVER: EReqGetConnectionCount: -> error, Message().Write(0, d) returned <%d>", err) |
|
357 iCmServer->PanicClient( EBadDescriptor ); |
|
358 } |
|
359 |
|
360 LOGIT("SERVER: EReqGetConnectionCount. -> RemoveObsoleteConnectionParams()") |
|
361 // Remove obsolete connection settings |
|
362 RemoveObsoleteConnectionParams(); |
|
363 } |
|
364 |
|
365 LOGEXITFN1("CConnMonSession::GetConnectionCountL()", err) |
|
366 return err; |
|
367 } |
|
368 |
|
369 |
|
370 // ----------------------------------------------------------------------------- |
|
371 // CConnMonSession::GetConnectionInfo |
|
372 // ----------------------------------------------------------------------------- |
|
373 // |
|
374 TInt CConnMonSession::GetConnectionInfo() |
|
375 { |
|
376 LOGENTRFN("CConnMonSession::GetConnectionInfo()") |
|
377 TInt err( KErrNone ); |
|
378 TUint id( 0 ); |
|
379 TUint subConnectionCount( 1 ); |
|
380 |
|
381 TInt index = Message().Int0(); |
|
382 |
|
383 if ( !iEnumConnInfo ) |
|
384 { |
|
385 err = KErrUnknown; |
|
386 } |
|
387 // Indexes given to client start from 1 |
|
388 else if ( ( index <= 0 ) || ( index > iEnumConnInfo->Count() ) ) |
|
389 { |
|
390 err = KErrArgument; |
|
391 } |
|
392 else |
|
393 { |
|
394 // Enumerated connection IDs are stored in session |
|
395 id = (*iEnumConnInfo)[index - 1]; |
|
396 |
|
397 // Get subconnection count |
|
398 err = iCmServer->Iap()->GetConnectionInfo( id, subConnectionCount ); |
|
399 LOGIT4("SERVER: EReqGetConnectionInfo: index %d -> id %d, subConnCount %d, ret <%d>", |
|
400 index, id, subConnectionCount, err) |
|
401 |
|
402 if ( KErrNone == err ) |
|
403 { |
|
404 // Write "id" back to the client's address space |
|
405 TPtrC8 d( reinterpret_cast<TUint8*>( &id ), sizeof( id ) ); |
|
406 |
|
407 err = Message().Write( 1, d ); |
|
408 if ( KErrNone != err ) |
|
409 { |
|
410 iCmServer->PanicClient( EBadDescriptor ); |
|
411 } |
|
412 else |
|
413 { |
|
414 // Write "subConnectionCount" back to the client's address space |
|
415 TPtrC8 e( |
|
416 reinterpret_cast<TUint8*>( &subConnectionCount ), |
|
417 sizeof( subConnectionCount ) ); |
|
418 |
|
419 err = Message().Write( 2, e ); |
|
420 if ( KErrNone != err ) |
|
421 { |
|
422 iCmServer->PanicClient( EBadDescriptor ); |
|
423 } |
|
424 } |
|
425 } |
|
426 } |
|
427 LOGEXITFN1("CConnMonSession::GetConnectionInfo()", err) |
|
428 return err; |
|
429 } |
|
430 |
|
431 |
|
432 // ----------------------------------------------------------------------------- |
|
433 // CConnMonSession::GetSubConnectionInfo |
|
434 // ----------------------------------------------------------------------------- |
|
435 // |
|
436 TInt CConnMonSession::GetSubConnectionInfo() const |
|
437 { |
|
438 LOGENTRFN("CConnMonSession::GetSubConnectionInfo()") |
|
439 LOGEXITFN1("CConnMonSession::GetSubConnectionInfo()", KErrNotSupported) |
|
440 return KErrNotSupported; |
|
441 } |
|
442 |
|
443 |
|
444 // ----------------------------------------------------------------------------- |
|
445 // CConnMonSession::GetIntAttributeL |
|
446 // ----------------------------------------------------------------------------- |
|
447 // |
|
448 TInt CConnMonSession::GetIntAttributeL() |
|
449 { |
|
450 LOGENTRFN("CConnMonSession::GetIntAttributeL()") |
|
451 TInt err( KErrNone ); |
|
452 TInt value( 0 ); |
|
453 |
|
454 // Call comms APIs |
|
455 err = iCmServer->Iap()->GetIntAttributeL( Message(), value ); |
|
456 LOGIT1("SERVER: CConnMonSession::GetIntAttributeL: Iap()->GetIntAttributeL <%d>", err) |
|
457 |
|
458 // Check if this request should be served by a plug-in engine |
|
459 if ( ( Message().Int0() >= EBearerIdGPRS ) && |
|
460 ( err != KErrNone ) && |
|
461 ( err != KRequestPending ) ) |
|
462 { |
|
463 RMessage2 msg = Message(); |
|
464 err = iCmServer->SendRequestToPlugin( EReqGetIntAttribute, msg ); |
|
465 } |
|
466 |
|
467 LOGIT5("SERVER: EReqGetIntAttribute. id %d, subConnId %d, attr %d -> value %d, ret <%d>", |
|
468 Message().Int0(), Message().Int1(), Message().Int2(), value, err) |
|
469 if ( KErrNone == err ) |
|
470 { |
|
471 // Write "value" back to the client's address space |
|
472 TPtrC8 d( reinterpret_cast<TUint8*>( &value ), sizeof( value ) ); |
|
473 |
|
474 err = Message().Write( KAttributeParameterIndex, d ); |
|
475 if ( KErrNone != err ) |
|
476 { |
|
477 iCmServer->PanicClient( EBadDescriptor ); |
|
478 } |
|
479 } |
|
480 |
|
481 LOGEXITFN1("CConnMonSession::GetIntAttributeL()", err) |
|
482 return err; |
|
483 } |
|
484 |
|
485 |
|
486 // ----------------------------------------------------------------------------- |
|
487 // CConnMonSession::GetUintAttributeL |
|
488 // ----------------------------------------------------------------------------- |
|
489 // |
|
490 TInt CConnMonSession::GetUintAttributeL() |
|
491 { |
|
492 LOGENTRFN("CConnMonSession::GetUintAttributeL()") |
|
493 TInt err( KErrNone ); |
|
494 TUint value( 0 ); |
|
495 |
|
496 TUint connectionId( Message().Int0() ); |
|
497 TInt attribute( Message().Int2() ); |
|
498 |
|
499 switch ( attribute ) |
|
500 { |
|
501 case KDownlinkDataThreshold: |
|
502 case KUplinkDataThreshold: |
|
503 case KActivityTimeThreshold: |
|
504 { |
|
505 if ( iCmServer->Iap()->ConnectionExists( connectionId ) ) |
|
506 { |
|
507 TConnSettings settings( 0, 0, 0 ); |
|
508 err = GetConnectionSettings( connectionId, settings ); |
|
509 if ( KErrNone == err ) |
|
510 { |
|
511 if ( attribute == KDownlinkDataThreshold ) |
|
512 { |
|
513 value = settings.iDLDataThreshold; |
|
514 } |
|
515 else if ( attribute == KUplinkDataThreshold ) |
|
516 { |
|
517 value = settings.iULDataThreshold; |
|
518 } |
|
519 else |
|
520 { |
|
521 value = settings.iActivityTimeThreshold; |
|
522 } |
|
523 } |
|
524 } |
|
525 else |
|
526 { |
|
527 err = KErrNotFound; |
|
528 } |
|
529 } |
|
530 break; |
|
531 |
|
532 case KBearerAvailabilityThreshold: |
|
533 value = iBearerAvailabilityThreshold; |
|
534 break; |
|
535 case KSignalStrengthThreshold: |
|
536 value = iSignalStrengthThreshold; |
|
537 break; |
|
538 case KBearerGroupThreshold: |
|
539 value = iBearerGroupThreshold; |
|
540 break; |
|
541 |
|
542 case KMobilePhoneNetworkMode: |
|
543 { |
|
544 LOGIT("GetUintAttributeL: case KMobilePhoneNetworkMode") |
|
545 |
|
546 // Check network registration first |
|
547 TInt registrationMode( ENetworkRegistrationNotAvailable ); |
|
548 err = iCmServer->Iap()->GetNetworkRegistrationMode( registrationMode ); |
|
549 if ( KErrNone == err ) |
|
550 { |
|
551 if ( registrationMode == ENetworkRegistrationUnknown || |
|
552 registrationMode == ENetworkRegistrationNoService ) |
|
553 { |
|
554 value = EConnMonNetworkModeUnknown; |
|
555 } |
|
556 else |
|
557 { |
|
558 RMobilePhone::TMobilePhoneNetworkMode networkMode; |
|
559 err = iCmServer->Iap()->MobilePhone()->GetCurrentMode( networkMode ); |
|
560 if ( KErrNone == err ) |
|
561 { |
|
562 LOGIT1("GetUintAttributeL: current phone network mode %d", networkMode) |
|
563 |
|
564 TConnMonMobilePhoneNetworkMode connMonNetworkMode; |
|
565 err = ConnMonUtils::MobilePhoneNetworkModeToConnMonMobilePhoneNetworkMode( |
|
566 networkMode, |
|
567 connMonNetworkMode ); |
|
568 if ( KErrNone == err ) |
|
569 { |
|
570 value = connMonNetworkMode; |
|
571 } |
|
572 } |
|
573 } |
|
574 } |
|
575 } |
|
576 break; |
|
577 |
|
578 case KWlanScanMaxDelay: |
|
579 // Check WLAN support for the given ID |
|
580 err = iCmServer->Iap()->WlanSupportCheck( connectionId ); |
|
581 if ( KErrNone == err ) |
|
582 { |
|
583 err = iCmServer->Iap()->WlanSupport()->GetUintAttributeL( Message(), value ); |
|
584 } |
|
585 break; |
|
586 |
|
587 default: |
|
588 { |
|
589 LOGIT1("GetUintAttributeL: case %d", attribute) |
|
590 |
|
591 // Call comms APIs |
|
592 err = iCmServer->Iap()->GetUintAttributeL( Message(), value ); |
|
593 |
|
594 // Check if message will be completed later |
|
595 if ( KRequestPending == err ) |
|
596 { |
|
597 if ( KDownlinkData == attribute ) |
|
598 { |
|
599 TConnRequest request( KDownlinkData, Message() ); |
|
600 SetConnectionRequest( connectionId, request ); |
|
601 } |
|
602 else if ( KUplinkData == attribute ) |
|
603 { |
|
604 TConnRequest request( KUplinkData, Message() ); |
|
605 SetConnectionRequest( connectionId, request ); |
|
606 } |
|
607 } |
|
608 |
|
609 // Check if this request should be served by a plug-in engine |
|
610 if ( ( Message().Int0() >= EBearerIdGPRS ) && |
|
611 ( err != KErrNone ) && |
|
612 ( err != KRequestPending ) ) |
|
613 { |
|
614 RMessage2 msg = Message(); |
|
615 err = iCmServer->SendRequestToPlugin( EReqGetUintAttribute, msg ); |
|
616 } |
|
617 } |
|
618 break; |
|
619 } |
|
620 LOGIT5("SERVER: EReqGetUintAttribute: id %d, subConnId %d, attr %d -> value %d, ret <%d>", |
|
621 Message().Int0(), Message().Int1(), Message().Int2(), value, err ) |
|
622 |
|
623 if ( KErrNone == err ) |
|
624 { |
|
625 // Write "value" back to the client's address space |
|
626 TPtrC8 d( reinterpret_cast<TUint8*>( &value ), sizeof( value ) ); |
|
627 |
|
628 err = Message().Write( KAttributeParameterIndex, d ); |
|
629 if ( err != KErrNone ) |
|
630 { |
|
631 iCmServer->PanicClient( EBadDescriptor ); |
|
632 } |
|
633 } |
|
634 |
|
635 LOGEXITFN1("CConnMonSession::GetUintAttributeL()", err) |
|
636 return err; |
|
637 } |
|
638 |
|
639 // ----------------------------------------------------------------------------- |
|
640 // CConnMonSession::GetBoolAttributeL |
|
641 // ----------------------------------------------------------------------------- |
|
642 // |
|
643 TInt CConnMonSession::GetBoolAttributeL() |
|
644 { |
|
645 LOGENTRFN("CConnMonSession::GetBoolAttributeL()") |
|
646 TInt err( KErrNone ); |
|
647 TBool value( EFalse ); |
|
648 TUint connectionId( Message().Int0() ); |
|
649 TUint attribute( Message().Int2() ); |
|
650 |
|
651 LOGIT2("SERVER: EReqGetBoolAttribute IN: id %d, attr %d", connectionId, attribute) |
|
652 // Call comms APIs |
|
653 err = iCmServer->Iap()->GetBoolAttributeL( Message(), value ); |
|
654 |
|
655 // Check if request was KConnectionActive and should be completed later |
|
656 if ( ( err == KRequestPending ) && ( attribute == KConnectionActive ) ) |
|
657 { |
|
658 TConnRequest request( KConnectionActive, Message() ); |
|
659 SetConnectionRequest( connectionId, request ); |
|
660 } |
|
661 |
|
662 // Check if this request should be served by a plug-in engine |
|
663 if ( ( ( connectionId >= EBearerIdGPRS ) && |
|
664 ( err != KErrNone ) && |
|
665 ( err != KRequestPending ) ) |
|
666 || |
|
667 ( ( attribute == KBearerAvailability ) && |
|
668 ( err == KErrCancel ) ) ) |
|
669 { |
|
670 RMessage2 msg = Message(); |
|
671 err = iCmServer->SendRequestToPlugin( EReqGetBoolAttribute, msg ); |
|
672 } |
|
673 LOGIT5("SERVER: EReqGetBoolAttribute OUT: id %d, subConnId %d, attr %d -> value %d, ret <%d>", |
|
674 connectionId, Message().Int1(), attribute, value, err) |
|
675 |
|
676 // Return if error or the request is pending and will be completed later. |
|
677 if ( KErrNone == err ) |
|
678 { |
|
679 // Write "value" back to the client's address space |
|
680 TPtrC8 d( reinterpret_cast<TUint8*>( &value ), sizeof( value ) ); |
|
681 |
|
682 err = Message().Write( KAttributeParameterIndex, d ); |
|
683 if ( KErrNone != err ) |
|
684 { |
|
685 iCmServer->PanicClient( EBadDescriptor ); |
|
686 } |
|
687 } |
|
688 |
|
689 LOGEXITFN1("CConnMonSession::GetBoolAttributeL()", err) |
|
690 return err; |
|
691 } |
|
692 |
|
693 |
|
694 // ----------------------------------------------------------------------------- |
|
695 // CConnMonSession::GetStringAttributeL |
|
696 // ----------------------------------------------------------------------------- |
|
697 // |
|
698 TInt CConnMonSession::GetStringAttributeL() |
|
699 { |
|
700 LOGENTRFN("CConnMonSession::GetStringAttributeL()") |
|
701 TInt err( KErrNone ); |
|
702 TUint connectionId( Message().Int0() ); |
|
703 TUint attribute( Message().Int2() ); |
|
704 LOGIT2("SERVER: EReqGetStringAttribute IN: id %d, attribute %d", connectionId, attribute) |
|
705 |
|
706 HBufC16* value = HBufC16::NewL( KConnMonMaxStringAttributeLength ); |
|
707 CleanupStack::PushL( value ); |
|
708 |
|
709 TPtr16 auxPtr( const_cast<TUint16*>( value->Des().Ptr() ), KConnMonMaxStringAttributeLength ); |
|
710 auxPtr.FillZ(); // Fill descriptor with zeros |
|
711 |
|
712 // Check attribute |
|
713 switch ( attribute ) |
|
714 { |
|
715 case KWlanSsid: |
|
716 // Check WLAN support |
|
717 err = iCmServer->Iap()->WlanSupportCheck( connectionId ); |
|
718 if ( KErrNone == err ) |
|
719 { |
|
720 // Get string attribute from WLAN session, max SSID length is 32 |
|
721 err = iCmServer->Iap()->WlanSupport()->GetStringAttributeL( Message(), auxPtr ); |
|
722 } |
|
723 break; |
|
724 |
|
725 default: |
|
726 // Call comms APIs |
|
727 err = iCmServer->Iap()->GetStringAttribute( Message(), auxPtr ); |
|
728 |
|
729 // Check if this request should be served by a plug-in engine |
|
730 if ( ( connectionId >= EBearerIdGPRS ) && |
|
731 ( KErrNone != err ) && |
|
732 ( KRequestPending != err ) ) |
|
733 { |
|
734 RMessage2 msg = Message(); |
|
735 err = iCmServer->SendRequestToPlugin( EReqGetStringAttribute, msg ); |
|
736 } |
|
737 break; |
|
738 } |
|
739 // Length of 'value' should be max 63 chars. |
|
740 LOGIT5("SERVER: EReqGetStringAttribute OUT: id %d, subConnId %d, attr %d -> value >%s<, ret <%d>", |
|
741 connectionId, Message().Int1(), attribute, auxPtr.PtrZ(), err) |
|
742 |
|
743 CleanupStack::Pop( value ); |
|
744 |
|
745 if ( KErrNone == err ) |
|
746 { |
|
747 // Write "value" back to the client's address space |
|
748 err = Message().Write( KAttributeParameterIndex, auxPtr ); |
|
749 if ( err != KErrNone ) |
|
750 { |
|
751 iCmServer->PanicClient( EBadDescriptor ); |
|
752 } |
|
753 } |
|
754 delete value; |
|
755 |
|
756 LOGEXITFN1("CConnMonSession::GetStringAttributeL()", err) |
|
757 return err; |
|
758 } |
|
759 |
|
760 |
|
761 // ----------------------------------------------------------------------------- |
|
762 // CConnMonSession::GetPckgAttributeL |
|
763 // ----------------------------------------------------------------------------- |
|
764 // |
|
765 TInt CConnMonSession::GetPckgAttributeL() |
|
766 { |
|
767 LOGENTRFN("CConnMonSession::GetPckgAttributeL()") |
|
768 TInt err( KErrNone ); |
|
769 |
|
770 TUint connectionId( Message().Int0() ); |
|
771 TUint attribute( Message().Int2() ); |
|
772 |
|
773 switch ( attribute ) |
|
774 { |
|
775 case KStartTime: |
|
776 { |
|
777 LOGIT("GetPckgAttributeL: attr == KStartTime") |
|
778 TTime time; |
|
779 |
|
780 // Call comms APIs |
|
781 err = iCmServer->Iap()->GetStartTime( connectionId, time ); |
|
782 LOGIT2("GetPckgAttributeL: id %d, ret <%d>", connectionId, err) |
|
783 if ( KErrNone != err ) |
|
784 { |
|
785 return err; |
|
786 } |
|
787 |
|
788 // Write "value" back to the client's address space |
|
789 TPckgBuf<TTime> timePckg( time ); |
|
790 err = Message().Write( KAttributeParameterIndex, timePckg ); |
|
791 if ( KErrNone != err ) |
|
792 { |
|
793 iCmServer->PanicClient( EBadDescriptor ); |
|
794 return KErrBadDescriptor; |
|
795 } |
|
796 |
|
797 #ifdef _DEBUG |
|
798 TBuf<KConnMonMaxStringAttributeLength> buf; |
|
799 _LIT( KFormatStartTime, "%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B" ); |
|
800 time.FormatL( buf, KFormatStartTime ); |
|
801 LOGIT1("GetPckgAttributeL: universal start time >%s<", buf.PtrZ()) |
|
802 #endif // _DEBUG |
|
803 |
|
804 break; |
|
805 } |
|
806 |
|
807 case KClientInfo: |
|
808 { |
|
809 LOGIT("GetPckgAttributeL: attr == KClientInfo") |
|
810 // Client uids |
|
811 TConnMonClientEnum clientEnum; |
|
812 |
|
813 clientEnum.iCount = 0; |
|
814 for ( TUint i = 0; i < KConnMonMaxClientUids; i++ ) |
|
815 { |
|
816 clientEnum.iUid[i].iUid = 0; |
|
817 } |
|
818 |
|
819 // Call comms APIs |
|
820 err = iCmServer->Iap()->GetUids( connectionId, clientEnum ); |
|
821 LOGIT2("GetPckgAttributeL: clients %d, ret <%d>", clientEnum.iCount, err) |
|
822 if ( KErrNone != err ) |
|
823 { |
|
824 return err; |
|
825 } |
|
826 |
|
827 // Write "value" back to the client's address space |
|
828 TPckgBuf<TConnMonClientEnum> clientEnumPckg( clientEnum ); |
|
829 err = Message().Write( KAttributeParameterIndex, clientEnumPckg ); |
|
830 if ( KErrNone != err ) |
|
831 { |
|
832 iCmServer->PanicClient( EBadDescriptor ); |
|
833 return KErrBadDescriptor; |
|
834 } |
|
835 break; |
|
836 } |
|
837 |
|
838 case KNetworkNames: |
|
839 { |
|
840 LOGIT("GetPckgAttributeL: attr == KNetworkNames") |
|
841 |
|
842 // Check if WLAN attribute and WLAN is supported |
|
843 err = iCmServer->Iap()->WlanSupportCheck( connectionId ); |
|
844 if ( KErrNone == err ) |
|
845 { |
|
846 // This attribute generates WLAN scanning via WLAN engine. |
|
847 // Async GetScanResults method is called and message will be completed |
|
848 // later in session specific WlanSession class object |
|
849 err = iCmServer->Iap()->WlanSupport()->GetNetworkNamesL( Message() ); |
|
850 } |
|
851 return err; |
|
852 } |
|
853 |
|
854 case KWLANNetworks: |
|
855 { |
|
856 LOGIT("GetPckgAttributeL: attr == KWLANNetworks") |
|
857 |
|
858 // Check buffer max length |
|
859 TInt maxSize( Message().GetDesMaxLength( KAttributeParameterIndex ) ); |
|
860 if ( KErrBadDescriptor == maxSize ) |
|
861 { |
|
862 LOGIT("GetPckgAttributeL: error, bad descriptor argument") |
|
863 iCmServer->PanicClient( EBadDescriptor ); |
|
864 return KErrBadDescriptor; |
|
865 } |
|
866 |
|
867 // Buffer's max length needs to be at least 2 beacause |
|
868 // minimum information to be returned is the count of all |
|
869 // networks and the count of returned networks. |
|
870 if ( maxSize < 2 ) |
|
871 { |
|
872 LOGIT1("GetPckgAttributeL: buffer too small %d", maxSize) |
|
873 return KErrArgument; |
|
874 } |
|
875 |
|
876 // Get WLAN networks |
|
877 RConnMonWLANNetworksArray wlanNetworks; |
|
878 CleanupClosePushL( wlanNetworks ); |
|
879 iCmServer->Iap()->WlanSupport()->GetWLANNetworksL( wlanNetworks ); |
|
880 |
|
881 ConnMonWLANNetworksArrayPckg arr( wlanNetworks, maxSize ); |
|
882 CleanupStack::PopAndDestroy( &wlanNetworks ); |
|
883 |
|
884 if ( !arr.Buf() ) |
|
885 { |
|
886 return KErrNoMemory; |
|
887 } |
|
888 |
|
889 // Write result back to the client |
|
890 TInt res = Message().Write( KAttributeParameterIndex, ( *arr.Buf() ) ); |
|
891 if ( KErrNone != res ) |
|
892 { |
|
893 iCmServer->PanicClient( EBadDescriptor ); |
|
894 return KErrBadDescriptor; |
|
895 } |
|
896 |
|
897 break; |
|
898 } |
|
899 |
|
900 case KWlanNetworks: |
|
901 { |
|
902 LOGIT("GetPckgAttributeL: attr == KWlanNetworks") |
|
903 |
|
904 // Check if WLAN attribute and WLAN is supported |
|
905 err = iCmServer->Iap()->WlanSupportCheck( connectionId ); |
|
906 if ( KErrNone != err ) |
|
907 { |
|
908 return err; |
|
909 } |
|
910 |
|
911 // Check buffer max length |
|
912 TInt maxSize( Message().GetDesMaxLength( KAttributeParameterIndex ) ); |
|
913 if ( KErrBadDescriptor == maxSize ) |
|
914 { |
|
915 LOGIT("GetPckgAttributeL: error, bad descriptor argument") |
|
916 iCmServer->PanicClient( EBadDescriptor ); |
|
917 return KErrBadDescriptor; |
|
918 } |
|
919 |
|
920 // Buffer's max length needs to be at least 2 because |
|
921 // minimum information to be returned is the count of all |
|
922 // networks and the count of returned networks. |
|
923 if ( maxSize < 2 ) |
|
924 { |
|
925 LOGIT1("GetPckgAttributeL: buffer too small %d", maxSize) |
|
926 return KErrArgument; |
|
927 } |
|
928 |
|
929 // This attribute generates WLAN scanning via WLAN engine. |
|
930 // Async GetScanResults method is called and message will be completed |
|
931 // later in session specific WlanSession class object |
|
932 err = iCmServer->Iap()->WlanSupport()->GetWlanNetworksL( Message() ); |
|
933 return err; |
|
934 } |
|
935 |
|
936 case KWlanSsidNetworks: |
|
937 { |
|
938 LOGIT("GetPckgAttributeL: attr == KWlanSsidNetworks") |
|
939 |
|
940 // Check if WLAN attribute and WLAN is supported |
|
941 err = iCmServer->Iap()->WlanSupportCheck( connectionId ); |
|
942 if ( KErrNone != err ) |
|
943 { |
|
944 return err; |
|
945 } |
|
946 |
|
947 // Check buffer max length |
|
948 TInt maxSize( Message().GetDesMaxLength( KAttributeParameterIndex ) ); |
|
949 if ( KErrBadDescriptor == maxSize ) |
|
950 { |
|
951 LOGIT("GetPckgAttributeL: error, bad descriptor argument") |
|
952 iCmServer->PanicClient( EBadDescriptor ); |
|
953 return KErrBadDescriptor; |
|
954 } |
|
955 |
|
956 // Buffer's max length needs to be at least 2 because |
|
957 // minimum information to be returned is the count of all |
|
958 // networks and the count of returned networks. |
|
959 if ( maxSize < 2 ) |
|
960 { |
|
961 LOGIT1("GetPckgAttributeL: buffer too small %d", maxSize) |
|
962 return KErrArgument; |
|
963 } |
|
964 |
|
965 // This attribute generates WLAN scanning via WLAN engine. |
|
966 // Async GetScanResults method is called and message will be completed |
|
967 // later in session specific WlanSession class object |
|
968 err = iCmServer->Iap()->WlanSupport()->GetWlanSsidNetworksL( Message() ); |
|
969 return err; |
|
970 } |
|
971 |
|
972 case KWlanCurrentNetwork: |
|
973 { |
|
974 LOGIT("GetPckgAttributeL: attr == KCurrentWlanNetwork") |
|
975 |
|
976 // Check if WLAN attribute and WLAN is supported |
|
977 err = iCmServer->Iap()->WlanSupportCheck( connectionId ); |
|
978 if ( err != KErrNone ) |
|
979 { |
|
980 return err; |
|
981 } |
|
982 |
|
983 // Check buffer max length |
|
984 TInt maxSize( Message().GetDesMaxLength( KAttributeParameterIndex ) ); |
|
985 if ( KErrBadDescriptor == maxSize ) |
|
986 { |
|
987 LOGIT("GetPckgAttributeL: error, bad descriptor argument") |
|
988 iCmServer->PanicClient( EBadDescriptor ); |
|
989 return KErrBadDescriptor; |
|
990 } |
|
991 |
|
992 // Buffer's max length needs to be at least 2 because |
|
993 // minimum information to be returned is the count of all |
|
994 // networks and the count of returned networks. |
|
995 if ( maxSize < 2 ) |
|
996 { |
|
997 LOGIT1("GetPckgAttributeL: buffer too small %d", maxSize) |
|
998 return KErrArgument; |
|
999 } |
|
1000 |
|
1001 RConnMonWlanNetworksPtrArray wlanNetwork; |
|
1002 ConnMonCleanupResetAndDestroyPushL( wlanNetwork ); |
|
1003 |
|
1004 err = iCmServer->Iap()->WlanSupport()->GetCurrentWlanNetworkL( wlanNetwork ); |
|
1005 if ( err != KErrNone ) |
|
1006 { |
|
1007 CleanupStack::PopAndDestroy( &wlanNetwork ); |
|
1008 return err; |
|
1009 } |
|
1010 |
|
1011 CConnMonWlanNetworksPtrArrayPckg arr( wlanNetwork, maxSize ); |
|
1012 CleanupStack::PopAndDestroy( &wlanNetwork ); |
|
1013 |
|
1014 if ( !arr.Buf() ) |
|
1015 { |
|
1016 return KErrNoMemory; |
|
1017 } |
|
1018 |
|
1019 // Write "value" back to the client's address space |
|
1020 err = Message().Write( KAttributeParameterIndex, ( *arr.Buf() ) ); |
|
1021 if ( err != KErrNone ) |
|
1022 { |
|
1023 // Panic client |
|
1024 iCmServer->PanicClient( EBadDescriptor ); |
|
1025 } |
|
1026 return err; |
|
1027 } |
|
1028 |
|
1029 case KWlanProbeRawBuffers: |
|
1030 { |
|
1031 LOGIT("GetPckgAttributeL: attr == KWlanProbeRawBuffers") |
|
1032 |
|
1033 // Check if WLAN attribute and WLAN is supported |
|
1034 err = iCmServer->Iap()->WlanSupportCheck( connectionId ); |
|
1035 if ( KErrNone != err ) |
|
1036 { |
|
1037 return err; |
|
1038 } |
|
1039 |
|
1040 // Check buffer max length |
|
1041 TInt maxSize( Message().GetDesMaxLength( KAttributeParameterIndex ) ); |
|
1042 if ( KErrBadDescriptor == maxSize ) |
|
1043 { |
|
1044 LOGIT("GetPckgAttributeL: error, bad descriptor argument") |
|
1045 iCmServer->PanicClient( EBadDescriptor ); |
|
1046 return KErrBadDescriptor; |
|
1047 } |
|
1048 |
|
1049 // Buffer's max length needs to be at least 2 because |
|
1050 // minimum information to be returned is the count of all |
|
1051 // networks and the count of returned networks. |
|
1052 if ( maxSize < 2 ) |
|
1053 { |
|
1054 LOGIT1("GetPckgAttributeL: buffer too small %d", maxSize) |
|
1055 return KErrArgument; |
|
1056 } |
|
1057 |
|
1058 // This attribute generates WLAN scanning via WLAN engine. |
|
1059 // Async GetScanResults method is called and message will be completed |
|
1060 // later in session specific WlanSession class object |
|
1061 err = iCmServer->Iap()->WlanSupport()->GetWlanProbeRawBuffersL( Message() ); |
|
1062 return err; |
|
1063 } |
|
1064 |
|
1065 case KIapAvailability: |
|
1066 { |
|
1067 LOGIT1("GetPckgAttributeL: KIapAvailability, id %d", connectionId) |
|
1068 TConnMonIapInfo iaps; |
|
1069 |
|
1070 // Connection ID attribute validity check |
|
1071 if ( ( connectionId != 0 ) && |
|
1072 ( ( connectionId < EBearerIdGPRS ) || |
|
1073 ( connectionId > EBearerIdVirtualVPN ) ) ) |
|
1074 { |
|
1075 err = KErrArgument; |
|
1076 } |
|
1077 else if ( ( connectionId == EBearerIdGSM ) || |
|
1078 ( connectionId == EBearerIdCDMA2000 ) ) |
|
1079 { |
|
1080 err = KErrArgument; |
|
1081 } |
|
1082 |
|
1083 if ( !err ) |
|
1084 { |
|
1085 // Enable WLAN scan only if asking for all, WLAN or virtual IAPs |
|
1086 if ( ( connectionId == EBearerIdAll ) || |
|
1087 ( connectionId == EBearerIdWLAN ) || |
|
1088 ( connectionId == EBearerIdVirtualVPN ) ) |
|
1089 { |
|
1090 iCmServer->Iap()->EnableWlanScan(); |
|
1091 } |
|
1092 |
|
1093 // If WLAN background scan is ON and request is asking for all- |
|
1094 // or virtual iaps, ConnMon will send availability changed |
|
1095 // event if availability change is detected. |
|
1096 err = iCmServer->GetAvailableIaps( connectionId, iaps ); |
|
1097 } |
|
1098 |
|
1099 LOGIT2("SERVER: GetPckgAttributeL: -> IAP count %d, err <%d>", iaps.iCount, err) |
|
1100 if ( err ) |
|
1101 { |
|
1102 return err; |
|
1103 } |
|
1104 |
|
1105 // Write result back to client |
|
1106 TConnMonIapInfoBuf iapBuf( iaps ); |
|
1107 err = Message().Write( KAttributeParameterIndex, iapBuf ); |
|
1108 if ( err ) |
|
1109 { |
|
1110 iCmServer->PanicClient( EBadDescriptor ); |
|
1111 return KErrBadDescriptor; |
|
1112 } |
|
1113 } |
|
1114 break; |
|
1115 |
|
1116 case KSNAPsAvailability: |
|
1117 { |
|
1118 LOGIT("GetPckgAttributeL: KSNAPsAvailability") |
|
1119 TConnMonSNAPInfo snaps; |
|
1120 |
|
1121 iCmServer->Iap()->EnableWlanScan(); |
|
1122 |
|
1123 // If WLAN background scan is ON, ConnMon will send availability |
|
1124 // changed event if availability change is detected. |
|
1125 iCmServer->GetAvailableSnaps( snaps ); |
|
1126 |
|
1127 // Write result back to the client |
|
1128 TConnMonSNAPInfoBuf snapBuf( snaps ); |
|
1129 |
|
1130 err = Message().Write( KAttributeParameterIndex, snapBuf ); |
|
1131 if ( err ) |
|
1132 { |
|
1133 iCmServer->PanicClient( EBadDescriptor ); |
|
1134 return KErrBadDescriptor; |
|
1135 } |
|
1136 } |
|
1137 break; |
|
1138 |
|
1139 case KAvailableSNAPsIds: |
|
1140 { |
|
1141 LOGIT("GetPckgAttributeL: KAvailableSNAPsIds") |
|
1142 |
|
1143 TInt maxSize( Message().GetDesMaxLength( KAttributeParameterIndex ) ); // Max buffer length |
|
1144 if ( KErrBadDescriptor == maxSize ) |
|
1145 { |
|
1146 LOGIT("SERVER: EReqGetPckgAttribute -> KAvailableSNAPsIds: bad descriptor") |
|
1147 iCmServer->PanicClient( EBadDescriptor ); |
|
1148 return KErrBadDescriptor; |
|
1149 } |
|
1150 // Buffer's max length needs to be at least 2 beacause minimum |
|
1151 // information to be returned is the count of all networks and |
|
1152 // the count of returned networks. |
|
1153 if ( maxSize < 2 ) |
|
1154 { |
|
1155 LOGIT("SERVER: EReqGetPckgAttribute -> KAvailableSNAPsIds: descriptor too small") |
|
1156 return KErrArgument; |
|
1157 } |
|
1158 |
|
1159 iCmServer->Iap()->EnableWlanScan(); |
|
1160 |
|
1161 // If WLAN background scan is ON, ConnMon will send availability |
|
1162 // changed event if availability change is detected. |
|
1163 RArray<TConnMonId> availableSnapIds; |
|
1164 err = iCmServer->GetAvailableSnaps( availableSnapIds ); |
|
1165 if ( err ) |
|
1166 { |
|
1167 availableSnapIds.Close(); |
|
1168 return err; |
|
1169 } |
|
1170 |
|
1171 ConnMonIdsArrayPckg arr( availableSnapIds, maxSize ); |
|
1172 availableSnapIds.Close(); |
|
1173 if ( !arr.Buf() ) |
|
1174 { |
|
1175 return KErrNoMemory; |
|
1176 } |
|
1177 |
|
1178 err = Message().Write( KAttributeParameterIndex, (*arr.Buf()) ); |
|
1179 if ( err ) |
|
1180 { |
|
1181 iCmServer->PanicClient( EBadDescriptor ); |
|
1182 return KErrBadDescriptor; |
|
1183 } |
|
1184 } |
|
1185 break; |
|
1186 |
|
1187 case KBearerGroupInfo: |
|
1188 { |
|
1189 LOGIT("GetPckgAttributeL: KBearerGroupInfo") |
|
1190 |
|
1191 TBearerInfo bearerInfo; |
|
1192 TInt err = iCmServer->Iap()->GetBearerInfo( connectionId, bearerInfo ); |
|
1193 if ( KErrNone != err ) |
|
1194 { |
|
1195 return err; |
|
1196 } |
|
1197 LOGIT1("CConnMonSession::GetPckgAttributeL, bearer %d", bearerInfo.iBearer) |
|
1198 |
|
1199 TUint bearerMask( 0 ); |
|
1200 TUint bearerMask2( 0 ); |
|
1201 |
|
1202 err = iCmServer->BearerGroupManager()->GetBearerGroups( |
|
1203 (TConnMonBearerInfo)bearerInfo.iBearer, |
|
1204 bearerMask, |
|
1205 bearerMask2 ); |
|
1206 if ( KErrNone != err ) |
|
1207 { |
|
1208 return err; |
|
1209 } |
|
1210 LOGIT2("CConnMonSession::GetPckgAttributeL, bearerMask %d, bearerMask2 %d", bearerMask, bearerMask2) |
|
1211 |
|
1212 TConnMonBearerGroupInfo groupInfo; |
|
1213 groupInfo.iInternal = bearerInfo.iInternal; |
|
1214 groupInfo.iBearerGroups = bearerMask; |
|
1215 groupInfo.iBearerGroups2 = bearerMask2; |
|
1216 |
|
1217 TConnMonBearerGroupInfoBuf groupInfoBuf( groupInfo ); |
|
1218 err = Message().Write( KAttributeParameterIndex, groupInfoBuf ); |
|
1219 if ( KErrNone != err ) |
|
1220 { |
|
1221 LOGIT1("GetPckgAttributeL: error writing result to client <%d>", err) |
|
1222 iCmServer->PanicClient( EBadDescriptor ); |
|
1223 return KErrBadDescriptor; |
|
1224 } |
|
1225 |
|
1226 break; |
|
1227 } |
|
1228 |
|
1229 default: |
|
1230 { |
|
1231 LOGIT("GetPckgAttributeL: UNKNOWN attribute") |
|
1232 return KErrNotSupported; |
|
1233 } |
|
1234 } |
|
1235 |
|
1236 LOGEXITFN("CConnMonSession::GetPckgAttributeL()") |
|
1237 return KErrNone; |
|
1238 } |
|
1239 |
|
1240 |
|
1241 // ----------------------------------------------------------------------------- |
|
1242 // CConnMonSession::SetIntAttribute |
|
1243 // ----------------------------------------------------------------------------- |
|
1244 // |
|
1245 TInt CConnMonSession::SetIntAttributeL() |
|
1246 { |
|
1247 LOGENTRFN("CConnMonSession::SetIntAttributeL()") |
|
1248 TInt err( KErrNone ); |
|
1249 |
|
1250 TUint connectionId( Message().Int0() ); |
|
1251 TUint attribute( Message().Int2() ); |
|
1252 TUint value( Message().Int3() ); |
|
1253 |
|
1254 if ( KWlanScanCacheLifetime == attribute ) |
|
1255 { |
|
1256 // Check WLAN support for the given id |
|
1257 err = iCmServer->Iap()->WlanSupportCheck( connectionId ); |
|
1258 if ( KErrNone == err ) |
|
1259 { |
|
1260 err = iCmServer->Iap()->WlanSupport()->SetIntAttributeL( Message(), value ); |
|
1261 } |
|
1262 } |
|
1263 else if ( connectionId >= EBearerIdGPRS ) |
|
1264 { |
|
1265 RMessage2 msg = Message(); |
|
1266 err = iCmServer->SendRequestToPlugin( EReqSetIntAttribute, msg ); |
|
1267 } |
|
1268 else |
|
1269 { |
|
1270 err = KErrNotSupported; |
|
1271 } |
|
1272 |
|
1273 LOGEXITFN1("CConnMonSession::SetIntAttributeL()", err) |
|
1274 return err; |
|
1275 } |
|
1276 |
|
1277 |
|
1278 // ----------------------------------------------------------------------------- |
|
1279 // CConnMonSession::SetUintAttribute |
|
1280 // ----------------------------------------------------------------------------- |
|
1281 // |
|
1282 TInt CConnMonSession::SetUintAttributeL() |
|
1283 { |
|
1284 LOGENTRFN("CConnMonSession::SetUintAttributeL()") |
|
1285 TInt err( KErrNone ); |
|
1286 |
|
1287 TUint connectionId( Message().Int0() ); |
|
1288 TUint attribute( Message().Int2() ); |
|
1289 TUint value( Message().Int3() ); |
|
1290 |
|
1291 switch ( attribute ) |
|
1292 { |
|
1293 case KDownlinkDataThreshold: |
|
1294 case KUplinkDataThreshold: |
|
1295 case KActivityTimeThreshold: |
|
1296 { |
|
1297 if ( connectionId > KMaxConnectionId ) |
|
1298 { |
|
1299 err = KErrArgument; |
|
1300 } |
|
1301 else if ( !iCmServer->Iap()->ConnectionExists( connectionId ) ) |
|
1302 { |
|
1303 err = KErrNotFound; |
|
1304 } |
|
1305 else |
|
1306 { |
|
1307 err = AdjustThresholdToAllowedRange( connectionId, attribute, value ); |
|
1308 if ( KErrNone == err ) |
|
1309 { |
|
1310 TConnSettings settings( 0, 0, 0 ); |
|
1311 GetConnectionSettings( connectionId, settings ); |
|
1312 if ( attribute == KDownlinkDataThreshold ) |
|
1313 { |
|
1314 settings.iDLDataThreshold = value; |
|
1315 } |
|
1316 else if ( attribute == KUplinkDataThreshold ) |
|
1317 { |
|
1318 settings.iULDataThreshold = value; |
|
1319 } |
|
1320 else // KActivityTimeThreshold |
|
1321 { |
|
1322 settings.iActivityTimeThreshold = value; |
|
1323 } |
|
1324 err = SetConnectionSettings( connectionId, settings ); |
|
1325 } |
|
1326 } |
|
1327 } |
|
1328 break; |
|
1329 |
|
1330 case KBearerAvailabilityThreshold: |
|
1331 err = SetPluginThreshold( EBearerAvailabilityThreshold, value ); |
|
1332 if ( err != KErrNone ) |
|
1333 { |
|
1334 // Set anyway |
|
1335 iBearerAvailabilityThreshold = value; |
|
1336 err = KErrNone; |
|
1337 } |
|
1338 if ( iListening && ( iBearerAvailabilityThreshold > 0 ) ) |
|
1339 { |
|
1340 iCmServer->Iap()->WakeUpNotifications(); |
|
1341 } |
|
1342 break; |
|
1343 |
|
1344 case KSignalStrengthThreshold: |
|
1345 iSignalStrengthThreshold = value; |
|
1346 if ( iListening && ( iSignalStrengthThreshold > 0 ) ) |
|
1347 { |
|
1348 iCmServer->Iap()->WakeUpNotifications(); |
|
1349 } |
|
1350 err = KErrNone; |
|
1351 break; |
|
1352 |
|
1353 case KBearerGroupThreshold: |
|
1354 iBearerGroupThreshold = value; |
|
1355 LOGIT1("SetUintAttributeL: bearer group threshold set %d", iBearerGroupThreshold) |
|
1356 break; |
|
1357 |
|
1358 case KWlanScanMaxDelay: |
|
1359 // Check WLAN support for the given id |
|
1360 err = iCmServer->Iap()->WlanSupportCheck( connectionId ); |
|
1361 if ( KErrNone == err ) |
|
1362 { |
|
1363 err = iCmServer->Iap()->WlanSupport()->SetUintAttributeL( Message(), value ); |
|
1364 } |
|
1365 break; |
|
1366 |
|
1367 default: |
|
1368 LOGIT1("SERVER: CConnMonSession::SetUintAttributeL() default case %d", attribute) |
|
1369 // Call comms APIs |
|
1370 err = iCmServer->Iap()->SetUintAttribute( Message(), value ); |
|
1371 |
|
1372 if ( ( Message().Int0() >= EBearerIdGPRS ) && ( err != KErrNone ) ) |
|
1373 { |
|
1374 RMessage2 msg = Message(); |
|
1375 err = iCmServer->SendRequestToPlugin( EReqSetUintAttribute, msg ); |
|
1376 } |
|
1377 break; |
|
1378 } |
|
1379 |
|
1380 LOGEXITFN1("CConnMonSession::SetUintAttributeL()", err) |
|
1381 return err; |
|
1382 } |
|
1383 |
|
1384 // ----------------------------------------------------------------------------- |
|
1385 // CConnMonSession::SetBoolAttributeL |
|
1386 // ----------------------------------------------------------------------------- |
|
1387 // |
|
1388 TInt CConnMonSession::SetBoolAttribute() |
|
1389 { |
|
1390 LOGENTRFN("CConnMonSession::SetBoolAttribute()") |
|
1391 TInt err( KErrNotSupported ); |
|
1392 TUint attribute( Message().Int2() ); |
|
1393 LOGIT3("SERVER: EReqSetBoolAttribute IN: id %d, attr %d, value %d", |
|
1394 Message().Int0(), attribute, Message().Int3()) |
|
1395 |
|
1396 if ( ( attribute == KConnectionStop ) || ( attribute == KConnectionStopAll ) ) |
|
1397 { |
|
1398 err = iCmServer->Iap()->SetBoolAttribute( Message() ); |
|
1399 } |
|
1400 else if ( Message().Int0() >= EBearerIdGPRS ) |
|
1401 { |
|
1402 RMessage2 msg = Message(); |
|
1403 err = iCmServer->SendRequestToPlugin( EReqSetBoolAttribute, msg ); |
|
1404 } |
|
1405 |
|
1406 LOGEXITFN1("CConnMonSession::SetBoolAttribute()", err) |
|
1407 return err; |
|
1408 } |
|
1409 |
|
1410 |
|
1411 // ----------------------------------------------------------------------------- |
|
1412 // CConnMonSession::SetStringAttribute |
|
1413 // ----------------------------------------------------------------------------- |
|
1414 // |
|
1415 TInt CConnMonSession::SetStringAttributeL() |
|
1416 { |
|
1417 LOGENTRFN("CConnMonSession::SetStringAttributeL()") |
|
1418 TInt err( KErrNone ); |
|
1419 TUint connectionId( Message().Int0() ); |
|
1420 TUint attribute( Message().Int2() ); |
|
1421 LOGIT2("SERVER: EReqSetStringAttribute: id %d, attr %d", connectionId, attribute) |
|
1422 |
|
1423 // Check attribute |
|
1424 switch ( attribute ) |
|
1425 { |
|
1426 case KWlanSsid: |
|
1427 { |
|
1428 // Check WLAN support |
|
1429 err = iCmServer->Iap()->WlanSupportCheck( connectionId ); |
|
1430 if ( KErrNone == err ) |
|
1431 { |
|
1432 // Get descriptor argument length |
|
1433 TInt size = Message().GetDesLength( KAttributeParameterIndex ); |
|
1434 if ( size < 0 ) |
|
1435 { |
|
1436 LOGIT("SetStringAttributeL: error with descriptor argument") |
|
1437 err = size; // KErrArgument or KErrBadDescriptor |
|
1438 } |
|
1439 else if ( size > CConnMonWlanNetwork::KMaxNameLength ) |
|
1440 { |
|
1441 LOGIT1("SetStringAttributeL: string too long %d", size) |
|
1442 err = KErrTooBig; |
|
1443 } |
|
1444 else |
|
1445 { |
|
1446 // Read descriptor argument from message |
|
1447 TBuf<CConnMonWlanNetwork::KMaxNameLength> value; |
|
1448 Message().Read( KAttributeParameterIndex, value ); |
|
1449 |
|
1450 #ifdef _DEBUG |
|
1451 // One letter longer than string, since we are adding a '\0' when printing |
|
1452 TBuf<CConnMonWlanNetwork::KMaxNameLength + 1> debugName( value ); |
|
1453 LOGIT2("SetStringAttributeL: string >%s<, length %d", debugName.PtrZ(), value.Length()) |
|
1454 #endif // _DEBUG |
|
1455 |
|
1456 // Set string |
|
1457 err = iCmServer->Iap()->WlanSupport()->SetStringAttributeL( Message(), value ); |
|
1458 } |
|
1459 } |
|
1460 } |
|
1461 break; |
|
1462 |
|
1463 default: |
|
1464 err = KErrNotSupported; |
|
1465 break; |
|
1466 } |
|
1467 |
|
1468 LOGEXITFN1("CConnMonSession::SetStringAttributeL()", err) |
|
1469 return err; |
|
1470 } |
|
1471 |
|
1472 // ----------------------------------------------------------------------------- |
|
1473 // CConnMonSession::SetPckgAttribute |
|
1474 // ----------------------------------------------------------------------------- |
|
1475 // |
|
1476 TInt CConnMonSession::SetPckgAttribute() const |
|
1477 { |
|
1478 return KErrNotSupported; |
|
1479 } |
|
1480 |
|
1481 // ----------------------------------------------------------------------------- |
|
1482 // CConnMonSession::CancelAsyncRequest |
|
1483 // ----------------------------------------------------------------------------- |
|
1484 // |
|
1485 TInt CConnMonSession::CancelAsyncRequest() |
|
1486 { |
|
1487 LOGENTRFN("CConnMonSession::CancelAsyncRequest()") |
|
1488 |
|
1489 // Defined in TConnMonAsyncRequest |
|
1490 TInt requestToCancel = Message().Int0(); |
|
1491 LOGIT1("SERVER: EReqCancelAsyncRequest, req %d", requestToCancel) |
|
1492 |
|
1493 if ( ( EConnMonGetPckgAttribute == requestToCancel ) || |
|
1494 ( EConnMonGetBoolAttribute == requestToCancel ) || |
|
1495 ( EConnMonGetIntAttribute == requestToCancel ) ) |
|
1496 { |
|
1497 // Check WLAN support |
|
1498 if ( iCmServer->Iap()->WlanSupport() ) |
|
1499 { |
|
1500 // Cancel possible wlan requests |
|
1501 iCmServer->Iap()->WlanSupport()->CancelAsyncRequest( Message() ); |
|
1502 } |
|
1503 } |
|
1504 |
|
1505 if ( EConnMonGetUintAttribute == requestToCancel ) |
|
1506 { |
|
1507 // Complete all pending data volume requests with status 'KErrCancel' |
|
1508 for ( TInt i = 0; i < iConnParams.Count(); i++ ) |
|
1509 { |
|
1510 CompleteDataVolumeRequests( iConnParams[i].iConnectionId, 0, 0, KErrCancel ); |
|
1511 } |
|
1512 } |
|
1513 else if ( EConnMonGetBoolAttribute == requestToCancel ) |
|
1514 { |
|
1515 // Complete all pending activity requests with status 'KErrCancel' |
|
1516 for ( TInt i = 0; i < iConnParams.Count(); i++ ) |
|
1517 { |
|
1518 CompleteActivityRequests( iConnParams[i].iConnectionId, EFalse, KErrCancel ); |
|
1519 } |
|
1520 } |
|
1521 |
|
1522 // Complete all pending plugin requests (of type Message().Int0()) with 'KErrCancel' |
|
1523 RThread clientThread; |
|
1524 |
|
1525 TInt err = Message().Client( clientThread ); |
|
1526 if ( KErrNone == err ) |
|
1527 { |
|
1528 iCmServer->CancelAttributeRequestsFromPlugins( clientThread, Message().Int0() ); |
|
1529 clientThread.Close(); |
|
1530 } |
|
1531 |
|
1532 LOGEXITFN1("CConnMonSession::CancelAsyncRequest()", err) |
|
1533 return err; |
|
1534 |
|
1535 // It is not possible to cancel other async requests at the moment because they |
|
1536 // are completed right away in the server side. Note. the client's request for a new |
|
1537 // event (EReqReceiveEvent) is cancelled by calling CancelNotifications() |
|
1538 } |
|
1539 |
|
1540 // ----------------------------------------------------------------------------- |
|
1541 // CConnMonSession::ReceiveEventL |
|
1542 // ----------------------------------------------------------------------------- |
|
1543 // |
|
1544 void CConnMonSession::ReceiveEventL( const TAny* aBuffer ) |
|
1545 { |
|
1546 __ASSERT_DEBUG( !iReceiveActive, PanicServer( EReceiveAlreadyActive ) ); |
|
1547 |
|
1548 //LOGIT("SERVER: EReqReceiveEvent") |
|
1549 |
|
1550 if ( !iListening ) |
|
1551 { |
|
1552 // Set status first |
|
1553 iListening = ETrue; |
|
1554 |
|
1555 // Start event notifiers if not already there |
|
1556 iCmServer->Iap()->ListenL(); |
|
1557 |
|
1558 // Want events from now on... |
|
1559 iLastEventTime = iCmServer->EventQueue()->LastEventTime(); |
|
1560 |
|
1561 // Set the threshold to the plugin (to start the plugin events) |
|
1562 if ( iBearerAvailabilityThreshold == 1 ) |
|
1563 { |
|
1564 iBearerAvailabilityThreshold = 0; // To cause a change 0 -> 1 |
|
1565 SetPluginThreshold( EBearerAvailabilityThreshold, 1 ); |
|
1566 } |
|
1567 } |
|
1568 |
|
1569 // Remember the 'receive request' |
|
1570 iReceiveMessage = Message(); |
|
1571 iReceiveBuffer = aBuffer; |
|
1572 iReceiveActive = ETrue; |
|
1573 |
|
1574 // Check for immediate fulfilment |
|
1575 iCmServer->EventQueue()->CheckEvents( this ); |
|
1576 } |
|
1577 |
|
1578 // ----------------------------------------------------------------------------- |
|
1579 // CConnMonSession::CancelReceiveEvent |
|
1580 // ----------------------------------------------------------------------------- |
|
1581 // |
|
1582 void CConnMonSession::CancelReceiveEvent() |
|
1583 { |
|
1584 if ( iReceiveActive ) |
|
1585 { |
|
1586 LOGIT("SERVER: EReqCancelReceiveEvent") |
|
1587 iReceiveMessage.Complete( KErrCancel ); |
|
1588 iReceiveActive = EFalse; |
|
1589 } |
|
1590 |
|
1591 // Stop event watchers (if this is the last session wanting events) |
|
1592 if ( iListening ) |
|
1593 { |
|
1594 // Reset plugin's threshold relating to availability events |
|
1595 // (to stop the plugin events when not needed) |
|
1596 if ( iBearerAvailabilityThreshold == 1 ) |
|
1597 { |
|
1598 SetPluginThreshold( EBearerAvailabilityThreshold, 0 ); |
|
1599 iBearerAvailabilityThreshold = 1; // Restore |
|
1600 } |
|
1601 |
|
1602 // Stop listening |
|
1603 iCmServer->Iap()->CancelListen(); |
|
1604 iListening = EFalse; |
|
1605 } |
|
1606 } |
|
1607 |
|
1608 // ----------------------------------------------------------------------------- |
|
1609 // CConnMonSession::IsListening |
|
1610 // ----------------------------------------------------------------------------- |
|
1611 // |
|
1612 TBool CConnMonSession::IsListening() const |
|
1613 { |
|
1614 return iListening; |
|
1615 } |
|
1616 |
|
1617 // ----------------------------------------------------------------------------- |
|
1618 // CConnMonSession::CanReceiveEvent |
|
1619 // ----------------------------------------------------------------------------- |
|
1620 // |
|
1621 TBool CConnMonSession::CanReceiveEvent() const |
|
1622 { |
|
1623 return iReceiveActive; |
|
1624 } |
|
1625 |
|
1626 // ----------------------------------------------------------------------------- |
|
1627 // CConnMonSession::SendEventToClient |
|
1628 // ----------------------------------------------------------------------------- |
|
1629 // |
|
1630 TBool CConnMonSession::SendEventToClient( const TEvent& aEvent ) |
|
1631 { |
|
1632 if ( aEvent.iTime > iLastEventTime ) |
|
1633 { |
|
1634 // Client wants only new events |
|
1635 iLastEventTime = aEvent.iTime; |
|
1636 |
|
1637 switch ( aEvent.iInfo.iEventType ) |
|
1638 { |
|
1639 case EConnMonDownlinkDataThreshold: |
|
1640 case EConnMonUplinkDataThreshold: |
|
1641 { |
|
1642 TUint threshold( 0 ); |
|
1643 TUint smallestThreshold( 0 ); |
|
1644 CalculateAdjustedThreshold( aEvent.iInfo, threshold, smallestThreshold ); |
|
1645 |
|
1646 if ( ( threshold > 0 ) && ( smallestThreshold > 0 ) ) |
|
1647 { |
|
1648 TUint rounded = smallestThreshold * ( aEvent.iInfo.iData / smallestThreshold ); |
|
1649 if ( ( aEvent.iInfo.iData % smallestThreshold ) > ( smallestThreshold / 2 ) ) |
|
1650 { |
|
1651 rounded += smallestThreshold; |
|
1652 } |
|
1653 if ( rounded % threshold != 0 ) |
|
1654 { |
|
1655 return EFalse; |
|
1656 } |
|
1657 } |
|
1658 else |
|
1659 { |
|
1660 return EFalse; |
|
1661 } |
|
1662 } |
|
1663 break; |
|
1664 |
|
1665 case EConnMonConnectionActivityChange: |
|
1666 { |
|
1667 TConnSettings settings( 0, 0, 0 ); |
|
1668 GetConnectionSettings( aEvent.iInfo.iConnectionId, settings ); |
|
1669 if ( settings.iActivityTimeThreshold == 0 ) |
|
1670 { |
|
1671 return EFalse; |
|
1672 } |
|
1673 } |
|
1674 break; |
|
1675 |
|
1676 case EConnMonBearerAvailabilityChange: |
|
1677 { |
|
1678 if ( iBearerAvailabilityThreshold == 0 ) |
|
1679 { |
|
1680 return EFalse; |
|
1681 } |
|
1682 } |
|
1683 break; |
|
1684 |
|
1685 case EConnMonSignalStrengthChange: |
|
1686 { |
|
1687 if ( iSignalStrengthThreshold == 0 ) |
|
1688 { |
|
1689 return EFalse; |
|
1690 } |
|
1691 } |
|
1692 break; |
|
1693 |
|
1694 case EConnMonBearerInfoChange: |
|
1695 case EConnMonBearerChange: |
|
1696 { |
|
1697 // Send only either EConnMonBearerChange or EConnMonBearerInfoChange event |
|
1698 |
|
1699 if ( iBearerGroupThreshold == 0 && |
|
1700 aEvent.iInfo.iEventType == EConnMonBearerInfoChange ) |
|
1701 { |
|
1702 return EFalse; |
|
1703 } |
|
1704 else if ( iBearerGroupThreshold > 0 && |
|
1705 aEvent.iInfo.iEventType == EConnMonBearerChange ) |
|
1706 { |
|
1707 return EFalse; |
|
1708 } |
|
1709 } |
|
1710 break; |
|
1711 |
|
1712 case EConnMonBearerGroupChange: |
|
1713 { |
|
1714 if ( iBearerGroupThreshold == 0 ) |
|
1715 { |
|
1716 return EFalse; |
|
1717 } |
|
1718 } |
|
1719 break; |
|
1720 |
|
1721 case EConnMonIapAvailabilityChange: |
|
1722 case EConnMonSNAPsAvailabilityChange: |
|
1723 { |
|
1724 if ( aEvent.iExtra.iPtr ) |
|
1725 { |
|
1726 TPtrC8 tempDes( aEvent.iExtra.iPtr, aEvent.iExtra.iSize ); |
|
1727 TConnMonExtraBuf notiBuf( tempDes ); |
|
1728 TInt err = iReceiveMessage.Write( 1, notiBuf ); |
|
1729 if ( err != KErrNone ) |
|
1730 { |
|
1731 iCmServer->PanicClient( EBadDescriptor ); |
|
1732 iReceiveActive = EFalse; |
|
1733 return ETrue; |
|
1734 } |
|
1735 } |
|
1736 } |
|
1737 break; |
|
1738 |
|
1739 default: |
|
1740 break; |
|
1741 } |
|
1742 |
|
1743 // Send the event info to the client |
|
1744 TPtr8 n( (TUint8*) &( aEvent.iInfo ), sizeof( TEventInfo ), sizeof( TEventInfo ) ); |
|
1745 |
|
1746 TInt res = iReceiveMessage.Write( 0, n ); |
|
1747 if ( res != KErrNone ) |
|
1748 { |
|
1749 iCmServer->PanicClient( EBadDescriptor ); |
|
1750 } |
|
1751 else |
|
1752 { |
|
1753 // Complete the message |
|
1754 iReceiveMessage.Complete( KErrNone ); |
|
1755 } |
|
1756 |
|
1757 iReceiveActive = EFalse; |
|
1758 return ETrue; |
|
1759 } |
|
1760 return EFalse; |
|
1761 } |
|
1762 |
|
1763 // ----------------------------------------------------------------------------- |
|
1764 // CConnMonSession::CompleteDataVolumeRequests |
|
1765 // ----------------------------------------------------------------------------- |
|
1766 // |
|
1767 TInt CConnMonSession::CompleteDataVolumeRequests( |
|
1768 const TUint& aConnectionId, |
|
1769 const TUint& aDlVolume, |
|
1770 const TUint& aUlVolume, |
|
1771 const TInt& aStatus ) |
|
1772 { |
|
1773 TInt index( 0 ); |
|
1774 |
|
1775 // Find requests for the current connection |
|
1776 for ( index = 0; index < iConnParams.Count(); index++ ) |
|
1777 { |
|
1778 if ( iConnParams[index].iConnectionId == aConnectionId ) |
|
1779 { |
|
1780 break; |
|
1781 } |
|
1782 } |
|
1783 |
|
1784 if ( index == iConnParams.Count() ) |
|
1785 { |
|
1786 return KErrArgument; |
|
1787 } |
|
1788 |
|
1789 // Send values to the the client |
|
1790 // Loop to find any pending data volume requests on this connection |
|
1791 for ( TInt i = 0; i < iConnParams[index].iRequests.Count(); i++ ) |
|
1792 { |
|
1793 TConnRequest* req = &( iConnParams[index].iRequests[i] ); |
|
1794 TInt err( KErrNone ); |
|
1795 |
|
1796 if ( req->iType == KDownlinkData || req->iType == KUplinkData ) |
|
1797 { |
|
1798 if ( ( aStatus == KErrNone ) || ( aStatus == KErrCancel ) ) |
|
1799 { |
|
1800 if ( req->iType == KDownlinkData ) |
|
1801 { |
|
1802 TPtr8 n( (TUint8*) &aDlVolume, sizeof( TUint ), sizeof( TUint ) ); |
|
1803 |
|
1804 err = req->iMessage.Write( KAttributeParameterIndex, n ); |
|
1805 } |
|
1806 else |
|
1807 { |
|
1808 TPtr8 m( (TUint8*) &aUlVolume, sizeof( TUint ), sizeof( TUint ) ); |
|
1809 |
|
1810 err = req->iMessage.Write( KAttributeParameterIndex, m ); |
|
1811 } |
|
1812 |
|
1813 if ( err != KErrNone ) |
|
1814 { |
|
1815 iCmServer->PanicClient( req->iMessage, EBadDescriptor ); |
|
1816 } |
|
1817 } |
|
1818 |
|
1819 // Complete the request |
|
1820 req->iMessage.Complete( aStatus ); |
|
1821 |
|
1822 // Remove the completed request from the array |
|
1823 iConnParams[index].iRequests.Remove( i ); |
|
1824 i--; |
|
1825 } |
|
1826 } |
|
1827 |
|
1828 return KErrNone; |
|
1829 } |
|
1830 |
|
1831 // ----------------------------------------------------------------------------- |
|
1832 // CConnMonSession::CompleteActivityRequests |
|
1833 // ----------------------------------------------------------------------------- |
|
1834 // |
|
1835 TInt CConnMonSession::CompleteActivityRequests( |
|
1836 const TUint& aConnectionId, |
|
1837 const TBool& aActivity, |
|
1838 const TInt& aStatus ) |
|
1839 { |
|
1840 TInt index( 0 ); |
|
1841 |
|
1842 // Find requests for the current connection |
|
1843 for ( index = 0; index < iConnParams.Count(); index++ ) |
|
1844 { |
|
1845 if ( iConnParams[index].iConnectionId == aConnectionId ) |
|
1846 { |
|
1847 break; |
|
1848 } |
|
1849 } |
|
1850 |
|
1851 if ( index == iConnParams.Count() ) |
|
1852 { |
|
1853 return KErrArgument; |
|
1854 } |
|
1855 |
|
1856 // Send values to the the client |
|
1857 // Loop to find any pending activity requests on this connection |
|
1858 for ( TInt i = 0; i < iConnParams[index].iRequests.Count(); i++ ) |
|
1859 { |
|
1860 TConnRequest* req = &( iConnParams[index].iRequests[i] ); |
|
1861 TInt err( KErrNone ); |
|
1862 |
|
1863 if ( req->iType == KConnectionActive ) |
|
1864 { |
|
1865 if ( aStatus == KErrNone ) |
|
1866 { |
|
1867 TPtr8 n( (TUint8*) &aActivity, sizeof( TBool ), sizeof( TBool ) ); |
|
1868 |
|
1869 err = req->iMessage.Write( KAttributeParameterIndex, n ); |
|
1870 if ( err != KErrNone ) |
|
1871 { |
|
1872 iCmServer->PanicClient( req->iMessage, EBadDescriptor ); |
|
1873 } |
|
1874 } |
|
1875 |
|
1876 // Complete the request |
|
1877 req->iMessage.Complete( aStatus ); |
|
1878 |
|
1879 // Remove the completed request from the array |
|
1880 iConnParams[index].iRequests.Remove( i ); |
|
1881 i--; |
|
1882 } |
|
1883 } |
|
1884 |
|
1885 return KErrNone; |
|
1886 } |
|
1887 |
|
1888 // ----------------------------------------------------------------------------- |
|
1889 // CConnMonSession::SetConnectionSettings |
|
1890 // ----------------------------------------------------------------------------- |
|
1891 // |
|
1892 TInt CConnMonSession::SetConnectionSettings( |
|
1893 const TUint aConnId, |
|
1894 const TConnSettings& aSettings ) |
|
1895 { |
|
1896 if ( aConnId <= KMaxConnectionId ) |
|
1897 { |
|
1898 if ( !IsConnectionValid( aConnId ) ) |
|
1899 { |
|
1900 RemoveConnectionParams( aConnId ); |
|
1901 return KErrNotFound; |
|
1902 } |
|
1903 } |
|
1904 else |
|
1905 { |
|
1906 return KErrArgument; |
|
1907 } |
|
1908 |
|
1909 TConnParams connParams( aConnId ); |
|
1910 TInt index = iConnParams.Find( connParams, TConnParams::MatchId ); |
|
1911 |
|
1912 if ( KErrNotFound == index ) |
|
1913 { |
|
1914 connParams.iSettings = aSettings; |
|
1915 iConnParams.Append( connParams ); |
|
1916 } |
|
1917 else |
|
1918 { |
|
1919 iConnParams[index].iSettings = aSettings; |
|
1920 } |
|
1921 |
|
1922 if ( iListening ) |
|
1923 { |
|
1924 iCmServer->Iap()->WakeUpNotifications( aConnId ); |
|
1925 } |
|
1926 |
|
1927 return KErrNone; |
|
1928 } |
|
1929 |
|
1930 // ----------------------------------------------------------------------------- |
|
1931 // CConnMonSession::GetConnectionSettings |
|
1932 // ----------------------------------------------------------------------------- |
|
1933 // |
|
1934 TInt CConnMonSession::GetConnectionSettings( |
|
1935 const TUint aConnId, |
|
1936 TConnSettings& aSettings ) |
|
1937 { |
|
1938 TInt index( 0 ); |
|
1939 |
|
1940 for ( index = 0; index < iConnParams.Count(); index++ ) |
|
1941 { |
|
1942 if ( iConnParams[index].iConnectionId == aConnId ) |
|
1943 { |
|
1944 break; |
|
1945 } |
|
1946 } |
|
1947 |
|
1948 if ( index < iConnParams.Count() ) |
|
1949 { |
|
1950 aSettings = iConnParams[index].iSettings; |
|
1951 } |
|
1952 else |
|
1953 { |
|
1954 return KErrNotFound; |
|
1955 } |
|
1956 |
|
1957 return KErrNone; |
|
1958 } |
|
1959 |
|
1960 // ----------------------------------------------------------------------------- |
|
1961 // CConnMonSession::SetConnectionRequest |
|
1962 // ----------------------------------------------------------------------------- |
|
1963 // |
|
1964 TInt CConnMonSession::SetConnectionRequest( |
|
1965 const TUint aConnId, |
|
1966 const TConnRequest& aRequest ) |
|
1967 { |
|
1968 if ( !IsConnectionValid( aConnId ) ) |
|
1969 { |
|
1970 RemoveConnectionParams( aConnId ); |
|
1971 return KErrNotFound; |
|
1972 } |
|
1973 |
|
1974 TConnParams connParams( aConnId ); |
|
1975 TInt index = iConnParams.Find( connParams, TConnParams::MatchId ); |
|
1976 |
|
1977 if ( KErrNotFound == index ) |
|
1978 { |
|
1979 connParams.iRequests.Append( aRequest ); |
|
1980 iConnParams.Append( connParams ); |
|
1981 } |
|
1982 else |
|
1983 { |
|
1984 iConnParams[index].iRequests.Append( aRequest ); |
|
1985 } |
|
1986 |
|
1987 return KErrNone; |
|
1988 } |
|
1989 |
|
1990 // ----------------------------------------------------------------------------- |
|
1991 // CConnMonSession::RemoveConnectionParams |
|
1992 // ----------------------------------------------------------------------------- |
|
1993 // |
|
1994 TInt CConnMonSession::RemoveConnectionParams( const TUint aConnId ) |
|
1995 { |
|
1996 TInt index( 0 ); |
|
1997 |
|
1998 for ( index=0; index < iConnParams.Count(); index++ ) |
|
1999 { |
|
2000 if ( iConnParams[index].iConnectionId == aConnId ) |
|
2001 { |
|
2002 break; |
|
2003 } |
|
2004 } |
|
2005 |
|
2006 if ( index == iConnParams.Count() ) |
|
2007 { |
|
2008 return KErrNotFound; |
|
2009 } |
|
2010 else |
|
2011 { |
|
2012 // Complete any outstanding requests on this connection |
|
2013 CompleteDataVolumeRequests( aConnId, 0, 0, KErrDisconnected ); |
|
2014 CompleteActivityRequests( aConnId, EFalse, KErrDisconnected ); |
|
2015 |
|
2016 // Free resources |
|
2017 iConnParams[index].iRequests.Close(); |
|
2018 |
|
2019 // Remove the whole entry |
|
2020 iConnParams.Remove( index ); |
|
2021 } |
|
2022 |
|
2023 return KErrNone; |
|
2024 } |
|
2025 |
|
2026 // ----------------------------------------------------------------------------- |
|
2027 // CConnMonSession::GetBearerThreshold |
|
2028 // ----------------------------------------------------------------------------- |
|
2029 // |
|
2030 TInt CConnMonSession::GetBearerThreshold( |
|
2031 const TInt& aThresholdType, |
|
2032 TUint& aThreshold ) const |
|
2033 { |
|
2034 if ( !iListening ) |
|
2035 { |
|
2036 aThreshold = 0; |
|
2037 return KErrNone; |
|
2038 } |
|
2039 |
|
2040 if ( aThresholdType == EBearerAvailabilityThreshold ) |
|
2041 { |
|
2042 aThreshold = iBearerAvailabilityThreshold; |
|
2043 } |
|
2044 else if ( aThresholdType == ESignalStrengthThreshold ) |
|
2045 { |
|
2046 aThreshold = iSignalStrengthThreshold; |
|
2047 } |
|
2048 else |
|
2049 { |
|
2050 return KErrArgument; |
|
2051 } |
|
2052 |
|
2053 return KErrNone; |
|
2054 } |
|
2055 |
|
2056 // ----------------------------------------------------------------------------- |
|
2057 // CConnMonSession::ServicePluginL |
|
2058 // ----------------------------------------------------------------------------- |
|
2059 // |
|
2060 void CConnMonSession::ServicePluginL( const RMessage2& aMessage ) |
|
2061 { |
|
2062 TInt rc( 0 ); |
|
2063 |
|
2064 if ( !FeatureManager::FeatureSupported( KFeatureIdConnMonExtension ) ) |
|
2065 { |
|
2066 aMessage.Complete( KErrNotSupported ); |
|
2067 LOGIT("SERVER: Plugins are not supported") |
|
2068 return; |
|
2069 } |
|
2070 |
|
2071 switch ( aMessage.Function() ) |
|
2072 { |
|
2073 // CREATE PLUGIN |
|
2074 case EReqPluginCreateSubSession: |
|
2075 { |
|
2076 if ( aMessage.Int0() < EBearerIdGPRS ) |
|
2077 { |
|
2078 aMessage.Complete( KErrArgument ); |
|
2079 } |
|
2080 else |
|
2081 { |
|
2082 NewPluginL( aMessage.Int0() ); |
|
2083 aMessage.Complete( KErrNone ); |
|
2084 LOGIT1("SERVER: Plugin has registered, id %d", aMessage.Int0()) |
|
2085 } |
|
2086 |
|
2087 break; |
|
2088 } |
|
2089 |
|
2090 // DELETE PLUGIN |
|
2091 case EReqPluginCloseSubSession: |
|
2092 { |
|
2093 DeletePlugin( aMessage.Int3() ); |
|
2094 aMessage.Complete( KErrNone ); |
|
2095 |
|
2096 break; |
|
2097 } |
|
2098 |
|
2099 // SERVICE PLUGIN'S REQUEST |
|
2100 default: |
|
2101 { |
|
2102 CPlugin* plugin = PluginFromHandle( aMessage.Int3() ); |
|
2103 |
|
2104 if ( !plugin ) |
|
2105 { |
|
2106 iCmServer->PanicClient( EConnMonBadHandle ); |
|
2107 break; |
|
2108 } |
|
2109 |
|
2110 switch ( aMessage.Function() ) |
|
2111 { |
|
2112 case EReqPluginRegisterAttribute: |
|
2113 { |
|
2114 TUint attribute( aMessage.Int0() ); |
|
2115 |
|
2116 rc = plugin->RegisterAttribute( attribute ); |
|
2117 aMessage.Complete( rc ); |
|
2118 |
|
2119 // Threshold can be set to the plugin only after completing the plugin's request |
|
2120 if ( ( rc == KErrNone ) && ( attribute == KBearerAvailabilityThreshold ) ) |
|
2121 { |
|
2122 plugin->GetQuery(); |
|
2123 } |
|
2124 break; |
|
2125 } |
|
2126 case EReqPluginCancelRegisterAttribute: |
|
2127 { |
|
2128 rc = plugin->CancelRegisterAttribute( aMessage.Int0() ); |
|
2129 aMessage.Complete( rc ); |
|
2130 break; |
|
2131 } |
|
2132 case EReqPluginEvent: |
|
2133 { |
|
2134 TEventInfo eventInfo; |
|
2135 TUint8* ptrData( NULL ); |
|
2136 TInt dataSize( 0 ); |
|
2137 |
|
2138 rc = plugin->Event( aMessage, eventInfo, ptrData, dataSize ); |
|
2139 aMessage.Complete( rc ); |
|
2140 |
|
2141 if ( rc == KErrNone ) |
|
2142 { |
|
2143 // Send the event to the clients |
|
2144 iCmServer->EventQueue()->Add( eventInfo, ptrData, dataSize ); |
|
2145 |
|
2146 LOGIT3("SERVER: EVENT from PLUGIN-> id %d, event %d, data %d", |
|
2147 eventInfo.iConnectionId, eventInfo.iEventType, eventInfo.iData) |
|
2148 |
|
2149 if ( ( eventInfo.iConnectionId == EBearerIdLAN ) && |
|
2150 ( eventInfo.iEventType == EConnMonBearerAvailabilityChange ) ) |
|
2151 { |
|
2152 if ( eventInfo.iData == 1 ) |
|
2153 { |
|
2154 // LAN bearer has become available |
|
2155 // Check if there are any LAN IAPs. |
|
2156 TFullIapInfo* iaps = NULL; |
|
2157 iaps = new( ELeave ) TFullIapInfo; |
|
2158 CleanupStack::PushL( iaps ); |
|
2159 |
|
2160 CIapSupport* iapSupport = CIapSupport::NewL(); |
|
2161 CleanupStack::PushL( iapSupport ); |
|
2162 |
|
2163 iapSupport->GetIapsFromCommDbL( EBearerIdLAN, *iaps ); |
|
2164 |
|
2165 CleanupStack::PopAndDestroy( iapSupport ); |
|
2166 iapSupport = NULL; |
|
2167 |
|
2168 // Show the UI dialog only if there are LAN IAPs in the commDB. |
|
2169 if ( iaps->iCount > 0 ) |
|
2170 { |
|
2171 CUiDialogAO* dialog = NULL; |
|
2172 // Show a dialog on the UI and ask the user to select the |
|
2173 // LAN network. CUiDialog is a one shot active object. It |
|
2174 // will save the user's LAN network preference to ConnMonIap. |
|
2175 // Use TRAPD because all SDKs don't have this dialog that is OK. |
|
2176 TRAPD( leaveCode, dialog = CUiDialogAO::NewL( iCmServer ) ); |
|
2177 |
|
2178 if ( leaveCode == KErrNone ) |
|
2179 { |
|
2180 dialog->Start(); |
|
2181 } |
|
2182 } |
|
2183 CleanupStack::PopAndDestroy( iaps ); |
|
2184 } |
|
2185 else |
|
2186 { |
|
2187 // LAN bearer is not anymore available |
|
2188 |
|
2189 // Reset user's LAN network selection |
|
2190 iCmServer->Iap()->ResetEndUserLanPreference(); |
|
2191 |
|
2192 LOGIT("CConnMonSession::ServicePluginL triggered HandleAvailabilityChange()") |
|
2193 |
|
2194 ( (CConnMonServer*)Server() )->AvailabilityManager() |
|
2195 ->HandleAvailabilityChange(); |
|
2196 } |
|
2197 } |
|
2198 } |
|
2199 break; |
|
2200 } |
|
2201 case EReqPluginGetQuery: |
|
2202 { |
|
2203 rc = plugin->GetQuery( aMessage ); |
|
2204 |
|
2205 // This will be completed later by the CPlugin object |
|
2206 break; |
|
2207 } |
|
2208 case EReqPluginCancelGetQuery: |
|
2209 { |
|
2210 rc = plugin->CancelGetQuery(); |
|
2211 aMessage.Complete( rc ); |
|
2212 break; |
|
2213 } |
|
2214 case EReqPluginAttribute: |
|
2215 { |
|
2216 rc = plugin->Attribute( aMessage ); |
|
2217 aMessage.Complete( rc ); |
|
2218 break; |
|
2219 } |
|
2220 |
|
2221 default: |
|
2222 break; |
|
2223 } |
|
2224 } |
|
2225 } |
|
2226 } |
|
2227 |
|
2228 // ----------------------------------------------------------------------------- |
|
2229 // CConnMonSession::PluginFromHandle |
|
2230 // Will return NULL if parameter aHandle is invalid |
|
2231 // ----------------------------------------------------------------------------- |
|
2232 // |
|
2233 CPlugin* CConnMonSession::PluginFromHandle( const TUint aHandle ) |
|
2234 { |
|
2235 CPlugin* plugin = reinterpret_cast<CPlugin*>( iPlugins->At( aHandle ) ); |
|
2236 return plugin; |
|
2237 } |
|
2238 |
|
2239 // ----------------------------------------------------------------------------- |
|
2240 // CConnMonSession::NewPluginL |
|
2241 // ----------------------------------------------------------------------------- |
|
2242 // |
|
2243 void CConnMonSession::NewPluginL( const TUint aConnectionId ) |
|
2244 { |
|
2245 // Create a new plugin object |
|
2246 CPlugin* plugin = CPlugin::NewL( this, aConnectionId ); |
|
2247 |
|
2248 // Ensure that the reference count is decremented if we leave. |
|
2249 // When ref count becomes zero, CObject::Close() deletes the object. |
|
2250 CleanupClosePushL( *plugin ); |
|
2251 |
|
2252 // Add object to object container to generate unique id |
|
2253 iContainer->AddL( ( CObject* ) plugin ); |
|
2254 |
|
2255 // Add object to object index; this returns a unique handle |
|
2256 TInt handle = iPlugins->AddL( ( CObject* ) plugin ); |
|
2257 |
|
2258 // Object is now owned by this session, reference count is correct. |
|
2259 CleanupStack::Pop( plugin ); |
|
2260 |
|
2261 // Write the handle to the client |
|
2262 TPckg<TInt> handlePckg( handle ); |
|
2263 |
|
2264 TInt res = Message().Write( KAttributeParameterIndex, handlePckg ); |
|
2265 |
|
2266 if ( res != KErrNone ) |
|
2267 { |
|
2268 // Removes from object index and destroys the object |
|
2269 iPlugins->Remove( handle ); |
|
2270 |
|
2271 iCmServer->PanicClient( EBadDescriptor ); |
|
2272 return; |
|
2273 } |
|
2274 } |
|
2275 |
|
2276 // ----------------------------------------------------------------------------- |
|
2277 // CConnMonSession::DeletePlugin |
|
2278 // ----------------------------------------------------------------------------- |
|
2279 // |
|
2280 void CConnMonSession::DeletePlugin( const TUint aHandle ) |
|
2281 { |
|
2282 CPlugin* plugin = reinterpret_cast<CPlugin*>( iPlugins->At( aHandle ) ); |
|
2283 |
|
2284 if ( !plugin ) |
|
2285 { |
|
2286 iCmServer->PanicClient( EConnMonBadHandle ); |
|
2287 } |
|
2288 else |
|
2289 { |
|
2290 // Removes from object index and destroys the object |
|
2291 iPlugins->Remove( aHandle ); |
|
2292 } |
|
2293 } |
|
2294 |
|
2295 // ----------------------------------------------------------------------------- |
|
2296 // CConnMonSession::SendRequestToPlugin |
|
2297 // ----------------------------------------------------------------------------- |
|
2298 // |
|
2299 TInt CConnMonSession::SendRequestToPlugin( const TInt aType, const RMessage2& aMessage ) |
|
2300 { |
|
2301 //LOGENTRFN("CConnMonSession::SendRequestToPlugin()") |
|
2302 TInt ret( KErrNotSupported ); |
|
2303 |
|
2304 TInt count = iPlugins->ActiveCount(); |
|
2305 |
|
2306 for ( TInt i = 0; i < count; i++ ) |
|
2307 { |
|
2308 CPlugin* plugin = reinterpret_cast<CPlugin*>( ( *iPlugins )[i] ); |
|
2309 |
|
2310 if ( plugin ) |
|
2311 { |
|
2312 if ( aType == EReqGetIntAttribute || |
|
2313 aType == EReqGetUintAttribute || |
|
2314 aType == EReqGetBoolAttribute || |
|
2315 aType == EReqGetStringAttribute || |
|
2316 aType == EReqGetPckgAttribute ) |
|
2317 { |
|
2318 ret = plugin->GetAttributeForClient( aType, aMessage ); |
|
2319 |
|
2320 // Asynchronous |
|
2321 if ( ret == KRequestPending ) |
|
2322 { |
|
2323 return ret; |
|
2324 } |
|
2325 } |
|
2326 else if ( aType == EReqSetIntAttribute || |
|
2327 aType == EReqSetUintAttribute || |
|
2328 aType == EReqSetBoolAttribute || |
|
2329 aType == EReqSetStringAttribute || |
|
2330 aType == EReqSetPckgAttribute || |
|
2331 aType == EReqInternalSetThreshold || |
|
2332 aType == EReqInternalResetThreshold ) |
|
2333 { |
|
2334 ret = plugin->SetAttributeForClient( aType, aMessage ); |
|
2335 |
|
2336 // Synchronous |
|
2337 if ( ret == KErrNone ) |
|
2338 { |
|
2339 return ret; |
|
2340 } |
|
2341 } |
|
2342 else |
|
2343 { |
|
2344 return KErrNotSupported; |
|
2345 } |
|
2346 } |
|
2347 } |
|
2348 |
|
2349 //LOGEXITFN("CConnMonSession::SendRequestToPlugin()") |
|
2350 return ret; |
|
2351 } |
|
2352 |
|
2353 // ----------------------------------------------------------------------------- |
|
2354 // CConnMonSession::CancelAttributeRequestFromPlugin |
|
2355 // ----------------------------------------------------------------------------- |
|
2356 // |
|
2357 void CConnMonSession::CancelAttributeRequestFromPlugin( |
|
2358 const RThread& aClient, |
|
2359 const TInt aType ) |
|
2360 { |
|
2361 TInt count = iPlugins->ActiveCount(); |
|
2362 |
|
2363 for ( TInt i = 0; i < count; i++ ) |
|
2364 { |
|
2365 CPlugin* plugin = reinterpret_cast<CPlugin*>( ( *iPlugins )[i] ); |
|
2366 |
|
2367 if ( plugin ) |
|
2368 { |
|
2369 plugin->CancelGetAttributeForClient( aClient, aType ); |
|
2370 } |
|
2371 } |
|
2372 } |
|
2373 |
|
2374 // ----------------------------------------------------------------------------- |
|
2375 // CConnMonSession::SetPluginThreshold |
|
2376 // ----------------------------------------------------------------------------- |
|
2377 // |
|
2378 TInt CConnMonSession::SetPluginThreshold( const TInt aType, const TUint aValue ) |
|
2379 { |
|
2380 TUint globalThBefore( 0 ); |
|
2381 TUint globalThAfter( 0 ); |
|
2382 TUint connectionId( 0 ); |
|
2383 TBool internal( EFalse ); |
|
2384 |
|
2385 if ( !FeatureManager::FeatureSupported( KFeatureIdConnMonExtension ) ) |
|
2386 { |
|
2387 return KErrNotSupported; |
|
2388 } |
|
2389 |
|
2390 if ( aType != EBearerAvailabilityThreshold && aType != ESignalStrengthThreshold ) |
|
2391 { |
|
2392 return KErrNotSupported; |
|
2393 } |
|
2394 |
|
2395 // At the moment a common threshold is used for all the bearers. |
|
2396 // When 'internal' is true threshold will be set in every plugin. |
|
2397 internal = ETrue; |
|
2398 |
|
2399 // Get the global threshold before changing session threshold |
|
2400 iCmServer->CalculateThreshold( connectionId, aType, globalThBefore ); |
|
2401 |
|
2402 if ( aType == EBearerAvailabilityThreshold ) |
|
2403 { |
|
2404 // Set the new threshold value |
|
2405 iBearerAvailabilityThreshold = aValue; |
|
2406 } |
|
2407 else if ( aType == ESignalStrengthThreshold ) |
|
2408 { |
|
2409 // Set the new threshold value |
|
2410 iSignalStrengthThreshold = aValue; |
|
2411 } |
|
2412 |
|
2413 // Get the global threshold after changing our threshold |
|
2414 iCmServer->CalculateThreshold( connectionId, aType, globalThAfter ); |
|
2415 |
|
2416 if ( globalThBefore != globalThAfter ) |
|
2417 { |
|
2418 // Global threshold has changed -> send to plug-in engines |
|
2419 if ( internal ) |
|
2420 { |
|
2421 if ( aValue == 1 ) |
|
2422 { |
|
2423 iCmServer->SendRequestToPlugin( EReqInternalSetThreshold, Message(), ETrue ); |
|
2424 } |
|
2425 else |
|
2426 { |
|
2427 iCmServer->SendRequestToPlugin( EReqInternalResetThreshold, Message(), ETrue ); |
|
2428 } |
|
2429 } |
|
2430 else |
|
2431 { |
|
2432 iCmServer->SendRequestToPlugin( EReqSetUintAttribute, Message(), ETrue ); |
|
2433 } |
|
2434 } |
|
2435 |
|
2436 return KErrNone; |
|
2437 } |
|
2438 |
|
2439 // ----------------------------------------------------------------------------- |
|
2440 // CConnMonSession::IsConnectionValid |
|
2441 // ----------------------------------------------------------------------------- |
|
2442 // |
|
2443 TBool CConnMonSession::IsConnectionValid( const TUint aConnId ) |
|
2444 { |
|
2445 LOGENTRFN("CConnMonSession::IsConnectionValid()") |
|
2446 TBool result( EFalse ); |
|
2447 |
|
2448 // Is connection valid anymore |
|
2449 TUint subConnectionCount( 0 ); |
|
2450 TInt err = iCmServer->Iap()->GetConnectionInfo( aConnId, subConnectionCount ); |
|
2451 if ( err != KErrNone ) |
|
2452 { |
|
2453 result = EFalse; |
|
2454 } |
|
2455 else |
|
2456 { |
|
2457 result = ETrue; |
|
2458 } |
|
2459 |
|
2460 LOGEXITFN1("CConnMonSession::IsConnectionValid()", result) |
|
2461 return result; |
|
2462 } |
|
2463 |
|
2464 // ----------------------------------------------------------------------------- |
|
2465 // CConnMonSession::RemoveObsoleteConnectionParams |
|
2466 // ----------------------------------------------------------------------------- |
|
2467 // |
|
2468 void CConnMonSession::RemoveObsoleteConnectionParams() |
|
2469 { |
|
2470 TInt numSettings = iConnParams.Count(); |
|
2471 if ( numSettings > 0 ) |
|
2472 { |
|
2473 TInt i( 0 ); |
|
2474 do |
|
2475 { |
|
2476 if ( !IsConnectionValid( iConnParams[i].iConnectionId ) ) |
|
2477 { |
|
2478 // Complete any outstanding requests on this connection |
|
2479 CompleteDataVolumeRequests( |
|
2480 iConnParams[i].iConnectionId, |
|
2481 0, |
|
2482 0, |
|
2483 KErrDisconnected ); |
|
2484 |
|
2485 CompleteActivityRequests( |
|
2486 iConnParams[i].iConnectionId, |
|
2487 EFalse, |
|
2488 KErrDisconnected ); |
|
2489 |
|
2490 // Free resources |
|
2491 iConnParams[i].iRequests.Close(); |
|
2492 |
|
2493 // Remove the whole entry |
|
2494 iConnParams.Remove( i ); |
|
2495 numSettings = iConnParams.Count(); |
|
2496 } |
|
2497 else |
|
2498 { |
|
2499 ++i; |
|
2500 } |
|
2501 |
|
2502 } while ( i < numSettings ); |
|
2503 } |
|
2504 } |
|
2505 |
|
2506 // ----------------------------------------------------------------------------- |
|
2507 // CConnMonSession::CalculateAdjustedThreshold |
|
2508 // ----------------------------------------------------------------------------- |
|
2509 // |
|
2510 TInt CConnMonSession::CalculateAdjustedThreshold( |
|
2511 const TEventInfo& aEvent, |
|
2512 TUint& aAdjustedTh, |
|
2513 TUint& aSmallestTh ) |
|
2514 { |
|
2515 TConnSettings settings( 0, 0, 0 ); |
|
2516 TUint modulo( 0 ); |
|
2517 |
|
2518 aAdjustedTh = 0; |
|
2519 GetConnectionSettings( aEvent.iConnectionId, settings ); |
|
2520 |
|
2521 if ( aEvent.iEventType == EConnMonDownlinkDataThreshold ) |
|
2522 { |
|
2523 iCmServer->CalculateThreshold( |
|
2524 aEvent.iConnectionId, |
|
2525 EDownlinkThreshold, |
|
2526 aSmallestTh ); |
|
2527 |
|
2528 if ( aSmallestTh > 0 ) |
|
2529 { |
|
2530 modulo = settings.iDLDataThreshold % aSmallestTh; |
|
2531 } |
|
2532 |
|
2533 if ( modulo == 0 ) |
|
2534 { |
|
2535 aAdjustedTh = settings.iDLDataThreshold; |
|
2536 } |
|
2537 else if ( modulo < aSmallestTh / 2 ) |
|
2538 { |
|
2539 aAdjustedTh = settings.iDLDataThreshold - modulo; |
|
2540 } |
|
2541 else |
|
2542 { |
|
2543 aAdjustedTh = settings.iDLDataThreshold + aSmallestTh - modulo; |
|
2544 } |
|
2545 } |
|
2546 else if ( aEvent.iEventType == EConnMonUplinkDataThreshold ) |
|
2547 { |
|
2548 iCmServer->CalculateThreshold( |
|
2549 aEvent.iConnectionId, |
|
2550 EUplinkThreshold, |
|
2551 aSmallestTh ); |
|
2552 |
|
2553 if ( aSmallestTh > 0 ) |
|
2554 { |
|
2555 modulo = settings.iULDataThreshold % aSmallestTh; |
|
2556 } |
|
2557 |
|
2558 if ( modulo == 0 ) |
|
2559 { |
|
2560 aAdjustedTh = settings.iULDataThreshold; |
|
2561 } |
|
2562 else if ( modulo < aSmallestTh / 2 ) |
|
2563 { |
|
2564 aAdjustedTh = settings.iULDataThreshold - modulo; |
|
2565 } |
|
2566 else |
|
2567 { |
|
2568 aAdjustedTh = settings.iULDataThreshold + aSmallestTh - modulo; |
|
2569 } |
|
2570 } |
|
2571 else |
|
2572 { |
|
2573 return KErrArgument; |
|
2574 } |
|
2575 |
|
2576 return KErrNone; |
|
2577 } |
|
2578 |
|
2579 // ----------------------------------------------------------------------------- |
|
2580 // CConnMonSession::AdjustThresholdToAllowedRange |
|
2581 // ----------------------------------------------------------------------------- |
|
2582 // |
|
2583 TInt CConnMonSession::AdjustThresholdToAllowedRange( |
|
2584 const TInt& aConnId, |
|
2585 const TInt& aThresholdType, |
|
2586 TUint& aThreshold ) const |
|
2587 { |
|
2588 LOGENTRFN("CConnMonSession::AdjustThresholdToAllowedRange()") |
|
2589 TInt err( KErrNone ); |
|
2590 |
|
2591 // Zero value is always allowed |
|
2592 if ( aThreshold == 0 ) |
|
2593 { |
|
2594 LOGEXITFN1("CConnMonSession::AdjustThresholdToAllowedRange()", err) |
|
2595 return err; |
|
2596 } |
|
2597 |
|
2598 switch ( aThresholdType ) |
|
2599 { |
|
2600 case KActivityTimeThreshold: |
|
2601 // Already checked for zero earlier |
|
2602 if ( aThreshold < KMinimumActivityThreshold ) |
|
2603 { |
|
2604 aThreshold = KMinimumActivityThreshold; |
|
2605 } |
|
2606 break; |
|
2607 |
|
2608 // Currently same minimum threshold values for both uplink and downlink |
|
2609 case KDownlinkDataThreshold: |
|
2610 case KUplinkDataThreshold: |
|
2611 { |
|
2612 TInt bearer( EBearerUnknown ); |
|
2613 TBearerInfo bearerInfo; |
|
2614 TUint minimum( KMinimumDataThreshold ); |
|
2615 |
|
2616 // This method gets the bearer only for an internal connection. This is OK |
|
2617 // since data volume events are not supported for external connections. |
|
2618 iCmServer->Iap()->GetBearer( aConnId, bearer, bearerInfo ); |
|
2619 |
|
2620 // Set minimum |
|
2621 if ( bearer == EBearerWLAN || bearer == EBearerLAN ) |
|
2622 { |
|
2623 minimum = KMinimumWLANDataThreshold; |
|
2624 } |
|
2625 else if ( bearer == EBearerGPRS || bearer == EBearerEdgeGPRS ) |
|
2626 { |
|
2627 minimum = KMinimumGPRSDataThreshold; |
|
2628 } |
|
2629 else if ( bearer == EBearerWCDMA ) |
|
2630 { |
|
2631 minimum = KMinimumWCDMADataThreshold; |
|
2632 } |
|
2633 |
|
2634 // Check threshold |
|
2635 if ( aThreshold < minimum ) |
|
2636 { |
|
2637 aThreshold = minimum; |
|
2638 } |
|
2639 } |
|
2640 break; |
|
2641 |
|
2642 case KBearerAvailabilityThreshold: |
|
2643 case KSignalStrengthThreshold: |
|
2644 case KBearerGroupThreshold: |
|
2645 // All alowed |
|
2646 break; |
|
2647 default: |
|
2648 LOGIT1("AdjustThresholdToAllowedRange: Illegal value for threshold type %d", aThresholdType) |
|
2649 err = KErrNotFound; |
|
2650 break; |
|
2651 } |
|
2652 |
|
2653 LOGEXITFN1("CConnMonSession::AdjustThresholdToAllowedRange()", err) |
|
2654 return err; |
|
2655 } |
|
2656 |
|
2657 // End-of-file |