|
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: Core functionality for ConnMon. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <mmtsy_names.h> |
|
19 #include <featmgr.h> |
|
20 #include <rmmcustomapi.h> |
|
21 #include <utf.h> |
|
22 #include <es_sock_partner.h> |
|
23 |
|
24 #include "ConnMonServ.h" |
|
25 #include "ConnMonSess.h" |
|
26 #include "CEventQueue.h" |
|
27 #include "CCsdFax.h" |
|
28 #include "CPsdFax.h" |
|
29 #include "ConnMonIAP.h" |
|
30 #include "ConnMonNoti.h" |
|
31 #include "CDataVolume.h" |
|
32 #include "connmondtmnoti.h" |
|
33 #include "connmontelnoti.h" |
|
34 #include "ConnMonBearerNotifier.h" |
|
35 #include "log.h" |
|
36 |
|
37 // ============================ MEMBER FUNCTIONS =============================== |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // TConnInfo::TConnInfo |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 TConnInfo::TConnInfo( |
|
44 TInt aIapId, |
|
45 TInt aNetId, |
|
46 TUint aConnectionId, |
|
47 TInt aBearer, |
|
48 TBearerInfo aBearerInfo ) |
|
49 : |
|
50 iIapId( aIapId ), |
|
51 iNetId( aNetId ), |
|
52 iConnectionId( aConnectionId ), |
|
53 iBearer( aBearer ), |
|
54 iConnAttach( 0 ), |
|
55 iProgressNotifier( 0 ), |
|
56 iDLDataNotifier( 0 ), |
|
57 iULDataNotifier( 0 ), |
|
58 iDataVolumeAO( 0 ), |
|
59 iConnDownNotifier( 0 ), |
|
60 iActivityNotifier( 0 ), |
|
61 iActivity( 0 ), |
|
62 iBearerInfo( aBearerInfo ), |
|
63 iBearerNotifier( 0 ) |
|
64 { |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // TConnInfo::Reset |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 void TConnInfo::Reset() |
|
72 { |
|
73 // Only call this function to initialize a newly created TConnInfo-object. |
|
74 // (There is no cleanup) |
|
75 iIapId = 0; |
|
76 iNetId = 0; |
|
77 iConnectionId = 0; |
|
78 iBearer = EBearerUnknown; |
|
79 iBearerInfo.iBearer = EBearerInfoUnknown; |
|
80 iBearerInfo.iInternal = ETrue; |
|
81 iProgressNotifier = 0; |
|
82 iDLDataNotifier = 0; |
|
83 iULDataNotifier = 0; |
|
84 iDataVolumeAO = 0; |
|
85 iConnAttach = 0; |
|
86 iConnDownNotifier = 0; |
|
87 iActivityNotifier = 0; |
|
88 iActivity = 0; |
|
89 iBearerNotifier = 0; |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // TConnInfo::Compare |
|
94 // Compares two TConnInfo items (by connection id). |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 TInt TConnInfo::Compare( const TConnInfo& aFirst, const TConnInfo& aSecond ) |
|
98 { |
|
99 if ( aFirst.iConnectionId < aSecond.iConnectionId ) |
|
100 { |
|
101 return -1; |
|
102 } |
|
103 |
|
104 if ( aFirst.iConnectionId > aSecond.iConnectionId ) |
|
105 { |
|
106 return 1; |
|
107 } |
|
108 return 0; |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // TConnInfo::MatchId |
|
113 // Finds TConnInfo item matching by connection Id. |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 TBool TConnInfo::MatchId( const TConnInfo& aFirst, const TConnInfo& aSecond ) |
|
117 { |
|
118 if ( aFirst.iConnectionId == aSecond.iConnectionId ) |
|
119 { |
|
120 return ETrue; |
|
121 } |
|
122 return EFalse; |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // TConnInfo::MatchIap |
|
127 // Finds TConnInfo item matching by iap id and net id. |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 TBool TConnInfo::MatchIap( const TConnInfo& aFirst, const TConnInfo& aSecond ) |
|
131 { |
|
132 // Only internal bearers can be matched by IapId and NetId |
|
133 if ( ( aFirst.iIapId == aSecond.iIapId ) && ( aFirst.iNetId == aSecond.iNetId ) && |
|
134 ( aFirst.iBearer < EBearerExternalCSD ) && ( aSecond.iBearer < EBearerExternalCSD ) && |
|
135 ( aFirst.iBearerInfo.iInternal ) && ( aSecond.iBearerInfo.iInternal ) ) |
|
136 { |
|
137 return ETrue; |
|
138 } |
|
139 |
|
140 return EFalse; |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // TConnInfo::MatchBearer |
|
145 // Finds TConnInfo item matching by bearer. |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 TBool TConnInfo::MatchBearer( const TConnInfo& aFirst, const TConnInfo& aSecond ) |
|
149 { |
|
150 // External CSD bearers (there is no event availabe for bearer change) |
|
151 if ( ( aFirst.iBearer == EBearerExternalCSD || aFirst.iBearer == EBearerExternalHSCSD || |
|
152 aFirst.iBearer == EBearerExternalWcdmaCSD ) |
|
153 && |
|
154 ( aSecond.iBearer == EBearerExternalCSD || aSecond.iBearer == EBearerExternalHSCSD || |
|
155 aSecond.iBearer == EBearerExternalWcdmaCSD ) ) |
|
156 { |
|
157 return ETrue; |
|
158 } |
|
159 |
|
160 // External PSD bearers (there is not always an event availabe for bearer change) |
|
161 else if ( ( aFirst.iBearer == EBearerExternalGPRS || |
|
162 aFirst.iBearer == EBearerExternalEdgeGPRS || |
|
163 aFirst.iBearer == EBearerExternalWCDMA || |
|
164 aFirst.iBearer == EBearerExternalCDMA2000 || |
|
165 ( !aFirst.iBearerInfo.iInternal && |
|
166 ( aFirst.iBearerInfo.iBearer == EBearerInfoHSDPA || |
|
167 aFirst.iBearerInfo.iBearer == EBearerInfoHSUPA || |
|
168 aFirst.iBearerInfo.iBearer == EBearerInfoHSxPA ) ) ) |
|
169 && |
|
170 ( aSecond.iBearer == EBearerExternalGPRS || |
|
171 aSecond.iBearer == EBearerExternalEdgeGPRS || |
|
172 aSecond.iBearer == EBearerExternalWCDMA || |
|
173 aSecond.iBearer == EBearerExternalCDMA2000 || |
|
174 ( !aSecond.iBearerInfo.iInternal && |
|
175 ( aSecond.iBearerInfo.iBearer == EBearerInfoHSDPA || |
|
176 aSecond.iBearerInfo.iBearer == EBearerInfoHSUPA || |
|
177 aSecond.iBearerInfo.iBearer == EBearerInfoHSxPA ) ) ) ) |
|
178 |
|
179 { |
|
180 return ETrue; |
|
181 } |
|
182 |
|
183 // Other bearers |
|
184 else if ( aFirst.iBearer == aSecond.iBearer && |
|
185 aFirst.iBearerInfo.iBearer == aSecond.iBearerInfo.iBearer ) |
|
186 { |
|
187 return ETrue; |
|
188 } |
|
189 else |
|
190 { |
|
191 return EFalse; |
|
192 } |
|
193 } |
|
194 |
|
195 // ============================ MEMBER FUNCTIONS =============================== |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // CConnMonIAP::CConnMonIAP |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 CConnMonIAP::CConnMonIAP( CConnMonServer* aServer ) |
|
202 : |
|
203 iServer( aServer ), |
|
204 iEndUserNetIds( KNullDesC8 ) |
|
205 { |
|
206 } |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // CConnMonIAP::ConstructL |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 void CConnMonIAP::ConstructL() |
|
213 { |
|
214 LOGENTRFN("CConnMonIAP::ConstructL()") |
|
215 TInt err( KErrNone ); |
|
216 |
|
217 // Connect to socket server and use system global pool (-1) for message slots. |
|
218 User::LeaveIfError( iSocketServer.Connect( static_cast<TUint>( -1 ) ) ); |
|
219 LOGIT("(01/11) Loaded OK: ESock") |
|
220 |
|
221 // Open RConnection. This object is not attached to any connection |
|
222 User::LeaveIfError( iConnection.Open( iSocketServer ) ); |
|
223 LOGIT("(02/11) Opened OK: RConnection") |
|
224 |
|
225 // Connect to ETel server |
|
226 TBuf<KCommsDbSvrMaxColumnNameLength> tsyName; |
|
227 tsyName.Copy( KMmTsyModuleName ); |
|
228 |
|
229 // The RTelServer::Connect() might not always work with the first trial, |
|
230 // because of a coding error related to using semaphores in the method. |
|
231 for ( TInt a = 0; a < KPhoneRetryCount; a++ ) |
|
232 { |
|
233 err = iTelServer.Connect(); |
|
234 if ( KErrNone == err ) |
|
235 { |
|
236 break; |
|
237 } |
|
238 User::After( KPhoneRetryTimeout ); |
|
239 LOGIT("RTelServer::Connect() failed, trying again.") |
|
240 } |
|
241 User::LeaveIfError( err ); |
|
242 LOGIT("(03/11) Loaded OK: ETel") |
|
243 |
|
244 // Initialize FeatureManager |
|
245 FeatureManager::InitializeLibL(); |
|
246 LOGIT("(04/11) Loaded OK: FeatureManager") |
|
247 |
|
248 // Try to load tsy |
|
249 err = iTelServer.LoadPhoneModule( tsyName ); |
|
250 if ( KErrNone == err ) |
|
251 { |
|
252 LOGIT("(05/11) Loaded OK: TSY") |
|
253 iTSYLoaded = 1; |
|
254 |
|
255 // Phone info can be retrieved with value 0 if there is only one phone |
|
256 RTelServer::TPhoneInfo info; |
|
257 User::LeaveIfError( iTelServer.GetPhoneInfo( 0, info ) ); |
|
258 LOGIT("(06/11) Loaded OK: Phone info") |
|
259 |
|
260 User::LeaveIfError( iMobilePhone.Open( iTelServer, info.iName ) ); |
|
261 LOGIT("(07/11) Opened OK: RMobilePhone") |
|
262 |
|
263 // Open packet service |
|
264 err = iPacketService.Open( iMobilePhone ); |
|
265 if ( KErrNone == err ) |
|
266 { |
|
267 LOGIT("(08/11) Loaded OK: Packet service") |
|
268 iPacketServLoaded = 1; |
|
269 |
|
270 // CDMA network does not support external connections. PSD Fax handler module |
|
271 // should not be created when in CDMA network. The code below works OK as long |
|
272 // as there is no phone that supports both CDMA and GSM at the same time. |
|
273 if ( !FeatureManager::FeatureSupported( KFeatureIdProtocolCdma ) ) |
|
274 { |
|
275 // Create PSD Fax handler module |
|
276 iPsdFax = new( ELeave ) CPsdFax( |
|
277 iServer, |
|
278 &iTelServer, |
|
279 &iMobilePhone, |
|
280 &iPacketService ); |
|
281 iPsdFax->ConstructL(); |
|
282 LOGIT("(09/11) Loaded OK: PSD module") |
|
283 } |
|
284 else |
|
285 { |
|
286 LOGIT("(09/11) Nosupport: PSD module not loaded, no PSD support in CDMA networks.") |
|
287 } |
|
288 } |
|
289 else |
|
290 { |
|
291 LOGIT1("(08/11) Loaderror: Packet service failed with code <%d>", err) |
|
292 } |
|
293 |
|
294 // CDMA network does not support external connections. CSD Fax handler module |
|
295 // should not be created when in CDMA network. The code below works OK as long |
|
296 // as there is no phone that supports both CDMA and GSM at the same time. |
|
297 if ( !FeatureManager::FeatureSupported( KFeatureIdProtocolCdma ) ) |
|
298 { |
|
299 // Create CSD Fax handler module |
|
300 iCsdFax = new( ELeave ) CCsdFax( iServer, &iTelServer, &iMobilePhone ); |
|
301 iCsdFax->ConstructL(); |
|
302 LOGIT("(10/11) Loaded OK: CSD module") |
|
303 } |
|
304 else |
|
305 { |
|
306 LOGIT("(10/11) Nosupport: CSD module not loaded, no CSD support in CDMA networks") |
|
307 } |
|
308 } |
|
309 else |
|
310 { |
|
311 LOGIT1("(05/11) Loaderror: TSY failed with code <%d>", err) |
|
312 } |
|
313 |
|
314 // Open WLAN Management service |
|
315 if ( FeatureManager::FeatureSupported( KFeatureIdProtocolWlan ) ) |
|
316 { |
|
317 TRAPD( leaveCode, iWlanSupport = CWlanSupport::NewL( iServer ) ); |
|
318 if ( KErrNone != leaveCode ) |
|
319 { |
|
320 LOGIT1("(11/11) Loaderror: WLAN module failed with code <%d>", leaveCode) |
|
321 } |
|
322 else |
|
323 { |
|
324 LOGIT("(11/11) Loaded OK: WLAN module") |
|
325 } |
|
326 } |
|
327 else |
|
328 { |
|
329 LOGIT("(11/11) Nosupport: WLAN module not loaded, no WLAN support detected") |
|
330 } |
|
331 |
|
332 LOGEXITFN("CConnMonIAP::ConstructL()") |
|
333 } |
|
334 |
|
335 // ----------------------------------------------------------------------------- |
|
336 // CConnMonIAP::~CConnMonIAP |
|
337 // ----------------------------------------------------------------------------- |
|
338 // |
|
339 // Destructor |
|
340 CConnMonIAP::~CConnMonIAP() |
|
341 { |
|
342 LOGENTRFN("CConnMonIAP::~CConnMonIAP()") |
|
343 // Delele dial up modules. |
|
344 delete iCsdFax; |
|
345 iCsdFax = NULL; |
|
346 |
|
347 delete iPsdFax; |
|
348 iPsdFax = NULL; |
|
349 |
|
350 // Delete global notifications. This must be called before |
|
351 // services are closed or destroyed below. |
|
352 DeleteNotifications(); |
|
353 |
|
354 // Delete connection up/down notification. |
|
355 if ( iConnUpDownNotifier != 0 ) |
|
356 { |
|
357 iConnUpDownNotifier->Cancel(); |
|
358 delete iConnUpDownNotifier; |
|
359 } |
|
360 |
|
361 // Close all attached connections |
|
362 TInt count = iConnInfos.Count(); |
|
363 |
|
364 for ( TInt i = 0; i < count; i++ ) |
|
365 { |
|
366 if ( iConnInfos[i].iConnAttach != 0 ) |
|
367 { |
|
368 iConnInfos[i].iConnAttach->Close(); |
|
369 delete iConnInfos[i].iConnAttach; |
|
370 } |
|
371 } |
|
372 |
|
373 // Note. all sessions have closed by now. |
|
374 // There is no need to delete connection parameters |
|
375 // because session destructors have already done that. |
|
376 iConnInfos.Close(); |
|
377 |
|
378 // Close "global" ESOCK objects |
|
379 iConnection.Close(); |
|
380 iSocketServer.Close(); |
|
381 |
|
382 // Close "global" ETEL objects |
|
383 if ( iPacketServLoaded == 1 ) |
|
384 { |
|
385 iPacketService.Close(); |
|
386 } |
|
387 |
|
388 iMobilePhone.Close(); |
|
389 iTelServer.Close(); |
|
390 |
|
391 // Unload FeatureManager |
|
392 FeatureManager::UnInitializeLib(); |
|
393 |
|
394 // Destroy WLAN service |
|
395 delete iWlanSupport; |
|
396 iWlanSupport = NULL; |
|
397 |
|
398 // Reset global pointers |
|
399 iServer = NULL; |
|
400 iPsdNetwStatusNotifier = NULL; |
|
401 iNetwRegistrationNotifier = NULL; |
|
402 iEdgeNotifier = NULL; |
|
403 iWcdmaNotifier = NULL; |
|
404 iModeNotifier = NULL; |
|
405 iGSMSignalNotifier = NULL; |
|
406 iGSMBearerAvailabilityNotifier = NULL; |
|
407 |
|
408 // Clean up all ECom sessions |
|
409 // More info about it: TSW EGUO-64LD36 |
|
410 REComSession::FinalClose(); |
|
411 LOGEXITFN("CConnMonIAP::~CConnMonIAP()") |
|
412 } |
|
413 |
|
414 // ----------------------------------------------------------------------------- |
|
415 // CConnMonIAP::EnumerateConnections |
|
416 // Enumerates active connections using RConnection API. |
|
417 // Refreshes iConnInfos array (server view) with the latest information. |
|
418 // ----------------------------------------------------------------------------- |
|
419 // |
|
420 TInt CConnMonIAP::EnumerateConnections( TUint& aCount ) |
|
421 { |
|
422 // Server must be 'blocked' while updating the connection table. |
|
423 TConnectionInfoBuf connInfoBuf; |
|
424 TBearerInfo bearerInfo; |
|
425 TConnInfo connInfo( 0, 0, 0, 0, bearerInfo ); |
|
426 TInt err( KErrNone ); |
|
427 |
|
428 aCount = 0; |
|
429 RArray<TConnInfo> tempArray; |
|
430 |
|
431 // Get existing external (fax) CSD connections |
|
432 // These can't be enumerated from ETEL at the moment |
|
433 if ( iCsdFax ) |
|
434 { |
|
435 // In practise there can be only ONE fax connection of this type |
|
436 connInfo.Reset(); |
|
437 connInfo.iBearer = EBearerExternalCSD; // This will match any ext-CSD |
|
438 connInfo.iBearerInfo.iBearer = EBearerInfoCSD; |
|
439 connInfo.iBearerInfo.iInternal = EFalse; |
|
440 |
|
441 TInt index = iConnInfos.Find( connInfo, TConnInfo::MatchBearer ); |
|
442 if ( ( KErrNotFound != index ) && iCsdFax->IsValid() ) |
|
443 { |
|
444 // Add to temp array |
|
445 tempArray.Append( iConnInfos[index] ); |
|
446 aCount++; |
|
447 } |
|
448 else if ( !iConnUpDownNotifier ) |
|
449 { |
|
450 // Try to find out about external CSD connections |
|
451 // that were alive before CM server started. |
|
452 // The code below will be executed only when |
|
453 // this method is called for the first time. |
|
454 err = iCsdFax->FindCall(); |
|
455 if ( KErrNone == err ) |
|
456 { |
|
457 iCsdFax->GetBearer( connInfo.iBearer, connInfo.iBearerInfo ); |
|
458 connInfo.iConnectionId = NewConnectionId(); // New unique Id |
|
459 iCsdFax->SetConnectionId( connInfo.iConnectionId ); |
|
460 tempArray.Append( connInfo ); |
|
461 aCount++; |
|
462 } |
|
463 } |
|
464 } |
|
465 |
|
466 // Get existing external (fax) PSD connections |
|
467 // These connections can't be enumerated from ETEL at the moment |
|
468 // Only notification of a new connection is available from ETEL. |
|
469 if ( iPsdFax ) |
|
470 { |
|
471 connInfo.Reset(); |
|
472 connInfo.iBearer = EBearerExternalGPRS; // This will match any ext-PSD |
|
473 connInfo.iBearerInfo.iBearer = EBearerInfoGPRS; |
|
474 connInfo.iBearerInfo.iInternal = EFalse; |
|
475 |
|
476 // Check all external PSD connections |
|
477 for ( TUint index = 0; index < iConnInfos.Count(); index++ ) |
|
478 { |
|
479 // Check that connection bearer is external PSD |
|
480 if ( iConnInfos[index].iBearer == EBearerExternalGPRS || |
|
481 iConnInfos[index].iBearer == EBearerExternalEdgeGPRS || |
|
482 iConnInfos[index].iBearer == EBearerExternalWCDMA || |
|
483 iConnInfos[index].iBearer == EBearerExternalCDMA2000 || |
|
484 ( !iConnInfos[index].iBearerInfo.iInternal && |
|
485 ( iConnInfos[index].iBearerInfo.iBearer == EBearerInfoHSDPA || |
|
486 iConnInfos[index].iBearerInfo.iBearer == EBearerInfoHSUPA || |
|
487 iConnInfos[index].iBearerInfo.iBearer == EBearerInfoHSxPA ) ) ) |
|
488 { |
|
489 // Check if connection is still valid |
|
490 if ( iPsdFax->IsValid( iConnInfos[index].iConnectionId ) ) |
|
491 { |
|
492 // Add to temp array |
|
493 tempArray.Append( iConnInfos[index] ); |
|
494 aCount++; |
|
495 } |
|
496 } |
|
497 } |
|
498 |
|
499 if ( !iConnUpDownNotifier ) |
|
500 { |
|
501 for( TUint index = 0; index < KMaxPsdConnectionCount; index++ ) |
|
502 { |
|
503 // Try to find out about external PSD connections |
|
504 // that were alive before CM server started. |
|
505 // The code below will be executed only when |
|
506 // this method is called for the first time. |
|
507 TBuf<KMaxName> tempName( KExternalName ); |
|
508 |
|
509 // Add connection number to string if index is > 1 |
|
510 if ( index > 0 ) |
|
511 { |
|
512 tempName.AppendNum( index+1 ); |
|
513 } |
|
514 |
|
515 // Try to open connection context |
|
516 err = iPsdFax->OpenContext( index, tempName ); |
|
517 if ( KErrNone == err ) |
|
518 { |
|
519 iPsdFax->GetBearer( connInfo.iBearer, connInfo.iBearerInfo ); |
|
520 connInfo.iConnectionId = NewConnectionId(); // New unique Id |
|
521 err = iPsdFax->SetConnectionId( index, connInfo.iConnectionId ); |
|
522 if ( KErrNone == err ) |
|
523 { |
|
524 tempArray.Append( connInfo ); |
|
525 aCount++; |
|
526 } |
|
527 } |
|
528 } |
|
529 } |
|
530 } |
|
531 |
|
532 const TUint initialCount = iConnInfos.Count(); |
|
533 __ASSERT_DEBUG( ( aCount == static_cast<TUint>( tempArray.Count() ) ), |
|
534 PanicServer( EIapArrayError ) ); |
|
535 |
|
536 TUint k( 0 ); |
|
537 // Remove resources owned by obsolete connections |
|
538 for ( k = 0; k < initialCount; k++ ) |
|
539 { |
|
540 TInt index( KErrNotFound ); |
|
541 |
|
542 if ( iConnInfos[k].iBearer < EBearerExternalCSD ) |
|
543 { |
|
544 index = tempArray.Find( iConnInfos[k], TConnInfo::MatchIap ); // Internal |
|
545 } |
|
546 else |
|
547 { |
|
548 index = tempArray.Find( iConnInfos[k], TConnInfo::MatchBearer ); // External |
|
549 } |
|
550 |
|
551 if ( KErrNotFound == index ) |
|
552 { |
|
553 TBool deleteSent( ETrue ); |
|
554 |
|
555 if ( iConnInfos[k].iConnDownNotifier != 0 ) |
|
556 { |
|
557 deleteSent = iConnInfos[k].iConnDownNotifier->DeleteSent(); |
|
558 } |
|
559 |
|
560 TInt connStatus( 0 ); |
|
561 TInt ret = GetConnectionStatus( k, connStatus ); |
|
562 |
|
563 if ( ( ( KErrNone != ret ) || ( connStatus == 0 ) ) && deleteSent ) |
|
564 { |
|
565 LOGIT3("Removing old connection, index %d, id %d, bearer %d", |
|
566 k, iConnInfos[k].iConnectionId, iConnInfos[k].iBearer) |
|
567 iServer->RemoveConnSettingsFromSessions( iConnInfos[k].iConnectionId ); |
|
568 DeleteConnNotifications( k ); |
|
569 |
|
570 // Close attached connection |
|
571 if ( iConnInfos[k].iConnAttach != 0 ) |
|
572 { |
|
573 iConnInfos[k].iConnAttach->Close(); |
|
574 delete iConnInfos[k].iConnAttach; |
|
575 } |
|
576 } |
|
577 else |
|
578 { |
|
579 // Add connection to temp array because connection status is valid. |
|
580 tempArray.Append( iConnInfos[k] ); |
|
581 aCount++; |
|
582 } |
|
583 } |
|
584 } |
|
585 |
|
586 // Replace old iConnInfos array with tempArray |
|
587 // Reserve enough room |
|
588 for ( TUint i = initialCount; i < aCount; i++ ) |
|
589 { |
|
590 TInt error = iConnInfos.Append( tempArray[0] ); |
|
591 if ( error ) |
|
592 { |
|
593 // Rollback reserved entries |
|
594 for ( TUint j = i; j > initialCount; j-- ) |
|
595 { |
|
596 iConnInfos.Remove( j-1 ); |
|
597 } |
|
598 tempArray.Reset(); |
|
599 tempArray.Close(); |
|
600 return error; |
|
601 } |
|
602 } |
|
603 |
|
604 // Safe from leaves from here. Copy over new contents |
|
605 iConnInfos.Reset(); |
|
606 for ( k = 0; k < aCount; k++ ) |
|
607 { |
|
608 iConnInfos.Append( tempArray[k] ); |
|
609 } |
|
610 |
|
611 // Print connection info array to log |
|
612 #ifdef _DEBUG |
|
613 LOGIT("EnumerateConnections: Connection info array:") |
|
614 for ( TInt m = 0; m < iConnInfos.Count(); m++ ) |
|
615 { |
|
616 LOGIT4(" id %d, bearer %d, iapId %d, netId %d", iConnInfos[m].iConnectionId, |
|
617 iConnInfos[m].iBearer, iConnInfos[m].iIapId, iConnInfos[m].iNetId) |
|
618 } |
|
619 #endif // _DEBUG |
|
620 |
|
621 tempArray.Reset(); |
|
622 tempArray.Close(); |
|
623 |
|
624 err = KErrNone; |
|
625 // Start connection up/down notifier if not already running |
|
626 if ( !iConnUpDownNotifier ) |
|
627 { |
|
628 // Leave left out intentionally, check for NULL instead |
|
629 iConnUpDownNotifier = new CConnUpDownNotifier( iServer ); // No (ELeave) |
|
630 if ( !iConnUpDownNotifier ) |
|
631 { |
|
632 err = KErrNoMemory; |
|
633 } |
|
634 else |
|
635 { |
|
636 iConnUpDownNotifier->Construct(); |
|
637 } |
|
638 } |
|
639 if ( KErrNone == err ) |
|
640 { |
|
641 if ( !iConnUpDownNotifier->IsActive() ) |
|
642 { |
|
643 iConnUpDownNotifier->Receive(); // (re)start listening |
|
644 } |
|
645 // Add event watchers for the new connections. Old connections already have |
|
646 // notifications on and AddConnNotificationsL() will only restart the event |
|
647 // watchers if they have stopped (because of an error situation). |
|
648 if ( iCountListeners > 0 ) |
|
649 { |
|
650 TRAP( err, |
|
651 { |
|
652 for ( k = 0; k < aCount; k++ ) |
|
653 { |
|
654 AddConnNotificationsL( k ); |
|
655 } |
|
656 } ); |
|
657 } |
|
658 } |
|
659 return err; |
|
660 } |
|
661 |
|
662 // ----------------------------------------------------------------------------- |
|
663 // CConnMonIAP::EnumerateConnectionsL |
|
664 // Enumerates active connections using RConnection API. |
|
665 // Refreshes iConnInfos array (server view) with the latest information. |
|
666 // Fills aEnumInfo array (client view) with the newly enumerated connection ids. |
|
667 // ----------------------------------------------------------------------------- |
|
668 // |
|
669 TInt CConnMonIAP::EnumerateConnectionsL( TUint& aCount, CArrayFixFlat<TUint>& aEnumInfo ) |
|
670 { |
|
671 LOGENTRFN("CConnMonIAP::EnumerateConnectionsL()") |
|
672 TInt err( KErrNone ); |
|
673 |
|
674 err = EnumerateConnections( aCount ); |
|
675 if ( KErrNone == err ) |
|
676 { |
|
677 // Fill in table (connection ids) owned by the session |
|
678 // Client needs this table when querying connection info index by index. |
|
679 aEnumInfo.Reset(); |
|
680 |
|
681 if ( aCount > 0 ) |
|
682 { |
|
683 for ( TUint k = 0; k < aCount; k++ ) |
|
684 { |
|
685 // Sometimes there is a delay after the DELETE event has arrived and |
|
686 // before the closed connection is removed from Esock. Hide these closing |
|
687 // connections from clients. |
|
688 TBool deleteSent( EFalse ); |
|
689 |
|
690 if ( iConnInfos[k].iConnDownNotifier != 0 ) |
|
691 { |
|
692 deleteSent = iConnInfos[k].iConnDownNotifier->DeleteSent(); |
|
693 } |
|
694 |
|
695 if ( !deleteSent ) |
|
696 { |
|
697 aEnumInfo.AppendL( iConnInfos[k].iConnectionId ); |
|
698 } |
|
699 } |
|
700 aCount = aEnumInfo.Count(); |
|
701 } |
|
702 } |
|
703 |
|
704 LOGEXITFN1("CConnMonIAP::EnumerateConnectionsL()", err) |
|
705 return err; |
|
706 } |
|
707 |
|
708 // ----------------------------------------------------------------------------- |
|
709 // CConnMonIAP::ConnectionExists |
|
710 // Checks if given connection id is valid |
|
711 // ----------------------------------------------------------------------------- |
|
712 // |
|
713 TBool CConnMonIAP::ConnectionExists( const TUint& aConnectionId ) |
|
714 { |
|
715 LOGENTRFN("CConnMonIAP::ConnectionExists()") |
|
716 TBool res( EFalse ); |
|
717 |
|
718 if ( aConnectionId == 0 || aConnectionId >= KMaxConnectionId ) |
|
719 { |
|
720 res = EFalse; |
|
721 } |
|
722 else |
|
723 { |
|
724 TInt index = Index( aConnectionId ); |
|
725 if ( index < 0 ) |
|
726 { |
|
727 res = EFalse; |
|
728 } |
|
729 else |
|
730 { |
|
731 res = ETrue; |
|
732 } |
|
733 } |
|
734 |
|
735 LOGEXITFN1("CConnMonIAP::ConnectionExists()", res) |
|
736 return res; |
|
737 } |
|
738 |
|
739 // ----------------------------------------------------------------------------- |
|
740 // CConnMonIAP::GetConnectionInfo |
|
741 // Returns the number of subconnections in aSubConnectionCount |
|
742 // ----------------------------------------------------------------------------- |
|
743 // |
|
744 TInt CConnMonIAP::GetConnectionInfo( |
|
745 const TUint& aConnectionId, |
|
746 TUint& aSubConnectionCount ) |
|
747 { |
|
748 LOGENTRFN("CConnMonIAP::GetConnectionInfo()") |
|
749 TInt err( KErrNone ); |
|
750 |
|
751 // Find connection matching the given Id |
|
752 TInt index = Index( aConnectionId ); |
|
753 if ( index < 0 ) |
|
754 { |
|
755 err = KErrNotFound; |
|
756 } |
|
757 else |
|
758 { |
|
759 // Get the number of subconnections |
|
760 if ( iConnInfos[index].iBearer < EBearerExternalCSD ) |
|
761 { |
|
762 // Internal connections |
|
763 aSubConnectionCount = 1; |
|
764 err = iConnInfos[index].iConnAttach->EnumerateSubConnections( |
|
765 aSubConnectionCount ); |
|
766 if ( KErrNotReady == err ) |
|
767 { |
|
768 err = KErrNone; |
|
769 } |
|
770 } |
|
771 else |
|
772 { |
|
773 // External connections |
|
774 aSubConnectionCount = 1; |
|
775 } |
|
776 } |
|
777 |
|
778 LOGEXITFN1("CConnMonIAP::GetConnectionInfo()", err) |
|
779 return err; |
|
780 } |
|
781 |
|
782 // ----------------------------------------------------------------------------- |
|
783 // CConnMonIAP::GetIntAttributeL |
|
784 // Returns the integer attribute in aValue |
|
785 // ----------------------------------------------------------------------------- |
|
786 // |
|
787 TInt CConnMonIAP::GetIntAttributeL( const RMessage2& aMessage, TInt& aValue ) |
|
788 { |
|
789 LOGENTRFN("CConnMonIAP::GetIntAttributeL()") |
|
790 TInt ret( KErrNone ); |
|
791 TUint connectionId( aMessage.Int0() ); |
|
792 TUint attribute( aMessage.Int2() ); |
|
793 |
|
794 LOGIT2("SERVER: CConnMonIAP::GetIntAttributeL(): connId %d, attribute %d", connectionId, attribute) |
|
795 |
|
796 if ( KBearerInfo == attribute ) |
|
797 { |
|
798 LOGIT("SERVER: CConnMonIAP::GetIntAttributeL(): KBearerInfo") |
|
799 TBearerInfo bearerInfo; |
|
800 ret = GetBearerInfo( connectionId, bearerInfo ); |
|
801 if ( KErrNone == ret ) |
|
802 { |
|
803 aValue = bearerInfo.iBearer; |
|
804 } |
|
805 return ret; |
|
806 } |
|
807 |
|
808 if ( KWlanScanCacheLifetime == attribute ) |
|
809 { |
|
810 // Check WLAN support for the given id |
|
811 ret = WlanSupportCheck( connectionId ); |
|
812 if ( KErrNone == ret ) |
|
813 { |
|
814 ret = iWlanSupport->GetIntAttributeL( aMessage, aValue ); |
|
815 } |
|
816 return ret; |
|
817 } |
|
818 |
|
819 // Handle requests that use a bearer specific connection IDs |
|
820 if ( ( connectionId == EBearerIdGPRS || connectionId == EBearerIdWCDMA ) && |
|
821 ( attribute == KNetworkStatus ) ) |
|
822 { |
|
823 return ( GetPsdNetworkStatus( aValue ) ); |
|
824 } |
|
825 else if ( ( connectionId == EBearerIdGPRS || connectionId == EBearerIdWCDMA || |
|
826 connectionId == EBearerIdCSD || connectionId == EBearerIdGSM || |
|
827 connectionId == EBearerIdWcdmaCSD ) |
|
828 && ( attribute == KNetworkRegistration ) ) |
|
829 { |
|
830 return ( GetNetworkRegistration( aValue ) ); |
|
831 } |
|
832 else if ( ( connectionId == EBearerIdGPRS || connectionId == EBearerIdWCDMA || |
|
833 connectionId == EBearerIdCSD || connectionId == EBearerIdGSM || |
|
834 connectionId == EBearerIdWcdmaCSD ) |
|
835 && ( attribute == KNetworkRegistration_v2 ) ) |
|
836 { |
|
837 return ( GetNetworkRegistration_v2( aValue ) ); |
|
838 } |
|
839 else if ( ( connectionId == EBearerIdGPRS || connectionId == EBearerIdWCDMA || |
|
840 connectionId == EBearerIdCSD || connectionId == EBearerIdGSM || |
|
841 connectionId == EBearerIdWcdmaCSD ) |
|
842 && ( attribute == KSignalStrength ) ) |
|
843 { |
|
844 return ( GetGSMSignalStrength( aValue ) ); |
|
845 } |
|
846 else if ( connectionId == EBearerIdWLAN && attribute == KSignalStrength ) |
|
847 { |
|
848 if ( iWlanSupport ) |
|
849 { |
|
850 ret = iWlanSupport->GetSignalStrengthL( aMessage, aValue ); |
|
851 } |
|
852 else |
|
853 { |
|
854 ret = KErrNotSupported; |
|
855 } |
|
856 return ret; |
|
857 } |
|
858 else if ( ( connectionId == EBearerIdGPRS ) && ( attribute == KBearer ) ) |
|
859 { |
|
860 // Check which is the bearer of the GPRS cell. |
|
861 if ( IsEdgeCell() ) |
|
862 { |
|
863 aValue = EBearerEdgeGPRS; |
|
864 } |
|
865 else |
|
866 { |
|
867 aValue = EBearerGPRS; |
|
868 } |
|
869 return KErrNone; |
|
870 } |
|
871 |
|
872 // Find connection matching the given Id |
|
873 TInt index = Index( connectionId ); |
|
874 if ( index < 0 ) |
|
875 { |
|
876 return KErrNotFound; |
|
877 } |
|
878 |
|
879 LOGIT1("SERVER: CConnMonIAP::GetIntAttributeL(): index %d", index) |
|
880 |
|
881 // Find out bearer if not already set. |
|
882 if ( iConnInfos[index].iBearer == EBearerUnknown ) |
|
883 { |
|
884 ret = GetBearer( |
|
885 connectionId, |
|
886 iConnInfos[index].iBearer, |
|
887 iConnInfos[index].iBearerInfo ); |
|
888 |
|
889 if ( ret != KErrNone ) |
|
890 { |
|
891 LOGIT1("SERVER: CConnMonIAP::GetIntAttributeL(): Error getting bearer info for connection <%d>", ret) |
|
892 return ret; |
|
893 } |
|
894 LOGIT1("SERVER: CConnMonIAP::GetIntAttributeL(): bearer was unknown, now %d", iConnInfos[index].iBearer) |
|
895 } |
|
896 |
|
897 switch ( attribute ) |
|
898 { |
|
899 case KBearer: |
|
900 { |
|
901 // BEARER |
|
902 LOGIT1("SERVER: CConnMonIAP::GetIntAttributeL(): case KBearer, bearer %d", iConnInfos[index].iBearer) |
|
903 // Bearer is never unknown for the external connections |
|
904 // but sometimes it is not valid (e.g. CSD/HSCSD) until |
|
905 // connection reaches certain status. |
|
906 if ( ( iConnInfos[index].iBearer == EBearerExternalCSD ) || |
|
907 ( iConnInfos[index].iBearer == EBearerExternalHSCSD ) || |
|
908 ( iConnInfos[index].iBearer == EBearerExternalWcdmaCSD ) ) |
|
909 { |
|
910 if ( iCsdFax ) |
|
911 { |
|
912 iCsdFax->GetBearer( iConnInfos[index].iBearer, iConnInfos[index].iBearerInfo ); |
|
913 } |
|
914 } |
|
915 else if ( ( iConnInfos[index].iBearer == EBearerExternalGPRS ) || |
|
916 ( iConnInfos[index].iBearer == EBearerExternalEdgeGPRS ) || |
|
917 ( iConnInfos[index].iBearer == EBearerExternalWCDMA ) ) |
|
918 { |
|
919 if ( iPsdFax ) |
|
920 { |
|
921 iPsdFax->GetBearer( iConnInfos[index].iBearer, iConnInfos[index].iBearerInfo ); |
|
922 } |
|
923 } |
|
924 else if ( iConnInfos[index].iBearer < EBearerExternalCSD ) |
|
925 { |
|
926 // CSD/HSCSD info could change after the first query |
|
927 // also GPRS/EdgeGPRS/WCDMA info can change |
|
928 TInt bearer( EBearerUnknown ); |
|
929 TBearerInfo bearerInfo; |
|
930 |
|
931 ret = GetBearer( connectionId, bearer, bearerInfo ); |
|
932 if ( iConnInfos[index].iBearer != bearer ) |
|
933 { |
|
934 LOGIT4("Bearer changed: id %d, iapId %d, old bearer %d, new bearer %d", |
|
935 iConnInfos[index].iConnectionId, iConnInfos[index].iIapId, |
|
936 iConnInfos[index].iBearer, bearer) |
|
937 } |
|
938 |
|
939 if ( ( bearer != EBearerUnknown && bearerInfo.iBearer != EBearerInfoUnknown ) |
|
940 && ( ret == KErrNone ) ) |
|
941 { |
|
942 iConnInfos[index].iBearer = bearer; |
|
943 iConnInfos[index].iBearerInfo = bearerInfo; |
|
944 } |
|
945 } |
|
946 aValue = iConnInfos[index].iBearer; |
|
947 } |
|
948 break; |
|
949 |
|
950 case KNetworkStatus: |
|
951 { |
|
952 // NETWORK STATUS |
|
953 if ( iConnInfos[index].iBearer == EBearerGPRS || |
|
954 iConnInfos[index].iBearer == EBearerEdgeGPRS || |
|
955 iConnInfos[index].iBearer == EBearerWCDMA || |
|
956 iConnInfos[index].iBearer == EBearerCDMA2000 || |
|
957 iConnInfos[index].iBearer == EBearerExternalGPRS || |
|
958 iConnInfos[index].iBearer == EBearerExternalEdgeGPRS || |
|
959 iConnInfos[index].iBearer == EBearerExternalWCDMA || |
|
960 iConnInfos[index].iBearer == EBearerExternalCDMA2000 ) |
|
961 { |
|
962 // psd |
|
963 ret = GetPsdNetworkStatus( aValue ); |
|
964 } |
|
965 else if ( iConnInfos[index].iBearer == EBearerUnknown ) |
|
966 { |
|
967 // GetBearer() : iMobilePhone.GetCurrentMode() |
|
968 // is not always working for PSD when starting the first |
|
969 // connection. So this must be some PSD... |
|
970 ret = GetPsdNetworkStatus( aValue ); |
|
971 } |
|
972 else |
|
973 { |
|
974 // Others not supported at the moment |
|
975 aValue = EConnMonStatusNotAvailable; |
|
976 ret = KErrNone; |
|
977 } |
|
978 } |
|
979 break; |
|
980 |
|
981 case KConnectionStatus: |
|
982 { |
|
983 // CONNECTION STATUS |
|
984 if ( iConnInfos[index].iBearer < EBearerExternalCSD ) |
|
985 { |
|
986 // Internal connections |
|
987 ret = GetConnectionStatus( index, aValue ); |
|
988 } |
|
989 else if ( iConnInfos[index].iBearer == EBearerExternalCSD || |
|
990 iConnInfos[index].iBearer == EBearerExternalHSCSD || |
|
991 iConnInfos[index].iBearer == EBearerExternalWcdmaCSD ) |
|
992 { |
|
993 // External csd |
|
994 if ( iCsdFax ) |
|
995 { |
|
996 ret = iCsdFax->GetStatus( aValue ); |
|
997 } |
|
998 else |
|
999 { |
|
1000 ret = KErrNotFound; |
|
1001 } |
|
1002 } |
|
1003 else |
|
1004 { |
|
1005 // External psd |
|
1006 if ( iPsdFax ) |
|
1007 { |
|
1008 ret = iPsdFax->GetStatus( connectionId, aValue ); |
|
1009 } |
|
1010 else |
|
1011 { |
|
1012 ret = KErrNotFound; |
|
1013 } |
|
1014 } |
|
1015 } |
|
1016 break; |
|
1017 |
|
1018 case KProtocolType: |
|
1019 { |
|
1020 // PROTOCOL TYPE |
|
1021 if ( iConnInfos[index].iBearer == EBearerGPRS || |
|
1022 iConnInfos[index].iBearer == EBearerEdgeGPRS || |
|
1023 iConnInfos[index].iBearer == EBearerWCDMA ) |
|
1024 { |
|
1025 ret = GetProtocolTypeL( connectionId, aValue ); |
|
1026 } |
|
1027 else if ( iConnInfos[index].iBearer == EBearerExternalGPRS || |
|
1028 iConnInfos[index].iBearer == EBearerExternalEdgeGPRS || |
|
1029 iConnInfos[index].iBearer == EBearerExternalWCDMA ) |
|
1030 { |
|
1031 if ( iPsdFax ) |
|
1032 { |
|
1033 ret = iPsdFax->GetProtocolType( connectionId, aValue ); |
|
1034 } |
|
1035 else |
|
1036 { |
|
1037 ret = KErrNotFound; |
|
1038 } |
|
1039 } |
|
1040 else |
|
1041 { |
|
1042 aValue = EProtocolTypeUnknown; |
|
1043 } |
|
1044 } |
|
1045 break; |
|
1046 |
|
1047 case KNetworkRegistration: |
|
1048 { |
|
1049 // NETWORK REGISTRATION STATUS |
|
1050 if ( iConnInfos[index].iBearer == EBearerGPRS || |
|
1051 iConnInfos[index].iBearer == EBearerEdgeGPRS || |
|
1052 iConnInfos[index].iBearer == EBearerWCDMA || |
|
1053 iConnInfos[index].iBearer == EBearerCSD || |
|
1054 iConnInfos[index].iBearer == EBearerHSCSD || |
|
1055 iConnInfos[index].iBearer == EBearerWcdmaCSD || |
|
1056 iConnInfos[index].iBearer == EBearerExternalGPRS || |
|
1057 iConnInfos[index].iBearer == EBearerExternalEdgeGPRS || |
|
1058 iConnInfos[index].iBearer == EBearerExternalWCDMA || |
|
1059 iConnInfos[index].iBearer == EBearerExternalCSD || |
|
1060 iConnInfos[index].iBearer == EBearerExternalHSCSD || |
|
1061 iConnInfos[index].iBearer == EBearerExternalWcdmaCSD ) |
|
1062 { |
|
1063 ret = GetNetworkRegistration( aValue ); |
|
1064 } |
|
1065 else |
|
1066 { |
|
1067 aValue = ENetworkRegistrationNotAvailable; |
|
1068 ret = KErrNone; |
|
1069 } |
|
1070 } |
|
1071 break; |
|
1072 case KNetworkRegistration_v2: |
|
1073 { |
|
1074 // NETWORK REGISTRATION STATUS |
|
1075 if ( iConnInfos[index].iBearer == EBearerGPRS || |
|
1076 iConnInfos[index].iBearer == EBearerEdgeGPRS || |
|
1077 iConnInfos[index].iBearer == EBearerWCDMA || |
|
1078 iConnInfos[index].iBearer == EBearerCSD || |
|
1079 iConnInfos[index].iBearer == EBearerHSCSD || |
|
1080 iConnInfos[index].iBearer == EBearerWcdmaCSD || |
|
1081 iConnInfos[index].iBearer == EBearerExternalGPRS || |
|
1082 iConnInfos[index].iBearer == EBearerExternalEdgeGPRS || |
|
1083 iConnInfos[index].iBearer == EBearerExternalWCDMA || |
|
1084 iConnInfos[index].iBearer == EBearerExternalCSD || |
|
1085 iConnInfos[index].iBearer == EBearerExternalHSCSD || |
|
1086 iConnInfos[index].iBearer == EBearerExternalWcdmaCSD ) |
|
1087 { |
|
1088 ret = GetNetworkRegistration_v2( aValue ); |
|
1089 } |
|
1090 else |
|
1091 { |
|
1092 aValue = ENetworkRegistrationNotAvailable; |
|
1093 ret = KErrNone; |
|
1094 } |
|
1095 } |
|
1096 break; |
|
1097 case KSignalStrength: |
|
1098 { |
|
1099 // SIGNAL STRENGTH |
|
1100 ret = KErrNotSupported; |
|
1101 if ( iConnInfos[index].iBearer == EBearerGPRS || |
|
1102 iConnInfos[index].iBearer == EBearerEdgeGPRS || |
|
1103 iConnInfos[index].iBearer == EBearerWCDMA || |
|
1104 iConnInfos[index].iBearer == EBearerCSD || |
|
1105 iConnInfos[index].iBearer == EBearerHSCSD || |
|
1106 iConnInfos[index].iBearer == EBearerWcdmaCSD || |
|
1107 iConnInfos[index].iBearer == EBearerExternalGPRS || |
|
1108 iConnInfos[index].iBearer == EBearerExternalEdgeGPRS || |
|
1109 iConnInfos[index].iBearer == EBearerExternalWCDMA || |
|
1110 iConnInfos[index].iBearer == EBearerExternalCSD || |
|
1111 iConnInfos[index].iBearer == EBearerExternalHSCSD || |
|
1112 iConnInfos[index].iBearer == EBearerExternalWcdmaCSD ) |
|
1113 { |
|
1114 ret = GetGSMSignalStrength( aValue ); |
|
1115 } |
|
1116 else if ( iConnInfos[index].iBearer == EBearerWLAN ) |
|
1117 { |
|
1118 if ( iWlanSupport ) |
|
1119 { |
|
1120 ret = iWlanSupport->GetSignalStrengthL( aMessage, aValue ); |
|
1121 } |
|
1122 } |
|
1123 } |
|
1124 break; |
|
1125 |
|
1126 case KNetworkMode: |
|
1127 // NETWORK MODE |
|
1128 ret = KErrNotSupported; |
|
1129 if ( iConnInfos[index].iBearer == EBearerWLAN ) |
|
1130 { |
|
1131 if ( iWlanSupport ) |
|
1132 { |
|
1133 ret = iWlanSupport->GetConnectionMode( aValue ); |
|
1134 } |
|
1135 } |
|
1136 break; |
|
1137 |
|
1138 case KSecurityMode: |
|
1139 // SECURITY MODE |
|
1140 ret = KErrNotSupported; |
|
1141 if ( iConnInfos[index].iBearer == EBearerWLAN ) |
|
1142 { |
|
1143 if ( iWlanSupport ) |
|
1144 { |
|
1145 ret = iWlanSupport->GetConnectionSecurity( aValue ); |
|
1146 } |
|
1147 } |
|
1148 break; |
|
1149 |
|
1150 case KTrafficClass: |
|
1151 ret = KErrNotSupported; |
|
1152 break; |
|
1153 case KDeliveryOrder: |
|
1154 ret = KErrNotSupported; |
|
1155 break; |
|
1156 case KErroneousSDUDelivery: |
|
1157 ret = KErrNotSupported; |
|
1158 break; |
|
1159 case KResidualBitErrorRatio: |
|
1160 ret = KErrNotSupported; |
|
1161 break; |
|
1162 case KSDUErrorRatio: |
|
1163 ret = KErrNotSupported; |
|
1164 break; |
|
1165 default: |
|
1166 ret = KErrArgument; |
|
1167 break; |
|
1168 } |
|
1169 |
|
1170 LOGEXITFN1("CConnMonIAP::GetIntAttributeL()", ret) |
|
1171 return ret; |
|
1172 } |
|
1173 |
|
1174 // ----------------------------------------------------------------------------- |
|
1175 // CConnMonIAP::GetBearerInfo |
|
1176 // Returns the integer attribute in aValue |
|
1177 // ----------------------------------------------------------------------------- |
|
1178 // |
|
1179 TInt CConnMonIAP::GetBearerInfo( const TUint aConnectionId, TBearerInfo& aBearerInfo ) |
|
1180 { |
|
1181 LOGENTRFN("CConnMonIAP::GetBearerInfo()") |
|
1182 TInt err( KErrNone ); |
|
1183 |
|
1184 // Find connection matching the given Id |
|
1185 TInt index = Index( aConnectionId ); |
|
1186 if ( index < 0 ) |
|
1187 { |
|
1188 err = KErrNotFound; |
|
1189 } |
|
1190 else |
|
1191 { |
|
1192 // Find out bearer if not already set. This can be only with internal |
|
1193 // connections. |
|
1194 if ( iConnInfos[index].iBearerInfo.iBearer == EBearerInfoUnknown ) |
|
1195 { |
|
1196 LOGIT("GetBearerInfo: EBearerInfoUnknown") |
|
1197 err = GetBearer( |
|
1198 aConnectionId, |
|
1199 iConnInfos[index].iBearer, |
|
1200 iConnInfos[index].iBearerInfo ); |
|
1201 } |
|
1202 if ( KErrNone == err ) |
|
1203 { |
|
1204 // Bearer is never unknown for the external connections but |
|
1205 // sometimes it is not valid (e.g. CSD/HSCSD) until connection |
|
1206 // reaches certain status. |
|
1207 if ( !iConnInfos[index].iBearerInfo.iInternal && |
|
1208 ( iConnInfos[index].iBearerInfo.iBearer == EBearerInfoCSD || |
|
1209 iConnInfos[index].iBearerInfo.iBearer == EBearerInfoHSCSD || |
|
1210 iConnInfos[index].iBearerInfo.iBearer == EBearerInfoWcdmaCSD ) ) |
|
1211 { |
|
1212 if ( iCsdFax ) |
|
1213 { |
|
1214 LOGIT("GetBearerInfo: case iCsdFax") |
|
1215 err = iCsdFax->GetBearer( |
|
1216 iConnInfos[index].iBearer, |
|
1217 iConnInfos[index].iBearerInfo ); |
|
1218 } |
|
1219 } |
|
1220 else if ( !iConnInfos[index].iBearerInfo.iInternal && |
|
1221 ( iConnInfos[index].iBearerInfo.iBearer == EBearerInfoGPRS || |
|
1222 iConnInfos[index].iBearerInfo.iBearer == EBearerInfoEdgeGPRS || |
|
1223 iConnInfos[index].iBearerInfo.iBearer == EBearerInfoWCDMA || |
|
1224 iConnInfos[index].iBearerInfo.iBearer == EBearerInfoHSDPA || |
|
1225 iConnInfos[index].iBearerInfo.iBearer == EBearerInfoHSUPA || |
|
1226 iConnInfos[index].iBearerInfo.iBearer == EBearerInfoHSxPA ) ) |
|
1227 { |
|
1228 if ( iPsdFax ) |
|
1229 { |
|
1230 LOGIT("GetBearerInfo: case iPsdFax") |
|
1231 err = iPsdFax->GetBearer( |
|
1232 iConnInfos[index].iBearer, |
|
1233 iConnInfos[index].iBearerInfo ); |
|
1234 } |
|
1235 } |
|
1236 else if ( iConnInfos[index].iBearerInfo.iInternal && |
|
1237 ( iConnInfos[index].iBearerInfo.iBearer == EBearerInfoCSD || |
|
1238 iConnInfos[index].iBearerInfo.iBearer == EBearerInfoHSCSD || |
|
1239 iConnInfos[index].iBearerInfo.iBearer == EBearerInfoGPRS || |
|
1240 iConnInfos[index].iBearerInfo.iBearer == EBearerInfoEdgeGPRS || |
|
1241 iConnInfos[index].iBearerInfo.iBearer == EBearerInfoWCDMA || |
|
1242 iConnInfos[index].iBearerInfo.iBearer == EBearerInfoHSDPA || |
|
1243 iConnInfos[index].iBearerInfo.iBearer == EBearerInfoHSUPA || |
|
1244 iConnInfos[index].iBearerInfo.iBearer == EBearerInfoHSxPA ) ) |
|
1245 { |
|
1246 // CSD/HSCSD info could change after the first query also |
|
1247 // GPRS/EdgeGPRS/WCDMA info can change. |
|
1248 TInt bearer( EBearerUnknown ); |
|
1249 TBearerInfo bearerInfo; |
|
1250 |
|
1251 LOGIT("GetBearerInfo: GetBearer() 2nd query") |
|
1252 err = GetBearer( aConnectionId, bearer, bearerInfo ); |
|
1253 if ( ( KErrNone == err ) && ( bearerInfo.iBearer != EBearerInfoUnknown ) ) |
|
1254 { |
|
1255 iConnInfos[index].iBearer = bearer; |
|
1256 iConnInfos[index].iBearerInfo = bearerInfo; |
|
1257 } |
|
1258 } |
|
1259 } |
|
1260 if ( KErrNone == err ) |
|
1261 { |
|
1262 aBearerInfo.iBearer = iConnInfos[index].iBearerInfo.iBearer; |
|
1263 aBearerInfo.iInternal = iConnInfos[index].iBearerInfo.iInternal; |
|
1264 LOGIT2("GetBearerInfo: result: bearer %d, internal %d", aBearerInfo.iBearer, aBearerInfo.iInternal) |
|
1265 } |
|
1266 } |
|
1267 |
|
1268 LOGEXITFN1("CConnMonIAP::GetBearerInfo()", err) |
|
1269 return err; |
|
1270 } |
|
1271 |
|
1272 // ----------------------------------------------------------------------------- |
|
1273 // CConnMonIAP::GetUintAttributeL |
|
1274 // Returns the unsigned integer attribute in aValue |
|
1275 // ----------------------------------------------------------------------------- |
|
1276 // |
|
1277 TInt CConnMonIAP::GetUintAttributeL( const RMessage2& aMessage, TUint& aValue ) |
|
1278 { |
|
1279 LOGENTRFN("CConnMonIAP::GetUintAttributeL()") |
|
1280 TInt err( KErrNone ); |
|
1281 TUint connectionId( aMessage.Int0() ); |
|
1282 TUint attribute( aMessage.Int2() ); |
|
1283 |
|
1284 LOGIT2("SERVER: CConnMonIAP::GetUintAttributeL: connId %d, attribute %d", connectionId, attribute) |
|
1285 |
|
1286 // Find connection matching the given ID |
|
1287 TInt index = Index( connectionId ); |
|
1288 if ( index < 0 ) |
|
1289 { |
|
1290 LOGEXITFN1("CConnMonIAP::GetUintAttributeL()", KErrNotFound) |
|
1291 return KErrNotFound; |
|
1292 } |
|
1293 |
|
1294 switch ( attribute ) |
|
1295 { |
|
1296 case KIAPId: |
|
1297 { |
|
1298 err = KErrNotSupported; |
|
1299 if ( iConnInfos[index].iBearer < EBearerExternalCSD && |
|
1300 iConnInfos[index].iBearerInfo.iInternal ) |
|
1301 { |
|
1302 err = KErrNone; |
|
1303 aValue = iConnInfos[index].iIapId; |
|
1304 LOGIT1("GetUintAttributeL: iap id %d", aValue) |
|
1305 } |
|
1306 } |
|
1307 break; |
|
1308 |
|
1309 case KNetworkIdentifier: |
|
1310 { |
|
1311 err = KErrNotSupported; |
|
1312 if ( iConnInfos[index].iBearer < EBearerExternalCSD && |
|
1313 iConnInfos[index].iBearerInfo.iInternal ) |
|
1314 { |
|
1315 err = KErrNone; |
|
1316 aValue = iConnInfos[index].iNetId; |
|
1317 LOGIT1("GetUintAttributeL: net id %d", aValue) |
|
1318 } |
|
1319 } |
|
1320 break; |
|
1321 |
|
1322 case KDownlinkData: |
|
1323 case KUplinkData: |
|
1324 { |
|
1325 if ( iConnInfos[index].iBearer < EBearerExternalCSD && |
|
1326 iConnInfos[index].iBearerInfo.iInternal ) |
|
1327 { |
|
1328 // INTERNAL |
|
1329 // Query data volumes asyncronously |
|
1330 if ( !iConnInfos[index].iDataVolumeAO ) |
|
1331 { |
|
1332 // Create an active object and add it to scheduler |
|
1333 iConnInfos[index].iDataVolumeAO = new( ELeave ) CDataVolume( |
|
1334 iServer, |
|
1335 iConnInfos[index].iConnAttach, |
|
1336 iConnInfos[index].iConnectionId ); |
|
1337 |
|
1338 iConnInfos[index].iDataVolumeAO->Construct(); |
|
1339 } |
|
1340 if ( !iConnInfos[index].iDataVolumeAO->IsActive() ) |
|
1341 { |
|
1342 iConnInfos[index].iDataVolumeAO->Receive(); // start a new request |
|
1343 } |
|
1344 // Don't complete this request yet |
|
1345 err = KRequestPending; |
|
1346 } |
|
1347 |
|
1348 else if ( iConnInfos[index].iBearer == EBearerExternalGPRS || |
|
1349 iConnInfos[index].iBearer == EBearerExternalEdgeGPRS || |
|
1350 iConnInfos[index].iBearer == EBearerExternalWCDMA || |
|
1351 iConnInfos[index].iBearer == EBearerExternalCDMA2000 || |
|
1352 ( !iConnInfos[index].iBearerInfo.iInternal && |
|
1353 ( iConnInfos[index].iBearerInfo.iBearer == EBearerInfoHSDPA || |
|
1354 iConnInfos[index].iBearerInfo.iBearer == EBearerInfoHSUPA || |
|
1355 iConnInfos[index].iBearerInfo.iBearer == EBearerInfoHSxPA ) ) ) |
|
1356 { |
|
1357 // EXTERNAL PSD |
|
1358 if ( iPsdFax ) |
|
1359 { |
|
1360 TUint down( 0 ); |
|
1361 TUint up( 0 ); |
|
1362 err = iPsdFax->GetDataVolumes( connectionId, down, up ); |
|
1363 if ( KErrNone == err ) |
|
1364 { |
|
1365 if ( attribute == KDownlinkData ) |
|
1366 { |
|
1367 aValue = down; |
|
1368 } |
|
1369 else |
|
1370 { |
|
1371 aValue = up; |
|
1372 } |
|
1373 } |
|
1374 } |
|
1375 else |
|
1376 { |
|
1377 err = KErrNotFound; |
|
1378 } |
|
1379 } |
|
1380 |
|
1381 else |
|
1382 { |
|
1383 // EXTERNAL CSD |
|
1384 err = KErrNotSupported; |
|
1385 } |
|
1386 } |
|
1387 break; |
|
1388 |
|
1389 case KTransmitPower: |
|
1390 { |
|
1391 err = KErrNotSupported; |
|
1392 if ( iConnInfos[index].iBearer == EBearerWLAN && iWlanSupport ) |
|
1393 { |
|
1394 err = iWlanSupport->GetTransmitPower( aValue ); |
|
1395 LOGIT1("GetUintAttributeL: transmit power %d", aValue) |
|
1396 } |
|
1397 } |
|
1398 break; |
|
1399 |
|
1400 case KMaximumBitrateDownlink: |
|
1401 case KMaximumBitrateUplink: |
|
1402 case KMaximumSDUSize: |
|
1403 case KTransferDelay: |
|
1404 case KGuaranteedBitrateDownlink: |
|
1405 case KGuaranteedBitrateUplink: |
|
1406 case KTrafficHandlingPriority: |
|
1407 err = KErrNotSupported; |
|
1408 break; |
|
1409 |
|
1410 default: |
|
1411 err = KErrArgument; |
|
1412 break; |
|
1413 } |
|
1414 |
|
1415 LOGEXITFN1("CConnMonIAP::GetUintAttributeL()", err) |
|
1416 return err; |
|
1417 } |
|
1418 |
|
1419 |
|
1420 // ----------------------------------------------------------------------------- |
|
1421 // CConnMonIAP::GetBoolAttributeL |
|
1422 // Returns the TBool attribute in aValue |
|
1423 // ----------------------------------------------------------------------------- |
|
1424 // |
|
1425 TInt CConnMonIAP::GetBoolAttributeL( const RMessage2& aMessage, TBool& aValue ) |
|
1426 { |
|
1427 LOGENTRFN("CConnMonIAP::GetBoolAttributeL()") |
|
1428 TInt err( KErrNone ); |
|
1429 TUint connectionId( aMessage.Int0() ); |
|
1430 TUint attribute( aMessage.Int2() ); |
|
1431 |
|
1432 switch ( attribute ) |
|
1433 { |
|
1434 case KConnectionActive: |
|
1435 { |
|
1436 // Find connection matching the given ID |
|
1437 TInt index = Index( connectionId ); |
|
1438 if ( index < 0 ) |
|
1439 { |
|
1440 LOGIT("GetBoolAttributeL: connection id not found") |
|
1441 err = KErrNotFound; |
|
1442 break; |
|
1443 } |
|
1444 if ( iConnInfos[index].iBearer < EBearerExternalCSD && |
|
1445 iConnInfos[index].iBearerInfo.iInternal ) |
|
1446 { |
|
1447 TInt connectionStatus( 0 ); |
|
1448 GetConnectionStatus( index, connectionStatus ); |
|
1449 LOGIT1("GetBoolAttributeL: connection status %d", connectionStatus) |
|
1450 |
|
1451 if ( connectionStatus != KLinkLayerOpen ) |
|
1452 { |
|
1453 aValue = EFalse; |
|
1454 break; |
|
1455 } |
|
1456 if ( ( iCountListeners > 0 ) && ( iConnInfos[index].iActivityNotifier != 0 ) ) |
|
1457 { |
|
1458 if ( iConnInfos[index].iActivityNotifier->IsActive() ) |
|
1459 { |
|
1460 // Notifications are ON and are updating the activity info. |
|
1461 // Return the info immediately from internal table |
|
1462 if ( iConnInfos[index].iActivity == 0 ) |
|
1463 { |
|
1464 aValue = EFalse; |
|
1465 } |
|
1466 else |
|
1467 { |
|
1468 aValue = ETrue; |
|
1469 } |
|
1470 } |
|
1471 else |
|
1472 { |
|
1473 GetActivityOneShotL( index ); |
|
1474 err = KRequestPending; |
|
1475 } |
|
1476 } |
|
1477 else |
|
1478 { |
|
1479 // Notifications are OFF |
|
1480 GetActivityOneShotL( index ); |
|
1481 err = KRequestPending; |
|
1482 } |
|
1483 } |
|
1484 else |
|
1485 { |
|
1486 err = KErrNotSupported; |
|
1487 } |
|
1488 } |
|
1489 break; |
|
1490 |
|
1491 case KBearerAvailability: |
|
1492 { |
|
1493 TUint bearer( EBearerIdAll ); |
|
1494 err = BearerIdForBearerAvailability( connectionId, bearer ); |
|
1495 if ( KErrNone == err ) |
|
1496 { |
|
1497 if ( bearer == EBearerIdWLAN ) |
|
1498 { |
|
1499 if ( iWlanSupport ) |
|
1500 { |
|
1501 err = iWlanSupport->GetBearerAvailabilityL( aMessage, aValue ); |
|
1502 } |
|
1503 else |
|
1504 { |
|
1505 err = KErrNotSupported; |
|
1506 } |
|
1507 } |
|
1508 else |
|
1509 { |
|
1510 TBool byCell( EFalse ); |
|
1511 TBool byPhone( EFalse ); |
|
1512 err = GetBearerSupportInfo( bearer, byCell, byPhone ); |
|
1513 if ( byCell && byPhone ) |
|
1514 { |
|
1515 aValue = ETrue; |
|
1516 } |
|
1517 else |
|
1518 { |
|
1519 aValue = EFalse; |
|
1520 } |
|
1521 } |
|
1522 } |
|
1523 } |
|
1524 break; |
|
1525 |
|
1526 case KPacketDataAvailability: |
|
1527 { |
|
1528 if ( connectionId != EBearerIdGPRS && connectionId != EBearerIdWCDMA ) |
|
1529 { |
|
1530 err = KErrNotSupported; |
|
1531 } |
|
1532 else |
|
1533 { |
|
1534 // When not in dual mode and call is active, gprs and wcdma bearers are unavailable |
|
1535 // Note that even the WCDMA can be unavailable, if the phone doesn't support DTM |
|
1536 if ( iTelephonyNotifier && iDualTransferModeNotifier && |
|
1537 iTelephonyNotifier->IsCallActive() && |
|
1538 !iDualTransferModeNotifier->IsInDualMode() ) |
|
1539 { |
|
1540 LOGIT("SERVER: Packet data UNAVAILABLE (2G&3G), no DTM and call is active") |
|
1541 aValue = EFalse; |
|
1542 } |
|
1543 // If DTM status says available, lets check the availability of the bearer. |
|
1544 // This is done because the DTM status remains as it was if the psd link is broken. |
|
1545 // So there might be a situation where the notifier says we are in dual mode even |
|
1546 // though the whole bearer is unavailable |
|
1547 else |
|
1548 { |
|
1549 TBool byPhone( EFalse ); |
|
1550 TBool byCell( EFalse ); |
|
1551 err = GetBearerSupportInfo( connectionId, byCell, byPhone ); |
|
1552 LOGIT4("Bearer support: bearer %d, byCell %d, byPhone %d, err <%d>", connectionId, byCell, byPhone, err) |
|
1553 aValue = ETrue; |
|
1554 if ( KErrNone == err ) |
|
1555 { |
|
1556 if ( byCell && byPhone ) |
|
1557 { |
|
1558 LOGIT("SERVER: Packet data AVAILABLE, DTM or no call is active") |
|
1559 } |
|
1560 else |
|
1561 { |
|
1562 LOGIT("SERVER: Packet data UNAVAILABLE, no bearer") |
|
1563 aValue = EFalse; |
|
1564 } |
|
1565 } |
|
1566 } |
|
1567 } |
|
1568 } |
|
1569 break; |
|
1570 |
|
1571 default: |
|
1572 // Unknown attribute |
|
1573 err = KErrArgument; |
|
1574 break; |
|
1575 } |
|
1576 |
|
1577 LOGEXITFN1("CConnMonIAP::GetBoolAttributeL()", err) |
|
1578 return err; |
|
1579 } |
|
1580 |
|
1581 // ----------------------------------------------------------------------------- |
|
1582 // CConnMonIAP::GetStringAttribute |
|
1583 // Returns the TDes attribute in aValue |
|
1584 // ----------------------------------------------------------------------------- |
|
1585 // |
|
1586 TInt CConnMonIAP::GetStringAttribute( const RMessage2& aMessage, TDes& aValue ) |
|
1587 { |
|
1588 LOGENTRFN("CConnMonIAP::GetStringAttribute()") |
|
1589 TInt err( KErrNone ); |
|
1590 TUint connectionId( aMessage.Int0() ); |
|
1591 TUint attribute( aMessage.Int2() ); |
|
1592 |
|
1593 // Find connection matching the given ID |
|
1594 TInt index = Index( connectionId ); |
|
1595 if ( index < 0 ) |
|
1596 { |
|
1597 LOGEXITFN1("CConnMonIAP::GetStringAttribute()", KErrNotFound) |
|
1598 return KErrNotFound; |
|
1599 } |
|
1600 |
|
1601 // Find out bearer if not already set |
|
1602 if ( iConnInfos[index].iBearer == EBearerUnknown ) |
|
1603 { |
|
1604 err = GetBearer( connectionId, iConnInfos[index].iBearer, iConnInfos[index].iBearerInfo ); |
|
1605 if ( KErrNone != err ) |
|
1606 { |
|
1607 LOGEXITFN1("CConnMonIAP::GetStringAttribute()", err) |
|
1608 return err; |
|
1609 } |
|
1610 } |
|
1611 |
|
1612 switch ( attribute ) |
|
1613 { |
|
1614 case KIAPName: |
|
1615 { |
|
1616 // From RConnection |
|
1617 if ( iConnInfos[index].iBearer >= EBearerExternalCSD && |
|
1618 !iConnInfos[index].iBearerInfo.iInternal ) |
|
1619 { |
|
1620 err = KErrNotSupported; |
|
1621 } |
|
1622 else |
|
1623 { |
|
1624 TBuf<KCommsDbSvrMaxFieldLength> settingName; |
|
1625 settingName.Copy( TPtrC( IAP ) ); |
|
1626 settingName.Append( TChar( '\\' ) ); |
|
1627 settingName.Append( TPtrC( COMMDB_NAME ) ); |
|
1628 // IAP name max. length in commsdat should be 50 |
|
1629 err = iConnInfos[index].iConnAttach->GetDesSetting( TPtrC( settingName ), aValue ); |
|
1630 } |
|
1631 } |
|
1632 break; |
|
1633 |
|
1634 case KAccessPointName: |
|
1635 { |
|
1636 if ( iConnInfos[index].iBearer < EBearerExternalCSD ) |
|
1637 { |
|
1638 err = GetAccessPointName( iConnInfos[index].iConnectionId, aValue ); |
|
1639 } |
|
1640 else if ( iConnInfos[index].iBearer == EBearerExternalGPRS || |
|
1641 iConnInfos[index].iBearer == EBearerExternalEdgeGPRS || |
|
1642 iConnInfos[index].iBearer == EBearerExternalWCDMA || |
|
1643 ( !iConnInfos[index].iBearerInfo.iInternal && |
|
1644 ( iConnInfos[index].iBearerInfo.iBearer == EBearerInfoHSDPA || |
|
1645 iConnInfos[index].iBearerInfo.iBearer == EBearerInfoHSUPA || |
|
1646 iConnInfos[index].iBearerInfo.iBearer == EBearerInfoHSxPA ) ) ) |
|
1647 { |
|
1648 if ( iPsdFax ) |
|
1649 { |
|
1650 err = iPsdFax->GetApn( connectionId, aValue ); |
|
1651 } |
|
1652 else |
|
1653 { |
|
1654 err = KErrNotFound; |
|
1655 } |
|
1656 } |
|
1657 else |
|
1658 { |
|
1659 err = KErrNotSupported; |
|
1660 } |
|
1661 } |
|
1662 break; |
|
1663 |
|
1664 case KTelNumber: |
|
1665 { |
|
1666 if ( iConnInfos[index].iBearer < EBearerExternalCSD ) |
|
1667 { |
|
1668 err = GetTelNumber( iConnInfos[index].iConnectionId, aValue ); |
|
1669 } |
|
1670 else if ( iConnInfos[index].iBearer == EBearerExternalCSD || |
|
1671 iConnInfos[index].iBearer == EBearerExternalHSCSD || |
|
1672 iConnInfos[index].iBearer == EBearerExternalWcdmaCSD ) |
|
1673 { |
|
1674 if ( iCsdFax ) |
|
1675 { |
|
1676 err = iCsdFax->GetTelNumber( aValue ); |
|
1677 } |
|
1678 else |
|
1679 { |
|
1680 err = KErrNotFound; |
|
1681 } |
|
1682 } |
|
1683 else |
|
1684 { |
|
1685 err = KErrNotSupported; |
|
1686 } |
|
1687 } |
|
1688 break; |
|
1689 |
|
1690 case KNetworkName: |
|
1691 { |
|
1692 err = KErrNotSupported; |
|
1693 if ( iConnInfos[index].iBearer == EBearerWLAN ) |
|
1694 { |
|
1695 if ( iWlanSupport ) |
|
1696 { |
|
1697 // Max SSID length is 32 |
|
1698 err = iWlanSupport->GetConnectionSsid( aValue ); |
|
1699 } |
|
1700 } |
|
1701 } |
|
1702 break; |
|
1703 |
|
1704 default: |
|
1705 err = KErrArgument; |
|
1706 break; |
|
1707 } |
|
1708 |
|
1709 LOGEXITFN1("CConnMonIAP::GetStringAttribute()", err) |
|
1710 return err; |
|
1711 } |
|
1712 |
|
1713 // ----------------------------------------------------------------------------- |
|
1714 // CConnMonIAP::GetUids |
|
1715 // RConnection::EnumerateConnections() must be called to get the right |
|
1716 // RConnection index for the connection (iConnInfos can't be trusted because |
|
1717 // connections are added by events, too). |
|
1718 // ----------------------------------------------------------------------------- |
|
1719 // |
|
1720 TInt CConnMonIAP::GetUids( |
|
1721 const TUint aConnectionId, |
|
1722 TConnMonClientEnum& aClientEnum ) |
|
1723 { |
|
1724 TInt err( KErrNone ); |
|
1725 TConnEnumArgBuf enumArgBuf; |
|
1726 TConnGetClientInfoArgBuf clientInfoBuf; |
|
1727 TUint count( 0 ); |
|
1728 TConnectionInfoBuf connInfoBuf; |
|
1729 TUint j; |
|
1730 |
|
1731 // Find connection matching the given Id |
|
1732 TInt index = Index( aConnectionId ); |
|
1733 |
|
1734 if ( index < 0 ) |
|
1735 { |
|
1736 return KErrNotFound; |
|
1737 } |
|
1738 |
|
1739 // Uids are not available for external connections |
|
1740 if ( iConnInfos[index].iBearer >= EBearerExternalCSD && |
|
1741 !iConnInfos[index].iBearerInfo.iInternal ) |
|
1742 { |
|
1743 return KErrNotSupported; |
|
1744 } |
|
1745 |
|
1746 // Get RConnection index for the connection |
|
1747 err = iConnection.EnumerateConnections( count ); |
|
1748 |
|
1749 if ( err != KErrNone ) |
|
1750 { |
|
1751 return( err ); |
|
1752 } |
|
1753 |
|
1754 for ( j = 1; j <= count; j++ ) |
|
1755 { |
|
1756 err = iConnection.GetConnectionInfo( j, connInfoBuf ); |
|
1757 |
|
1758 if ( err != KErrNone ) |
|
1759 { |
|
1760 return( err ); |
|
1761 } |
|
1762 |
|
1763 if ( ( iConnInfos[index].iIapId == connInfoBuf().iIapId ) && |
|
1764 ( iConnInfos[index].iNetId == connInfoBuf().iNetId ) ) |
|
1765 { |
|
1766 break; |
|
1767 } |
|
1768 } |
|
1769 |
|
1770 // If connection does not exist anymore |
|
1771 if ( j > count ) |
|
1772 { |
|
1773 return KErrNotFound; |
|
1774 } |
|
1775 |
|
1776 enumArgBuf().iIndex = j; |
|
1777 |
|
1778 // Get the number of clients |
|
1779 err = iConnection.Control( KCOLConnection, KCoEnumerateConnectionClients, enumArgBuf ); |
|
1780 |
|
1781 if ( err != KErrNone ) |
|
1782 { |
|
1783 return err; |
|
1784 } |
|
1785 |
|
1786 aClientEnum.iCount = enumArgBuf().iCount; |
|
1787 |
|
1788 // Count connection monitor OUT of the number of clients |
|
1789 if ( aClientEnum.iCount > 0 ) |
|
1790 { |
|
1791 --aClientEnum.iCount; |
|
1792 } |
|
1793 |
|
1794 // Get client uids one by one |
|
1795 // Note. in WINS uids are zero. |
|
1796 TInt k( 0 ); |
|
1797 |
|
1798 for ( TUint i = 1; i <= enumArgBuf().iCount; i++ ) |
|
1799 { |
|
1800 clientInfoBuf().iIndex = i; |
|
1801 |
|
1802 err = iConnection.Control( KCOLConnection, KCoGetConnectionClientInfo, clientInfoBuf ); |
|
1803 |
|
1804 if ( err != KErrNone ) |
|
1805 { |
|
1806 return err; |
|
1807 } |
|
1808 |
|
1809 // Exclude Connection Monitor UID |
|
1810 if ( ( clientInfoBuf().iClientInfo.iUid.iUid != KConnMonDllUid.iUid ) && |
|
1811 ( clientInfoBuf().iClientInfo.iUid.iUid != KGenericDllUid.iUid ) && |
|
1812 ( clientInfoBuf().iClientInfo.iUid.iUid != KConnMonServerUid.iUid ) && |
|
1813 ( clientInfoBuf().iClientInfo.iUid.iUid != 0 ) ) |
|
1814 { |
|
1815 TInt m( 0 ); |
|
1816 |
|
1817 // Look for duplicates |
|
1818 for ( m = 0; m < k; m++ ) |
|
1819 { |
|
1820 if ( aClientEnum.iUid[m].iUid == clientInfoBuf().iClientInfo.iUid.iUid ) |
|
1821 { |
|
1822 break; |
|
1823 } |
|
1824 } |
|
1825 |
|
1826 if ( m == k ) |
|
1827 { |
|
1828 // This is a new unique ID |
|
1829 aClientEnum.iUid[k].iUid = clientInfoBuf().iClientInfo.iUid.iUid; |
|
1830 k++; |
|
1831 } |
|
1832 else |
|
1833 { |
|
1834 // Duplicate |
|
1835 --aClientEnum.iCount; |
|
1836 } |
|
1837 } |
|
1838 } |
|
1839 |
|
1840 return err; |
|
1841 } |
|
1842 |
|
1843 // ----------------------------------------------------------------------------- |
|
1844 // CConnMonIAP::SetUintAttribute |
|
1845 // ----------------------------------------------------------------------------- |
|
1846 // |
|
1847 TInt CConnMonIAP::SetUintAttribute( |
|
1848 const RMessage2& /*aMessage*/, |
|
1849 const TUint /*aValue*/ ) |
|
1850 { |
|
1851 return KErrNotSupported; |
|
1852 } |
|
1853 |
|
1854 // ----------------------------------------------------------------------------- |
|
1855 // CConnMonIAP::SetBoolAttributeL |
|
1856 // Used for stopping the connections. |
|
1857 // ----------------------------------------------------------------------------- |
|
1858 // |
|
1859 TInt CConnMonIAP::SetBoolAttribute( const RMessage2& aMessage ) |
|
1860 { |
|
1861 LOGENTRFN("CConnMonIAP::SetBoolAttribute()") |
|
1862 TInt err( KErrNone ); |
|
1863 TUint attribute( aMessage.Int2() ); |
|
1864 TBool value( aMessage.Int3() ); |
|
1865 |
|
1866 switch ( attribute ) |
|
1867 { |
|
1868 case KConnectionStop: |
|
1869 if ( value ) |
|
1870 { |
|
1871 // Find connection matching the given Id |
|
1872 TInt index = Index( aMessage.Int0() ); |
|
1873 if ( index < 0 ) |
|
1874 { |
|
1875 err = KErrNotFound; |
|
1876 } |
|
1877 else |
|
1878 { |
|
1879 err = StopConnection( index ); |
|
1880 if ( KErrCouldNotConnect == err ) |
|
1881 { |
|
1882 err = KErrNotFound; |
|
1883 } |
|
1884 } |
|
1885 } |
|
1886 break; |
|
1887 |
|
1888 case KConnectionStopAll: |
|
1889 if ( value ) |
|
1890 { |
|
1891 TUint i( 0 ); |
|
1892 TUint count( 0 ); |
|
1893 TUint newCount( 0 ); |
|
1894 |
|
1895 // Refresh array |
|
1896 err = EnumerateConnections( count ); |
|
1897 LOGIT2("SetBoolAttribute: KConnectionStopAll: Enumerated all connections, count %d <%d>", count, err) |
|
1898 if ( KErrNone == err ) |
|
1899 { |
|
1900 while ( count > 0 && i < count ) |
|
1901 { |
|
1902 // Stop (and remove if up/down event watcher is dead) the connection |
|
1903 err = StopConnection( i ); |
|
1904 if ( KErrNone != err ) |
|
1905 { |
|
1906 LOGIT2("SetBoolAttribute: KConnectionStopAll: Error stopping connection %d <%d>", i, err) |
|
1907 return err; |
|
1908 } |
|
1909 newCount = iConnInfos.Count(); |
|
1910 if ( count > newCount ) |
|
1911 { |
|
1912 count = newCount; // Connection has been removed |
|
1913 } |
|
1914 else |
|
1915 { |
|
1916 i++; // Cconnection has not been removed, increment index to next connection |
|
1917 } |
|
1918 } |
|
1919 } |
|
1920 } |
|
1921 break; |
|
1922 |
|
1923 default: |
|
1924 err = KErrArgument; |
|
1925 break; |
|
1926 } |
|
1927 |
|
1928 LOGEXITFN1("CConnMonIAP::SetBoolAttribute()", err) |
|
1929 return err; |
|
1930 } |
|
1931 |
|
1932 // ----------------------------------------------------------------------------- |
|
1933 // CConnMonIAP::SetStringAttributeL |
|
1934 // |
|
1935 // ----------------------------------------------------------------------------- |
|
1936 // |
|
1937 TInt CConnMonIAP::SetStringAttributeL( |
|
1938 const RMessage2& /*aMessage*/, |
|
1939 const TDes& /*aValue*/ ) |
|
1940 { |
|
1941 return KErrNotSupported; |
|
1942 } |
|
1943 |
|
1944 |
|
1945 // ----------------------------------------------------------------------------- |
|
1946 // CConnMonIAP::ListenL |
|
1947 // Starts event watchers. |
|
1948 // ----------------------------------------------------------------------------- |
|
1949 // |
|
1950 void CConnMonIAP::ListenL() |
|
1951 { |
|
1952 LOGIT(".") |
|
1953 LOGENTRFN("CConnMonIAP::ListenL()") |
|
1954 iCountListeners++; |
|
1955 |
|
1956 // GLOBAL notifiers |
|
1957 |
|
1958 // Connection Up/Down events |
|
1959 if ( iConnUpDownNotifier == 0 ) |
|
1960 { |
|
1961 iConnUpDownNotifier = new( ELeave ) CConnUpDownNotifier( iServer ); |
|
1962 iConnUpDownNotifier->Construct(); |
|
1963 } |
|
1964 if ( !iConnUpDownNotifier->IsActive() ) |
|
1965 { |
|
1966 iConnUpDownNotifier->Receive(); // (re)start listening |
|
1967 } |
|
1968 |
|
1969 if ( iTSYLoaded && iPacketServLoaded ) |
|
1970 { |
|
1971 // PSD network status events |
|
1972 if ( iPsdNetwStatusNotifier == 0 ) |
|
1973 { |
|
1974 iPsdNetwStatusNotifier = CNetwStatusNotifier::NewL( iServer ); |
|
1975 } |
|
1976 if ( !iPsdNetwStatusNotifier->IsActive() ) |
|
1977 { |
|
1978 iPsdNetwStatusNotifier->Receive(); // (re)start listening |
|
1979 } |
|
1980 |
|
1981 // GPRS bearer availability changed events |
|
1982 if ( iGSMBearerAvailabilityNotifier == 0 ) |
|
1983 { |
|
1984 iGSMBearerAvailabilityNotifier = CBearerAvailabilityNotifier::NewL( iServer ); |
|
1985 } |
|
1986 if ( !iGSMBearerAvailabilityNotifier->IsActive() ) |
|
1987 { |
|
1988 iGSMBearerAvailabilityNotifier->Receive(); // (re)start listening |
|
1989 } |
|
1990 } |
|
1991 |
|
1992 if ( iTSYLoaded ) |
|
1993 { |
|
1994 // Mode change events |
|
1995 if ( iModeNotifier == 0 ) |
|
1996 { |
|
1997 iModeNotifier = CModeNotifier::NewL( iServer, iMobilePhone ); |
|
1998 } |
|
1999 if ( !iModeNotifier->IsActive() ) |
|
2000 { |
|
2001 iModeNotifier->Receive(); // (re)start listening |
|
2002 } |
|
2003 |
|
2004 // Network registration status events |
|
2005 if ( iNetwRegistrationNotifier == 0 ) |
|
2006 { |
|
2007 iNetwRegistrationNotifier = CNetwRegistrationNotifier::NewL( iServer, iMobilePhone ); |
|
2008 } |
|
2009 if ( !iNetwRegistrationNotifier->IsActive() ) |
|
2010 { |
|
2011 iNetwRegistrationNotifier->Receive(); // (re)start listening |
|
2012 } |
|
2013 |
|
2014 // Bearer change (GPRS/Edge GPRS) status events |
|
2015 if ( FeatureManager::FeatureSupported( KFeatureIdEdgeKnowledge ) ) |
|
2016 { |
|
2017 if ( iEdgeNotifier == 0 ) |
|
2018 { |
|
2019 iEdgeNotifier = new( ELeave ) CBearerNotifier( iServer, iMobilePhone ); |
|
2020 TRAPD( ret, iEdgeNotifier->ConstructL() ); |
|
2021 if ( ret != KErrNone ) |
|
2022 { |
|
2023 // Construction (=opening ETel CustomAPI) failed |
|
2024 delete iEdgeNotifier; |
|
2025 iEdgeNotifier = 0; |
|
2026 } |
|
2027 } |
|
2028 if ( iEdgeNotifier != 0 ) |
|
2029 { |
|
2030 if ( !iEdgeNotifier->IsActive() ) |
|
2031 { |
|
2032 iEdgeNotifier->Receive(); // (re)start listening |
|
2033 } |
|
2034 } |
|
2035 } |
|
2036 |
|
2037 if ( !iWcdmaNotifier ) |
|
2038 { |
|
2039 iWcdmaNotifier = CWcdmaBearerNotifier::NewL( iServer, iTelServer ); |
|
2040 if ( iWcdmaNotifier ) |
|
2041 { |
|
2042 iWcdmaNotifier->Receive(); |
|
2043 } |
|
2044 } |
|
2045 |
|
2046 if ( FeatureManager::FeatureSupported( KFeatureIdConnMonExtension ) ) |
|
2047 { |
|
2048 // GSM signal strength change events |
|
2049 if ( iGSMSignalNotifier == 0 ) |
|
2050 { |
|
2051 iGSMSignalNotifier = CGsmSignalNotifier::NewL( iServer, iMobilePhone ); |
|
2052 } |
|
2053 if ( !iGSMSignalNotifier->IsActive() ) |
|
2054 { |
|
2055 iGSMSignalNotifier->Receive(); // (re)start listening |
|
2056 } |
|
2057 } |
|
2058 } |
|
2059 |
|
2060 if ( !iTelephonyNotifier ) |
|
2061 { |
|
2062 iTelephonyNotifier = CConnMonTelNotifier::NewL( *this, &iMobilePhone ); |
|
2063 iTelephonyNotifier->Receive(); |
|
2064 } |
|
2065 |
|
2066 if ( !iDualTransferModeNotifier && iPacketServLoaded ) |
|
2067 { |
|
2068 iDualTransferModeNotifier = CConnMonDtmNotifier::NewL( iPacketService, *this ); |
|
2069 iDualTransferModeNotifier->Receive(); |
|
2070 } |
|
2071 |
|
2072 if ( iWlanSupport ) |
|
2073 { |
|
2074 iWlanSupport->EnableEventsToClients(); |
|
2075 } |
|
2076 |
|
2077 // Notifiers owned by the connections |
|
2078 // (connection status, data volumes, connection activity, subconnection up/down) |
|
2079 TInt count = iConnInfos.Count(); |
|
2080 |
|
2081 for ( TInt i = 0; i < count; i++ ) |
|
2082 { |
|
2083 AddConnNotificationsL( i ); |
|
2084 } |
|
2085 LOGEXITFN("CConnMonIAP::ListenL()") |
|
2086 } |
|
2087 |
|
2088 // ----------------------------------------------------------------------------- |
|
2089 // CConnMonIAP::CancelListen |
|
2090 // Stops and deletes event watchers. |
|
2091 // ----------------------------------------------------------------------------- |
|
2092 // |
|
2093 void CConnMonIAP::CancelListen() |
|
2094 { |
|
2095 iCountListeners--; |
|
2096 LOGIT1("CancelListen() remaining listeners: %d", iCountListeners) |
|
2097 |
|
2098 if ( iCountListeners == 0 ) |
|
2099 { |
|
2100 DeleteNotifications(); |
|
2101 } |
|
2102 } |
|
2103 |
|
2104 // ----------------------------------------------------------------------------------- |
|
2105 // CConnMonIAP::AddConnectionL |
|
2106 // Adds a new connection to the iConnInfos array. Starts event watchers for the |
|
2107 // connection if there are clients that want events. |
|
2108 // ----------------------------------------------------------------------------------- |
|
2109 // |
|
2110 TInt CConnMonIAP::AddConnectionL( TConnInfo& aConnection ) |
|
2111 { |
|
2112 TInt err( KErrNone ); |
|
2113 TInt index( KErrNotFound ); |
|
2114 TUint8 internal( 0 ); |
|
2115 |
|
2116 if ( aConnection.iBearer < EBearerExternalCSD ) |
|
2117 { |
|
2118 internal = 1; |
|
2119 } |
|
2120 |
|
2121 if ( internal ) |
|
2122 { |
|
2123 index = iConnInfos.Find( aConnection, TConnInfo::MatchIap ); |
|
2124 } |
|
2125 /* |
|
2126 else |
|
2127 { |
|
2128 index = iConnInfos.Find( aConnection, TConnInfo::MatchBearer ); |
|
2129 } |
|
2130 */ |
|
2131 |
|
2132 if ( KErrNotFound != index ) |
|
2133 { |
|
2134 LOGIT("AddConnectionL: New connection occured with same IAP id, remove old") |
|
2135 // To remove the connection we have to complete the |
|
2136 // connection by sending the notifications needed by clients. |
|
2137 CompleteConnectionClosing( index ); |
|
2138 } |
|
2139 |
|
2140 // Add to connection table |
|
2141 aConnection.iConnectionId = NewConnectionId(); |
|
2142 |
|
2143 if ( internal ) |
|
2144 { |
|
2145 err = OpenAndAttachTo( aConnection ); |
|
2146 if ( err != KErrNone ) |
|
2147 { |
|
2148 LOGIT1("AddConnectionL: ERROR attach failed <%d>", err) |
|
2149 return err; |
|
2150 } |
|
2151 } |
|
2152 |
|
2153 err = iConnInfos.Append( aConnection ); |
|
2154 |
|
2155 if ( ( KErrNone == err ) && internal ) |
|
2156 { |
|
2157 index = iConnInfos.Find( aConnection, TConnInfo::MatchIap ); |
|
2158 if ( ( index != KErrNotFound ) && ( iCountListeners > 0 ) ) |
|
2159 { |
|
2160 TRAPD( ret, AddConnNotificationsL( index ) ); |
|
2161 if ( ret != KErrNone ) |
|
2162 { |
|
2163 // Close attached connection |
|
2164 if ( iConnInfos[ index ].iConnAttach != 0 ) |
|
2165 { |
|
2166 iConnInfos[ index ].iConnAttach->Close(); |
|
2167 delete iConnInfos[ index ].iConnAttach; |
|
2168 } |
|
2169 |
|
2170 // Remove |
|
2171 iConnInfos.Remove( index ); |
|
2172 |
|
2173 // Leave |
|
2174 User::Leave( ret ); |
|
2175 } |
|
2176 } |
|
2177 } |
|
2178 |
|
2179 // Print connection info array to log |
|
2180 #ifdef _DEBUG |
|
2181 LOGIT("AddConnectionL: Connection info array:") |
|
2182 for ( TInt m = 0; m < iConnInfos.Count(); m++ ) |
|
2183 { |
|
2184 LOGIT4(" id %d, bearer %d, iapId %d, netId %d", iConnInfos[m].iConnectionId, |
|
2185 iConnInfos[m].iBearer, iConnInfos[m].iIapId, iConnInfos[m].iNetId) |
|
2186 } |
|
2187 #endif // _DEBUG |
|
2188 |
|
2189 return err; |
|
2190 } |
|
2191 |
|
2192 // ----------------------------------------------------------------------------------- |
|
2193 // CConnMonIAP::CompleteConnectionClosing |
|
2194 // ----------------------------------------------------------------------------------- |
|
2195 // |
|
2196 void CConnMonIAP::CompleteConnectionClosing( TInt& aIndex ) |
|
2197 { |
|
2198 LOGENTRFN("CConnMonIAP::CompleteConnectionClosing()") |
|
2199 |
|
2200 if ( iConnInfos[aIndex].iBearerNotifier->Listening() ) |
|
2201 { |
|
2202 iConnInfos[aIndex].iBearerNotifier->CancelListen(); |
|
2203 } |
|
2204 |
|
2205 if ( iConnInfos[aIndex].iProgressNotifier->IsActive() ) |
|
2206 { |
|
2207 // Progress notification request is still active --> Cancel it |
|
2208 iConnInfos[aIndex].iProgressNotifier->Cancel(); |
|
2209 } |
|
2210 // Send KLinkLayerClosed event |
|
2211 LOGIT("CompleteConnectionClosing: ProgressNotifier->SendClosedEvent()") |
|
2212 iConnInfos[aIndex].iProgressNotifier->SendClosedEvent(); |
|
2213 |
|
2214 if ( iConnInfos[aIndex].iConnDownNotifier->IsActive() ) |
|
2215 { |
|
2216 // Allinterface notification request is still active --> Cancel it |
|
2217 iConnInfos[aIndex].iConnDownNotifier->Cancel(); |
|
2218 } |
|
2219 |
|
2220 if ( !iConnInfos[aIndex].iConnDownNotifier->DeleteSent() ) |
|
2221 { |
|
2222 // After SetInterfaceClosed() call SendDeletedEvent() removes |
|
2223 // the connection |
|
2224 iConnInfos[aIndex].iConnDownNotifier->SetInterfaceClosed(); |
|
2225 iConnInfos[aIndex].iConnDownNotifier->SendDeletedEvent(); |
|
2226 } |
|
2227 else |
|
2228 { |
|
2229 // Delete has already been sent (shouldn't be possible) so |
|
2230 // connection has to be removed |
|
2231 LOGIT("CompleteConnectionClosing: Delete already sent, removing connection") |
|
2232 RemoveConnection( iConnInfos[aIndex] ); |
|
2233 } |
|
2234 |
|
2235 LOGEXITFN("CConnMonIAP::CompleteConnectionClosing()") |
|
2236 } |
|
2237 |
|
2238 // ----------------------------------------------------------------------------------- |
|
2239 // CConnMonIAP::RemoveConnection |
|
2240 // Removes connection settings from sessions, stops and deletes event watchers and |
|
2241 // removes the connection info from the iConnInfos array. |
|
2242 // Connection is deleted by an event (or by calling RConnection::Stop()). |
|
2243 // ----------------------------------------------------------------------------------- |
|
2244 // |
|
2245 TInt CConnMonIAP::RemoveConnection( TConnInfo& aConnection ) |
|
2246 { |
|
2247 LOGENTRFN("CConnMonIAP::RemoveConnection()") |
|
2248 |
|
2249 TInt index( KErrNotFound ); |
|
2250 // Check if bearer is external CSD |
|
2251 if ( aConnection.iBearer == EBearerExternalCSD || |
|
2252 aConnection.iBearer == EBearerExternalHSCSD || |
|
2253 aConnection.iBearer == EBearerExternalWcdmaCSD ) |
|
2254 { |
|
2255 index = iConnInfos.Find( aConnection, TConnInfo::MatchBearer ); |
|
2256 } |
|
2257 else if ( aConnection.iConnectionId > 0 ) |
|
2258 { |
|
2259 index = iConnInfos.Find( aConnection, TConnInfo::MatchId ); |
|
2260 } |
|
2261 else |
|
2262 { |
|
2263 index = iConnInfos.Find( aConnection, TConnInfo::MatchIap ); |
|
2264 } |
|
2265 |
|
2266 TInt err( KErrNotFound ); |
|
2267 if ( index >= 0 ) |
|
2268 { |
|
2269 // Set connection id for passing it back to the caller (client event) |
|
2270 aConnection.iConnectionId = iConnInfos[index].iConnectionId; |
|
2271 |
|
2272 // Remove threshold settings from the client tables |
|
2273 iServer->RemoveConnSettingsFromSessions( aConnection.iConnectionId ); |
|
2274 |
|
2275 // Stop notifications (data volume, connection status, etc.) |
|
2276 DeleteConnNotifications( index ); |
|
2277 |
|
2278 // Close attached connection |
|
2279 if ( iConnInfos[index].iConnAttach != 0 ) |
|
2280 { |
|
2281 iConnInfos[index].iConnAttach->Close(); |
|
2282 delete iConnInfos[index].iConnAttach; |
|
2283 iConnInfos[index].iConnAttach = NULL; |
|
2284 } |
|
2285 |
|
2286 iConnInfos.Remove( index ); |
|
2287 err = KErrNone; |
|
2288 } |
|
2289 |
|
2290 // Print connection info array to log |
|
2291 #ifdef _DEBUG |
|
2292 LOGIT("RemoveConnection: Connection info array:") |
|
2293 for ( TInt m = 0; m < iConnInfos.Count(); m++ ) |
|
2294 { |
|
2295 LOGIT4(" id %d, bearer %d, iapId %d, netId %d", iConnInfos[m].iConnectionId, |
|
2296 iConnInfos[m].iBearer, iConnInfos[m].iIapId, iConnInfos[m].iNetId) |
|
2297 } |
|
2298 #endif // _DEBUG |
|
2299 |
|
2300 LOGEXITFN1("CConnMonIAP::RemoveConnection()", err) |
|
2301 return err; |
|
2302 } |
|
2303 |
|
2304 // ----------------------------------------------------------------------------------- |
|
2305 // CConnMonIAP::CalculateNetworkStatus |
|
2306 // ----------------------------------------------------------------------------------- |
|
2307 // |
|
2308 TInt CConnMonIAP::CalculateNetworkStatus( const RPacketService::TStatus& aPacketStatus ) const |
|
2309 { |
|
2310 switch ( aPacketStatus ) |
|
2311 { |
|
2312 case ( RPacketService::EStatusUnattached ): |
|
2313 return EConnMonStatusUnattached; |
|
2314 |
|
2315 case ( RPacketService::EStatusAttached ): |
|
2316 return EConnMonStatusAttached; |
|
2317 |
|
2318 case ( RPacketService::EStatusActive ): |
|
2319 return EConnMonStatusActive; |
|
2320 |
|
2321 case ( RPacketService::EStatusSuspended ): |
|
2322 return EConnMonStatusSuspended; |
|
2323 |
|
2324 default: |
|
2325 break; |
|
2326 } |
|
2327 return aPacketStatus; |
|
2328 } |
|
2329 |
|
2330 // ----------------------------------------------------------------------------------- |
|
2331 // CConnMonIAP::CalculateNetworkRegistration |
|
2332 // ----------------------------------------------------------------------------------- |
|
2333 // |
|
2334 TInt CConnMonIAP::CalculateNetworkRegistration( |
|
2335 const RMobilePhone::TMobilePhoneRegistrationStatus& |
|
2336 aRegistration ) const |
|
2337 { |
|
2338 switch ( aRegistration ) |
|
2339 { |
|
2340 case ( RMobilePhone::ERegistrationUnknown ): |
|
2341 return ENetworkRegistrationUnknown; |
|
2342 |
|
2343 case ( RMobilePhone::ENotRegisteredNoService ): |
|
2344 return ENetworkRegistrationNoService; |
|
2345 |
|
2346 case ( RMobilePhone::ENotRegisteredEmergencyOnly ): |
|
2347 return ENetworkRegistrationEmergencyOnly; |
|
2348 |
|
2349 case ( RMobilePhone::ENotRegisteredSearching ): |
|
2350 return ENetworkRegistrationSearching; |
|
2351 |
|
2352 case ( RMobilePhone::ERegisteredBusy ): |
|
2353 return ENetworkRegistrationBusy; |
|
2354 |
|
2355 case ( RMobilePhone::ERegisteredOnHomeNetwork ): |
|
2356 return ENetworkRegistrationHomeNetwork; |
|
2357 |
|
2358 case ( RMobilePhone::ERegistrationDenied ): |
|
2359 return ENetworkRegistrationDenied; |
|
2360 |
|
2361 case ( RMobilePhone::ERegisteredRoaming ): |
|
2362 return ENetworkRegistrationRoaming; |
|
2363 |
|
2364 default: |
|
2365 break; |
|
2366 } |
|
2367 return aRegistration; |
|
2368 } |
|
2369 |
|
2370 // ----------------------------------------------------------------------------------- |
|
2371 // CConnMonIAP::CalculateNetworkRegistration_v2 |
|
2372 // ----------------------------------------------------------------------------------- |
|
2373 // |
|
2374 TInt CConnMonIAP::CalculateNetworkRegistration_v2( |
|
2375 const RMobilePhone::TMobilePhoneRegistrationStatus& |
|
2376 aRegistration ) const |
|
2377 { |
|
2378 switch ( aRegistration ) |
|
2379 { |
|
2380 case ( RMobilePhone::ERegistrationUnknown ): |
|
2381 return ENetworkRegistrationExtUnknown; |
|
2382 |
|
2383 case ( RMobilePhone::ENotRegisteredNoService ): |
|
2384 return ENetworkRegistrationExtNoService; |
|
2385 |
|
2386 case ( RMobilePhone::ENotRegisteredEmergencyOnly ): |
|
2387 return ENetworkRegistrationExtEmergencyOnly; |
|
2388 |
|
2389 case ( RMobilePhone::ENotRegisteredSearching ): |
|
2390 return ENetworkRegistrationExtSearching; |
|
2391 |
|
2392 case ( RMobilePhone::ERegisteredBusy ): |
|
2393 return ENetworkRegistrationExtBusy; |
|
2394 |
|
2395 case ( RMobilePhone::ERegisteredOnHomeNetwork ): |
|
2396 return ENetworkRegistrationExtHomeNetwork; |
|
2397 |
|
2398 case ( RMobilePhone::ERegistrationDenied ): |
|
2399 return ENetworkRegistrationExtDenied; |
|
2400 |
|
2401 case ( RMobilePhone::ERegisteredRoaming ): |
|
2402 { |
|
2403 RMobilePhone::TMobilePhoneNetworkInfoV1 network; |
|
2404 RMobilePhone::TMobilePhoneNetworkInfoV1Pckg networkPckg( network ); |
|
2405 |
|
2406 RMobilePhone::TMobilePhoneNetworkInfoV1 homeNetwork; |
|
2407 RMobilePhone::TMobilePhoneNetworkInfoV1Pckg homeNetworkPckg( homeNetwork ); |
|
2408 |
|
2409 TRequestStatus status( KErrNone ); |
|
2410 |
|
2411 iMobilePhone.GetCurrentNetwork(status, networkPckg); |
|
2412 User::WaitForRequest( status ); |
|
2413 |
|
2414 if(status.Int() == KErrNone) |
|
2415 { |
|
2416 iMobilePhone.GetHomeNetwork(status, homeNetworkPckg); |
|
2417 User::WaitForRequest( status ); |
|
2418 |
|
2419 if(network.iCountryCode.Compare(homeNetwork.iCountryCode) == 0) |
|
2420 { |
|
2421 return ENetworkRegistrationExtRoamingNational; |
|
2422 } |
|
2423 else |
|
2424 { |
|
2425 return ENetworkRegistrationExtRoamingInternational; |
|
2426 } |
|
2427 } |
|
2428 } |
|
2429 |
|
2430 default: |
|
2431 break; |
|
2432 } |
|
2433 return aRegistration; |
|
2434 } |
|
2435 |
|
2436 // ----------------------------------------------------------------------------- |
|
2437 // CConnMonIAP::IsEdgeCell |
|
2438 // ----------------------------------------------------------------------------- |
|
2439 // |
|
2440 TBool CConnMonIAP::IsEdgeCell() |
|
2441 { |
|
2442 LOGENTRFN("CConnMonIAP::IsEdgeCell()") |
|
2443 TBool edgeStatus( EFalse ); |
|
2444 |
|
2445 LOGTIMINGSTART("CConnMonIAP::IsEdgeCell") |
|
2446 |
|
2447 if ( FeatureManager::FeatureSupported( KFeatureIdEdgeKnowledge ) ) |
|
2448 { |
|
2449 RMmCustomAPI customApi; |
|
2450 RMmCustomAPI::TGprsInformation gprsInfo; |
|
2451 RMmCustomAPI::TGprsInformationPckg gprsInfoPckg( gprsInfo ); |
|
2452 TRequestStatus status( KErrNone ); |
|
2453 |
|
2454 TInt ret = customApi.Open( iMobilePhone ); |
|
2455 |
|
2456 if ( KErrNone == ret ) |
|
2457 { |
|
2458 customApi.GetEGprsInfo( status, gprsInfoPckg ); |
|
2459 User::WaitForRequest( status ); |
|
2460 |
|
2461 customApi.Close(); |
|
2462 |
|
2463 if ( KErrNone == status.Int() ) |
|
2464 { |
|
2465 if ( gprsInfoPckg().iGprsInfo == RMmCustomAPI::EEdgeGprs ) |
|
2466 { |
|
2467 edgeStatus = ETrue; |
|
2468 } |
|
2469 } |
|
2470 else |
|
2471 { |
|
2472 LOGIT1("IsEdgeCell: Error, RMmCustomAPI.GetEGprsInfo() <%d>", status.Int()) |
|
2473 } |
|
2474 } |
|
2475 else |
|
2476 { |
|
2477 LOGIT1("IsEdgeCell: Error, RMmCustomAPI.Open() <%d>", ret) |
|
2478 } |
|
2479 } |
|
2480 else |
|
2481 { |
|
2482 LOGIT("IsEdgeCell: KFeatureIdEdgeKnowledge not supported") |
|
2483 } |
|
2484 LOGTIMINGEND("CConnMonIAP::IsEdgeCell") |
|
2485 |
|
2486 LOGEXITFN1("CConnMonIAP::IsEdgeCell()", (TInt)edgeStatus) |
|
2487 return edgeStatus; |
|
2488 } |
|
2489 |
|
2490 // ----------------------------------------------------------------------------- |
|
2491 // CConnMonIAP::IsHsdpaCell |
|
2492 // ----------------------------------------------------------------------------- |
|
2493 // |
|
2494 TBool CConnMonIAP::IsHsdpaCell() |
|
2495 { |
|
2496 LOGENTRFN("CConnMonIAP::IsHsdpaCell()") |
|
2497 |
|
2498 RPacketService::TDynamicCapsFlags dynamicCaps( 0 ); |
|
2499 TBool hsdpaStatus( EFalse ); |
|
2500 |
|
2501 LOGTIMINGSTART("CConnMonIAP::IsHsdpaCell") |
|
2502 |
|
2503 TInt ret = iPacketService.GetDynamicCaps( dynamicCaps ); |
|
2504 if ( dynamicCaps & RPacketService::KCapsHSDPA ) |
|
2505 { |
|
2506 hsdpaStatus = ETrue; |
|
2507 } |
|
2508 LOGTIMINGEND("CConnMonIAP::IsHsdpaCell") |
|
2509 LOGIT2("IsHsdpaCell: Dynamic caps 0x%06X <%d>", dynamicCaps, ret) |
|
2510 |
|
2511 LOGEXITFN1("CConnMonIAP::IsHsdpaCell()", (TInt)hsdpaStatus) |
|
2512 return hsdpaStatus; |
|
2513 } |
|
2514 |
|
2515 // ----------------------------------------------------------------------------- |
|
2516 // CConnMonIAP::HsxpaStatus |
|
2517 // ----------------------------------------------------------------------------- |
|
2518 // |
|
2519 TInt CConnMonIAP::HsxpaStatus() |
|
2520 { |
|
2521 LOGENTRFN("CConnMonIAP::HsxpaStatus()") |
|
2522 |
|
2523 RPacketService::TDynamicCapsFlags dynamicCaps( 0 ); |
|
2524 TInt hspaState( EBearerInfoWCDMA ); |
|
2525 |
|
2526 LOGTIMINGSTART("CConnMonIAP::HsxpaStatus") |
|
2527 |
|
2528 TInt ret = iPacketService.GetDynamicCaps( dynamicCaps ); |
|
2529 if ( dynamicCaps & RPacketService::KCapsHSDPA ) |
|
2530 { |
|
2531 if ( dynamicCaps & RPacketService::KCapsHSUPA ) |
|
2532 { |
|
2533 hspaState = EBearerInfoHSxPA; |
|
2534 } |
|
2535 else |
|
2536 { |
|
2537 hspaState = EBearerInfoHSDPA; |
|
2538 } |
|
2539 } |
|
2540 else |
|
2541 { |
|
2542 if ( dynamicCaps & RPacketService::KCapsHSUPA ) |
|
2543 { |
|
2544 hspaState = EBearerInfoHSUPA; |
|
2545 } |
|
2546 else |
|
2547 { |
|
2548 hspaState = EBearerInfoWCDMA; |
|
2549 } |
|
2550 } |
|
2551 LOGTIMINGEND("CConnMonIAP::HsxpaStatus") |
|
2552 LOGIT2("HsxpaStatus: Dynamic caps 0x%06X <%d>", dynamicCaps, ret) |
|
2553 |
|
2554 LOGEXITFN1("CConnMonIAP::HsxpaStatus()", hspaState) |
|
2555 return hspaState; |
|
2556 } |
|
2557 |
|
2558 // ----------------------------------------------------------------------------- |
|
2559 // CConnMonIAP::GetStartTime |
|
2560 // ----------------------------------------------------------------------------- |
|
2561 // |
|
2562 TInt CConnMonIAP::GetStartTime( const TUint& aConnectionId, TTime& aTime ) |
|
2563 { |
|
2564 TInt err( KErrNone ); |
|
2565 |
|
2566 // Find connection matching the given Id |
|
2567 TInt index = Index( aConnectionId ); |
|
2568 |
|
2569 if ( index < 0 ) |
|
2570 { |
|
2571 return KErrNotFound; |
|
2572 } |
|
2573 |
|
2574 if ( iConnInfos[index].iBearer < EBearerExternalCSD |
|
2575 && iConnInfos[index].iBearerInfo.iBearer <= EBearerInfoHSxPA ) |
|
2576 { |
|
2577 // INTERNAL CONNECTIONS |
|
2578 TUint subConnectionCount( 0 ); |
|
2579 |
|
2580 // Find the start time of the earliest subconnection |
|
2581 err = iConnInfos[index].iConnAttach->EnumerateSubConnections( subConnectionCount ); |
|
2582 |
|
2583 if ( KErrNone != err ) |
|
2584 { |
|
2585 return err; |
|
2586 } |
|
2587 |
|
2588 LOGIT1("GetStartTime: Sub connection count %d", subConnectionCount) |
|
2589 for ( TUint i = 1; i <= subConnectionCount; i++ ) |
|
2590 { |
|
2591 TSubConnectionInfo subInfo; |
|
2592 TPckg<TSubConnectionInfo> pckgSubInfo( subInfo ); |
|
2593 |
|
2594 err = iConnInfos[index].iConnAttach->GetSubConnectionInfo( i, pckgSubInfo ); |
|
2595 |
|
2596 if ( KErrNone != err ) |
|
2597 { |
|
2598 LOGIT2("GetStartTime: Error getting conn.info for index %d, <%d>", i, err) |
|
2599 return err; |
|
2600 } |
|
2601 |
|
2602 if ( i == 1 ) |
|
2603 { |
|
2604 aTime = pckgSubInfo().iTimeStarted; |
|
2605 } |
|
2606 else if ( aTime > pckgSubInfo().iTimeStarted ) |
|
2607 { |
|
2608 aTime = pckgSubInfo().iTimeStarted; |
|
2609 } |
|
2610 } |
|
2611 } |
|
2612 else if ( iConnInfos[index].iBearer == EBearerExternalGPRS || |
|
2613 iConnInfos[index].iBearer == EBearerExternalEdgeGPRS || |
|
2614 iConnInfos[index].iBearer == EBearerExternalWCDMA || |
|
2615 iConnInfos[index].iBearer == EBearerExternalCDMA2000 || |
|
2616 ( !iConnInfos[index].iBearerInfo.iInternal && |
|
2617 ( iConnInfos[index].iBearerInfo.iBearer == EBearerInfoHSDPA || |
|
2618 iConnInfos[index].iBearerInfo.iBearer == EBearerInfoHSUPA || |
|
2619 iConnInfos[index].iBearerInfo.iBearer == EBearerInfoHSxPA ) ) ) |
|
2620 { |
|
2621 // EXTERNAL PSD |
|
2622 if ( iPsdFax ) |
|
2623 { |
|
2624 err = iPsdFax->GetStartTime( aConnectionId, aTime ); |
|
2625 |
|
2626 if ( KErrNone != err ) |
|
2627 { |
|
2628 return err; |
|
2629 } |
|
2630 } |
|
2631 else |
|
2632 { |
|
2633 return KErrNotFound; |
|
2634 } |
|
2635 } |
|
2636 else if ( iConnInfos[index].iBearer == EBearerExternalCSD || |
|
2637 iConnInfos[index].iBearer == EBearerExternalHSCSD || |
|
2638 iConnInfos[index].iBearer == EBearerExternalWcdmaCSD ) |
|
2639 { |
|
2640 // EXTERNAL CSD |
|
2641 if ( iCsdFax ) |
|
2642 { |
|
2643 err = iCsdFax->GetStartTime( aTime ); |
|
2644 |
|
2645 if ( KErrNone != err ) |
|
2646 { |
|
2647 return err; |
|
2648 } |
|
2649 } |
|
2650 else |
|
2651 { |
|
2652 err = KErrNotFound; |
|
2653 } |
|
2654 } |
|
2655 else |
|
2656 { |
|
2657 return KErrNotSupported; |
|
2658 } |
|
2659 |
|
2660 return err; |
|
2661 } |
|
2662 |
|
2663 // ----------------------------------------------------------------------------- |
|
2664 // CConnMonIAP::GetBearer |
|
2665 // Gets the bearer setting for the internal connections. |
|
2666 // ----------------------------------------------------------------------------- |
|
2667 // |
|
2668 TInt CConnMonIAP::GetBearer( |
|
2669 const TUint& aConnectionId, |
|
2670 TInt& aBearer, |
|
2671 TBearerInfo& aBearerInfo ) |
|
2672 { |
|
2673 TInt err( KErrNone ); |
|
2674 TUint32 bearerType( EBearerUnknown ); |
|
2675 TBuf<KCommsDbSvrMaxFieldLength> settingName; |
|
2676 TBuf<KCommsDbSvrMaxFieldLength> settingValue; |
|
2677 |
|
2678 LOGENTRFN("CConnMonIAP::GetBearer()") |
|
2679 |
|
2680 // Find connection matching the given Id |
|
2681 TInt index = Index( aConnectionId ); |
|
2682 if ( index < 0 ) |
|
2683 { |
|
2684 LOGEXITFN1("CConnMonIAP::GetBearer()", KErrNotFound) |
|
2685 return KErrNotFound; |
|
2686 } |
|
2687 |
|
2688 if ( iConnInfos[index].iConnAttach == 0 ) |
|
2689 { |
|
2690 LOGIT("GetBearer: error, iConnAttach was NULL") |
|
2691 LOGEXITFN1("CConnMonIAP::GetBearer()", KErrArgument) |
|
2692 return KErrArgument; |
|
2693 } |
|
2694 |
|
2695 // Find out BEARER TYPE |
|
2696 settingName.Copy( TPtrC( IAP ) ); |
|
2697 settingName.Append( TChar( '\\' ) ); |
|
2698 settingName.Append( TPtrC( IAP_BEARER_TYPE ) ); |
|
2699 |
|
2700 err = iConnInfos[index].iConnAttach->GetDesSetting( TPtrC( settingName ), settingValue ); |
|
2701 if ( KErrNone != err ) |
|
2702 { |
|
2703 LOGIT1("GetBearer: ERROR getting IAP bearer type <%d>", err) |
|
2704 LOGEXITFN1("CConnMonIAP::GetBearer()", err) |
|
2705 return err; |
|
2706 } |
|
2707 |
|
2708 if ( settingValue == TPtrC( VIRTUAL_BEARER ) ) |
|
2709 { |
|
2710 aBearer = EBearerVirtual; |
|
2711 aBearerInfo.iBearer = EBearerInfoVirtual; |
|
2712 aBearerInfo.iInternal = ETrue; |
|
2713 } |
|
2714 |
|
2715 // Find out SERVICE TYPE |
|
2716 settingName.Copy( TPtrC( IAP ) ); |
|
2717 settingName.Append( TChar( '\\' ) ); |
|
2718 settingName.Append( TPtrC( IAP_SERVICE_TYPE ) ); |
|
2719 |
|
2720 err = iConnInfos[index].iConnAttach->GetDesSetting( TPtrC( settingName ), settingValue ); |
|
2721 if ( KErrNone != err ) |
|
2722 { |
|
2723 LOGIT1("GetBearer: ERROR getting IAP service type <%d>", err) |
|
2724 LOGEXITFN1("CConnMonIAP::GetBearer()", err) |
|
2725 return err; |
|
2726 } |
|
2727 |
|
2728 // Is this virtual bearer + VPN service |
|
2729 if ( ( aBearer == EBearerVirtual ) && ( settingValue == TPtrC( VPN_SERVICE ) ) ) |
|
2730 { |
|
2731 aBearer = EBearerVirtualVPN; |
|
2732 aBearerInfo.iBearer = EBearerInfoVirtualVPN; |
|
2733 aBearerInfo.iInternal = ETrue; |
|
2734 } |
|
2735 |
|
2736 // Return if bearer has been solved |
|
2737 if ( aBearer != EBearerUnknown ) |
|
2738 { |
|
2739 LOGEXITFN1("CConnMonIAP::GetBearer()", KErrNone) |
|
2740 return KErrNone; |
|
2741 } |
|
2742 |
|
2743 // Study service type if bearer is still unknown |
|
2744 if ( settingValue == TPtrC( DIAL_OUT_ISP ) || settingValue == TPtrC( DIAL_IN_ISP ) ) |
|
2745 { |
|
2746 LOGIT("GetBearer: type is dial_x_isp") |
|
2747 settingName.Copy( settingValue ); |
|
2748 settingName.Append( TChar( '\\' ) ); |
|
2749 settingName.Append( TPtrC( ISP_BEARER_TYPE ) ); |
|
2750 |
|
2751 err = iConnInfos[index].iConnAttach->GetIntSetting( TPtrC( settingName ), bearerType ); |
|
2752 |
|
2753 if ( KErrNone != err ) |
|
2754 { |
|
2755 return err; |
|
2756 } |
|
2757 |
|
2758 if ( bearerType == EBearerTypeCSD ) |
|
2759 { |
|
2760 aBearer = EBearerCSD; |
|
2761 aBearerInfo.iBearer = EBearerInfoCSD; |
|
2762 aBearerInfo.iInternal = ETrue; |
|
2763 } |
|
2764 else |
|
2765 { |
|
2766 // EBearerTypeHSCSD |
|
2767 aBearer = EBearerHSCSD; |
|
2768 aBearerInfo.iBearer = EBearerInfoHSCSD; |
|
2769 aBearerInfo.iInternal = ETrue; |
|
2770 } |
|
2771 |
|
2772 if ( iTSYLoaded ) |
|
2773 { |
|
2774 RMobilePhone::TMobilePhoneNetworkMode mode; |
|
2775 |
|
2776 err = iMobilePhone.GetCurrentMode( mode ); |
|
2777 |
|
2778 if ( ( KErrNone == err ) && ( mode == RMobilePhone::ENetworkModeWcdma ) ) |
|
2779 { |
|
2780 aBearer = EBearerWcdmaCSD; |
|
2781 aBearerInfo.iBearer = EBearerInfoWcdmaCSD; |
|
2782 aBearerInfo.iInternal = ETrue; |
|
2783 } |
|
2784 } |
|
2785 |
|
2786 if ( aBearer == EBearerHSCSD || aBearer == EBearerCSD ) |
|
2787 { |
|
2788 // If TsyName == PHONETSY try to find out the real life situation (CSD/HSCSD) from ETel |
|
2789 // For point-to-point connections TSY is NOT PHONETSY. |
|
2790 settingName.Copy( TPtrC( IAP ) ); |
|
2791 settingName.Append( TChar( '\\' ) ); |
|
2792 settingName.Append( TPtrC( IAP_BEARER_TYPE ) ); |
|
2793 |
|
2794 err = iConnInfos[index].iConnAttach->GetDesSetting( |
|
2795 TPtrC( settingName ), |
|
2796 settingValue ); |
|
2797 |
|
2798 if ( ( KErrNone == err ) && ( settingValue == TPtrC( MODEM_BEARER ) ) ) |
|
2799 { |
|
2800 settingName.Copy( TPtrC( MODEM_BEARER ) ); |
|
2801 settingName.Append( TChar( '\\' ) ); |
|
2802 settingName.Append( TPtrC( MODEM_TSY_NAME ) ); |
|
2803 |
|
2804 err = iConnInfos[index].iConnAttach->GetDesSetting( |
|
2805 TPtrC( settingName ), |
|
2806 settingValue ); |
|
2807 |
|
2808 TBuf<KConnMonSmallBufferLen> tmp( KMmTsyModuleName ); |
|
2809 tmp.UpperCase(); |
|
2810 |
|
2811 if ( ( KErrNone == err ) && ( settingValue == tmp ) ) |
|
2812 { |
|
2813 // TSY is PHONETSY |
|
2814 TBuf<KConnMonSmallBufferLen> number; |
|
2815 |
|
2816 err = GetTelNumber( aConnectionId, number ); |
|
2817 |
|
2818 if ( KErrNone == err ) |
|
2819 { |
|
2820 GetBearerFromETel( number, aBearer, aBearerInfo ); |
|
2821 } |
|
2822 } |
|
2823 } |
|
2824 } |
|
2825 } |
|
2826 else if ( settingValue == TPtrC( OUTGOING_WCDMA ) || |
|
2827 settingValue == TPtrC( INCOMING_WCDMA ) ) |
|
2828 { |
|
2829 LOGIT("GetBearer: type is wcdma") |
|
2830 if ( iTSYLoaded ) |
|
2831 { |
|
2832 RMobilePhone::TMobilePhoneNetworkMode mode; |
|
2833 err = iMobilePhone.GetCurrentMode( mode ); |
|
2834 LOGIT2("GetBearer: phone mode %d <%d>", (TInt)mode, err) |
|
2835 if ( ( KErrNone != err ) || |
|
2836 ( mode == RMobilePhone::ENetworkModeUnknown ) || |
|
2837 ( mode == RMobilePhone::ENetworkModeUnregistered ) ) |
|
2838 { |
|
2839 // MODE is UNKNOWN |
|
2840 LOGIT2("GetBearer: mode is unknown %d <%d>", mode, err) |
|
2841 if ( FeatureManager::FeatureSupported( KFeatureIdProtocolGsm ) ) |
|
2842 { |
|
2843 // KFeatureIdProtocolGsm means that phone supports only GSM |
|
2844 if ( IsEdgeCell() ) |
|
2845 { |
|
2846 aBearer = EBearerEdgeGPRS; |
|
2847 aBearerInfo.iBearer = EBearerInfoEdgeGPRS; |
|
2848 } |
|
2849 else |
|
2850 { |
|
2851 aBearer = EBearerGPRS; |
|
2852 aBearerInfo.iBearer = EBearerInfoGPRS; |
|
2853 } |
|
2854 aBearerInfo.iInternal = ETrue; |
|
2855 } |
|
2856 else |
|
2857 { |
|
2858 LOGIT("GetBearer: KFeatureIdProtocolGsm not supported") |
|
2859 } |
|
2860 } |
|
2861 else |
|
2862 { |
|
2863 // MODE is KNOWN |
|
2864 if ( mode == RMobilePhone::ENetworkModeWcdma ) |
|
2865 { |
|
2866 aBearer = EBearerWCDMA; |
|
2867 aBearerInfo.iBearer = HsxpaStatus(); |
|
2868 aBearerInfo.iInternal = ETrue; |
|
2869 } |
|
2870 else if ( mode == RMobilePhone::ENetworkModeGsm ) |
|
2871 { |
|
2872 if ( IsEdgeCell() ) |
|
2873 { |
|
2874 aBearer = EBearerEdgeGPRS; |
|
2875 aBearerInfo.iBearer = EBearerInfoEdgeGPRS; |
|
2876 } |
|
2877 else |
|
2878 { |
|
2879 aBearer = EBearerGPRS; |
|
2880 aBearerInfo.iBearer = EBearerInfoGPRS; |
|
2881 } |
|
2882 aBearerInfo.iInternal = ETrue; |
|
2883 } |
|
2884 else |
|
2885 { |
|
2886 LOGIT1("GetBearer: error, mode was unexpected %d", mode) |
|
2887 } |
|
2888 } |
|
2889 } |
|
2890 } |
|
2891 |
|
2892 else if ( settingValue == TPtrC( LAN_SERVICE ) ) |
|
2893 { |
|
2894 LOGIT("GetBearer: type is (w)lan") |
|
2895 aBearer = EBearerLAN; |
|
2896 aBearerInfo.iBearer = EBearerInfoLAN; |
|
2897 aBearerInfo.iInternal = ETrue; |
|
2898 |
|
2899 settingName.FillZ(); |
|
2900 settingValue.FillZ(); |
|
2901 settingName.Copy( TPtrC( LAN_BEARER ) ); |
|
2902 settingName.Append( TChar( '\\' ) ); |
|
2903 settingName.Append( TPtrC( COMMDB_NAME ) ); |
|
2904 |
|
2905 err = iConnInfos[index].iConnAttach->GetDesSetting( TPtrC( settingName ), settingValue ); |
|
2906 |
|
2907 if ( KErrNone != err ) |
|
2908 { |
|
2909 return err; |
|
2910 } |
|
2911 |
|
2912 if ( settingValue == TPtrC( KWlanBearerRecordName ) ) |
|
2913 { |
|
2914 aBearer = EBearerWLAN; |
|
2915 aBearerInfo.iBearer = EBearerInfoWLAN; |
|
2916 } |
|
2917 } |
|
2918 LOGIT2("GetBearer: bearer %d, bearerInfo %d", aBearer, aBearerInfo.iBearer) |
|
2919 LOGEXITFN1("CConnMonIAP::GetBearer()", err) |
|
2920 return err; |
|
2921 } |
|
2922 |
|
2923 // ----------------------------------------------------------------------------------- |
|
2924 // CConnMonIAP::UpdateActivity |
|
2925 // Updates connection activity information. |
|
2926 // ----------------------------------------------------------------------------------- |
|
2927 // |
|
2928 TInt CConnMonIAP::UpdateActivity( const TUint& aConnectionId, const TUint& aActivity ) |
|
2929 { |
|
2930 // Find connection matching the given Id |
|
2931 TInt index = Index( aConnectionId ); |
|
2932 |
|
2933 if ( index < 0 ) |
|
2934 { |
|
2935 return KErrNotFound; |
|
2936 } |
|
2937 |
|
2938 if ( aActivity == 0 ) |
|
2939 { |
|
2940 iConnInfos[index].iActivity = 0; |
|
2941 } |
|
2942 else |
|
2943 { |
|
2944 iConnInfos[index].iActivity = 1; |
|
2945 } |
|
2946 |
|
2947 return KErrNone; |
|
2948 } |
|
2949 |
|
2950 // ----------------------------------------------------------------------------------- |
|
2951 // CConnMonIAP::GetDeleteNotifyStatus |
|
2952 // ----------------------------------------------------------------------------------- |
|
2953 // |
|
2954 TInt CConnMonIAP::GetDeleteNotifyStatus( TConnInfo& aConnection, TBool& aSent ) |
|
2955 { |
|
2956 TInt index( KErrNotFound ); |
|
2957 |
|
2958 if ( aConnection.iBearer >= EBearerExternalCSD ) |
|
2959 { |
|
2960 return KErrNotSupported; |
|
2961 } |
|
2962 |
|
2963 index = iConnInfos.Find( aConnection, TConnInfo::MatchIap ); |
|
2964 |
|
2965 if ( index < 0 ) |
|
2966 { |
|
2967 return KErrNotFound; |
|
2968 } |
|
2969 |
|
2970 aConnection.iConnectionId = iConnInfos[index].iConnectionId; |
|
2971 aConnection.iBearer = iConnInfos[index].iBearer; |
|
2972 |
|
2973 TInt connectionStatus( 0 ); |
|
2974 GetConnectionStatus( index, connectionStatus ); |
|
2975 |
|
2976 if ( ( iConnInfos[index].iConnDownNotifier != 0 ) && |
|
2977 ( iConnInfos[index].iProgressNotifier != 0 ) ) |
|
2978 { |
|
2979 if ( !iConnInfos[index].iConnDownNotifier->DeleteSent() && |
|
2980 !iConnInfos[index].iConnDownNotifier->IsActive() && |
|
2981 ( !iConnInfos[index].iProgressNotifier->IsActive() || |
|
2982 ( connectionStatus != KLinkLayerOpen ) ) ) |
|
2983 { |
|
2984 aSent = EFalse; |
|
2985 } |
|
2986 else |
|
2987 { |
|
2988 aSent = ETrue; |
|
2989 } |
|
2990 } |
|
2991 else |
|
2992 { |
|
2993 aSent = EFalse; |
|
2994 } |
|
2995 |
|
2996 return KErrNone; |
|
2997 } |
|
2998 |
|
2999 // ----------------------------------------------------------------------------------- |
|
3000 // CConnMonIAP::GetActivityNotifier |
|
3001 // ----------------------------------------------------------------------------------- |
|
3002 // |
|
3003 TInt CConnMonIAP::GetActivityNotifier( |
|
3004 const TUint& aConnectionId, |
|
3005 CActivityNotifier** aActivityNotifier ) |
|
3006 { |
|
3007 // Find connection matching the given Id |
|
3008 TInt index = Index( aConnectionId ); |
|
3009 |
|
3010 if ( index < 0 ) |
|
3011 { |
|
3012 return KErrNotFound; |
|
3013 } |
|
3014 |
|
3015 if ( aActivityNotifier == 0 ) |
|
3016 { |
|
3017 return KErrUnknown; |
|
3018 } |
|
3019 |
|
3020 *aActivityNotifier = iConnInfos[ index ].iActivityNotifier; |
|
3021 |
|
3022 return KErrNone; |
|
3023 } |
|
3024 |
|
3025 // ----------------------------------------------------------------------------------- |
|
3026 // CConnMonIAP::GetProgressNotifier |
|
3027 // ----------------------------------------------------------------------------------- |
|
3028 // |
|
3029 TInt CConnMonIAP::GetProgressNotifier( |
|
3030 const TUint& aConnectionId, |
|
3031 CProgressNotifier** aProgressNotifier ) |
|
3032 { |
|
3033 // Find connection matching the given Id |
|
3034 TInt index = Index( aConnectionId ); |
|
3035 |
|
3036 if ( index < 0 ) |
|
3037 { |
|
3038 return KErrNotFound; |
|
3039 } |
|
3040 |
|
3041 if ( aProgressNotifier == 0 ) |
|
3042 { |
|
3043 return KErrUnknown; |
|
3044 } |
|
3045 |
|
3046 *aProgressNotifier = iConnInfos[index].iProgressNotifier; |
|
3047 |
|
3048 return KErrNone; |
|
3049 } |
|
3050 |
|
3051 // ----------------------------------------------------------------------------------- |
|
3052 // CConnMonIAP::GetSubConnUpDownNotifier |
|
3053 // ----------------------------------------------------------------------------------- |
|
3054 // |
|
3055 TInt CConnMonIAP::GetSubConnUpDownNotifier( |
|
3056 const TUint& aConnectionId, |
|
3057 CSubConnUpDownNotifier** aSubConnUpDownNotifier ) |
|
3058 { |
|
3059 // Find connection matching the given Id |
|
3060 TInt index = Index( aConnectionId ); |
|
3061 |
|
3062 if ( index < 0 ) |
|
3063 { |
|
3064 return KErrNotFound; |
|
3065 } |
|
3066 |
|
3067 if ( aSubConnUpDownNotifier == 0 ) |
|
3068 { |
|
3069 return KErrUnknown; |
|
3070 } |
|
3071 |
|
3072 *aSubConnUpDownNotifier = iConnInfos[index].iConnDownNotifier; |
|
3073 |
|
3074 return KErrNone; |
|
3075 } |
|
3076 |
|
3077 // ----------------------------------------------------------------------------------- |
|
3078 // CConnMonIAP::WakeUpNotifications |
|
3079 // Wakes up sleeping CONNECTION SPECIFIC event watchers that depend on a threshold. |
|
3080 // (data volume, activity). |
|
3081 // ----------------------------------------------------------------------------------- |
|
3082 // |
|
3083 TInt CConnMonIAP::WakeUpNotifications( const TUint& aConnectionId ) |
|
3084 { |
|
3085 // Find connection matching the given Id |
|
3086 TInt index = Index( aConnectionId ); |
|
3087 |
|
3088 if ( index < 0 ) |
|
3089 { |
|
3090 return KErrNotFound; |
|
3091 } |
|
3092 |
|
3093 if ( ( iConnInfos[index].iBearer < EBearerExternalCSD ) && ( iCountListeners > 0 ) ) |
|
3094 { |
|
3095 // INTERNAL CONNECTIONS |
|
3096 TInt connectionStatus( 0 ); |
|
3097 GetConnectionStatus( index, connectionStatus ); |
|
3098 |
|
3099 if ( ( connectionStatus == KLinkLayerOpen ) || ( connectionStatus == KPsdSuspended ) ) |
|
3100 { |
|
3101 // ------------------------- |
|
3102 // Amount of Downlink data |
|
3103 // ------------------------- |
|
3104 if ( iConnInfos[index].iDLDataNotifier != 0 ) |
|
3105 { |
|
3106 if ( !iConnInfos[index].iDLDataNotifier->IsActive() ) |
|
3107 { |
|
3108 iConnInfos[index].iDLDataNotifier->Receive(); // (re)start listening |
|
3109 } |
|
3110 } |
|
3111 |
|
3112 // ------------------------- |
|
3113 // Amount of Uplink data |
|
3114 // ------------------------- |
|
3115 if ( iConnInfos[index].iULDataNotifier != 0 ) |
|
3116 { |
|
3117 if ( !iConnInfos[index].iULDataNotifier->IsActive() ) |
|
3118 { |
|
3119 iConnInfos[index].iULDataNotifier->Receive(); // (re)start listening |
|
3120 } |
|
3121 } |
|
3122 |
|
3123 // ---------------------- |
|
3124 // Connection Activity |
|
3125 // ---------------------- |
|
3126 if ( iConnInfos[index].iActivityNotifier != 0 ) |
|
3127 { |
|
3128 if ( !iConnInfos[index].iActivityNotifier->IsActive() ) |
|
3129 { |
|
3130 iConnInfos[index].iActivityNotifier->Receive( iConnInfos[index].iActivity ); |
|
3131 } |
|
3132 } |
|
3133 |
|
3134 if ( iConnInfos[index].iBearerNotifier ) |
|
3135 { |
|
3136 if ( !iConnInfos[index].iBearerNotifier->Listening() ) |
|
3137 { |
|
3138 iConnInfos[index].iBearerNotifier->Listen(); |
|
3139 } |
|
3140 } |
|
3141 } |
|
3142 } |
|
3143 |
|
3144 return KErrNone; |
|
3145 } |
|
3146 |
|
3147 // ----------------------------------------------------------------------------------- |
|
3148 // CConnMonIAP::WakeUpNotifications |
|
3149 // Wakes up GENERAL sleeping event watchers that depend on a threshold. |
|
3150 // (signal strength, bearer availability). |
|
3151 // ----------------------------------------------------------------------------------- |
|
3152 // |
|
3153 TInt CConnMonIAP::WakeUpNotifications() |
|
3154 { |
|
3155 if ( iGSMSignalNotifier != 0 ) |
|
3156 { |
|
3157 if ( !iGSMSignalNotifier->IsActive() ) |
|
3158 { |
|
3159 iGSMSignalNotifier->Receive(); // (re)start listening |
|
3160 } |
|
3161 } |
|
3162 |
|
3163 if ( iGSMBearerAvailabilityNotifier != 0 ) |
|
3164 { |
|
3165 if ( !iGSMBearerAvailabilityNotifier->IsActive() ) |
|
3166 { |
|
3167 iGSMBearerAvailabilityNotifier->Receive(); // (re)start listening |
|
3168 } |
|
3169 } |
|
3170 |
|
3171 return KErrNone; |
|
3172 } |
|
3173 |
|
3174 // ----------------------------------------------------------------------------------- |
|
3175 // CConnMonIAP::LaunchActivityNotifierL |
|
3176 // Launches the activity notifier for the given connection id. |
|
3177 // ----------------------------------------------------------------------------------- |
|
3178 // |
|
3179 TInt CConnMonIAP::LaunchActivityNotifierL( const TUint& aConnectionId ) |
|
3180 { |
|
3181 TInt index = Index( aConnectionId ); |
|
3182 |
|
3183 if ( index < 0 ) |
|
3184 { |
|
3185 return KErrNotFound; |
|
3186 } |
|
3187 |
|
3188 GetActivityOneShotL( index ); |
|
3189 return KErrNone; |
|
3190 } |
|
3191 |
|
3192 // ----------------------------------------------------------------------------------- |
|
3193 // CConnMonIAP::LaunchDataNotifiers |
|
3194 // Launches the data notifiers (uplink & downlink) for the given connection id. |
|
3195 // ----------------------------------------------------------------------------------- |
|
3196 // |
|
3197 TInt CConnMonIAP::LaunchDataNotifiers( const TUint& aConnectionId ) |
|
3198 { |
|
3199 TInt index = Index( aConnectionId ); |
|
3200 |
|
3201 if ( index < 0 ) |
|
3202 { |
|
3203 return KErrNotFound; |
|
3204 } |
|
3205 |
|
3206 if ( iConnInfos[index].iDLDataNotifier != 0 ) |
|
3207 { |
|
3208 if ( !iConnInfos[index].iDLDataNotifier->IsActive() ) |
|
3209 { |
|
3210 iConnInfos[index].iDLDataNotifier->Receive(); |
|
3211 } |
|
3212 } |
|
3213 |
|
3214 if ( iConnInfos[index].iULDataNotifier != 0 ) |
|
3215 { |
|
3216 if ( !iConnInfos[index].iULDataNotifier->IsActive() ) |
|
3217 { |
|
3218 iConnInfos[index].iULDataNotifier->Receive(); |
|
3219 } |
|
3220 } |
|
3221 |
|
3222 return KErrNone; |
|
3223 } |
|
3224 |
|
3225 // ----------------------------------------------------------------------------------- |
|
3226 // CConnMonIAP::LaunchDataNotifiers |
|
3227 // Launches the data notifiers (uplink & downlink) for the given connection id. |
|
3228 // ----------------------------------------------------------------------------------- |
|
3229 // |
|
3230 TInt CConnMonIAP::LaunchBearerNotifier( const TUint& aConnectionId ) |
|
3231 { |
|
3232 TInt index = Index( aConnectionId ); |
|
3233 |
|
3234 if ( index < 0 ) |
|
3235 { |
|
3236 return KErrNotFound; |
|
3237 } |
|
3238 |
|
3239 if ( iConnInfos[index].iBearerNotifier ) |
|
3240 { |
|
3241 if ( !iConnInfos[index].iBearerNotifier->Listening() ) |
|
3242 { |
|
3243 iConnInfos[index].iBearerNotifier->Listen(); |
|
3244 } |
|
3245 } |
|
3246 |
|
3247 return KErrNone; |
|
3248 } |
|
3249 |
|
3250 |
|
3251 // ----------------------------------------------------------------------------- |
|
3252 // CConnMonIAP::AppendActiveConnections |
|
3253 // ----------------------------------------------------------------------------- |
|
3254 // |
|
3255 void CConnMonIAP::GetActiveConnectionsIds( const TUint& aBearerId, RArray<TUint>& aIdArray ) |
|
3256 { |
|
3257 //LOGENTRFN("CConnMonIAP::GetActiveConnectionsIds()") |
|
3258 |
|
3259 const TInt count = iConnInfos.Count(); |
|
3260 for ( TInt i = 0; i < count; i++ ) |
|
3261 { |
|
3262 // Bearer might still be uninitialized |
|
3263 if ( iConnInfos[i].iBearer == EBearerUnknown ) |
|
3264 { |
|
3265 LOGIT1("GetActiveConnectionsIds: bearer unknown for conn.id %d", |
|
3266 iConnInfos[i].iConnectionId) |
|
3267 TInt err = GetBearer( |
|
3268 iConnInfos[i].iConnectionId, |
|
3269 iConnInfos[i].iBearer, |
|
3270 iConnInfos[i].iBearerInfo ); |
|
3271 |
|
3272 if ( KErrNone != err ) |
|
3273 { |
|
3274 // Skip because bearer is unknown. This connection has not yet fully started. |
|
3275 continue; |
|
3276 } |
|
3277 } |
|
3278 switch ( iConnInfos[i].iBearer ) |
|
3279 { |
|
3280 case EBearerGPRS: |
|
3281 case EBearerEdgeGPRS: |
|
3282 case EBearerWCDMA: |
|
3283 { |
|
3284 if ( aBearerId == EBearerIdGPRS ) |
|
3285 { |
|
3286 aIdArray.Append( iConnInfos[i].iIapId ); |
|
3287 } |
|
3288 } |
|
3289 break; |
|
3290 case EBearerWLAN: |
|
3291 { |
|
3292 if ( aBearerId == EBearerIdWLAN ) |
|
3293 { |
|
3294 TInt connectionStatus( 0 ); |
|
3295 GetConnectionStatus( i, connectionStatus ); |
|
3296 if ( connectionStatus == KLinkLayerOpen ) |
|
3297 { |
|
3298 aIdArray.Append( iConnInfos[i].iIapId ); |
|
3299 } |
|
3300 } |
|
3301 } |
|
3302 break; |
|
3303 case EBearerCSD: |
|
3304 case EBearerHSCSD: |
|
3305 case EBearerWcdmaCSD: |
|
3306 { |
|
3307 if ( aBearerId == EBearerIdCSD ) |
|
3308 { |
|
3309 aIdArray.Append( iConnInfos[i].iIapId ); |
|
3310 } |
|
3311 } |
|
3312 break; |
|
3313 case EBearerLAN: |
|
3314 { |
|
3315 if ( aBearerId == EBearerIdLAN ) |
|
3316 { |
|
3317 aIdArray.Append( iConnInfos[i].iIapId ); |
|
3318 } |
|
3319 } |
|
3320 break; |
|
3321 default: |
|
3322 break; |
|
3323 } |
|
3324 } |
|
3325 //LOGEXITFN("CConnMonIAP::GetActiveConnectionsIds()") |
|
3326 } |
|
3327 |
|
3328 |
|
3329 // ----------------------------------------------------------------------------- |
|
3330 // CConnMonIAP::GetBearerSupportInfo |
|
3331 // Checks whether the current cell and the phone support a bearer (GPRS or CSD). |
|
3332 // ----------------------------------------------------------------------------- |
|
3333 // |
|
3334 TInt CConnMonIAP::GetBearerSupportInfo( |
|
3335 const TUint aConnectionId, |
|
3336 TBool& aByCell, |
|
3337 TBool& aByPhone ) const |
|
3338 { |
|
3339 LOGENTRFN("CConnMonIAP::GetBearerSupportInfo()") |
|
3340 TInt err( KErrNone ); |
|
3341 |
|
3342 aByCell = EFalse; |
|
3343 aByPhone = EFalse; |
|
3344 |
|
3345 if ( !iTSYLoaded ) |
|
3346 { |
|
3347 LOGIT("GetBearerSupportInfo: ERROR, TSY not loaded") |
|
3348 LOGEXITFN1("CConnMonIAP::GetBearerSupportInfo()", err) |
|
3349 return err; |
|
3350 } |
|
3351 |
|
3352 RPacketService::TDynamicCapsFlags capsDynamic( 0 ); |
|
3353 if ( iPacketServLoaded ) |
|
3354 { |
|
3355 err = iPacketService.GetDynamicCaps( capsDynamic ); |
|
3356 if ( KErrNone != err ) |
|
3357 { |
|
3358 LOGIT1("GetBearerSupportInfo: ERROR getting dynamic caps <%d>", err) |
|
3359 capsDynamic = 0; |
|
3360 } |
|
3361 } |
|
3362 |
|
3363 if ( aConnectionId == EBearerIdGPRS || aConnectionId == EBearerIdWCDMA ) |
|
3364 { |
|
3365 LOGIT2("GetBearerSupportInfo: GPRS and WCDMA, dynamic caps: 0x%04X <%d>", capsDynamic, err) |
|
3366 |
|
3367 // 1. Is GPRS/WCDMA supported by this NETWORK CELL |
|
3368 if ( ( capsDynamic & RPacketService::KCapsManualAttach ) || |
|
3369 ( capsDynamic & RPacketService::KCapsManualDetach ) ) |
|
3370 { |
|
3371 // Is the phone registered on the packet network |
|
3372 RPacketService::TRegistrationStatus nwRegStatus( RPacketService::EUnknown ); |
|
3373 TRequestStatus status( KErrNone ); |
|
3374 iPacketService.GetNtwkRegStatus( status, nwRegStatus ); |
|
3375 User::WaitForRequest( status ); |
|
3376 |
|
3377 LOGIT2("GetBearerSupportInfo: pckt service ntwrk reg status: %d <%d>", nwRegStatus, status.Int()) |
|
3378 if ( KErrNone == status.Int() && |
|
3379 nwRegStatus != RPacketService::ENotRegisteredNotSearching && |
|
3380 nwRegStatus != RPacketService::ENotRegisteredSearching && |
|
3381 nwRegStatus != RPacketService::ERegistrationDenied && |
|
3382 nwRegStatus != RPacketService::ENotRegisteredAndNotAvailable ) |
|
3383 { |
|
3384 // Query the TSY for the attach mode |
|
3385 RPacketService::TAttachMode attachMode( RPacketService::EAttachWhenNeeded ); |
|
3386 err = iPacketService.GetAttachMode( attachMode ); |
|
3387 |
|
3388 LOGIT2("GetBearerSupportInfo: pckt service attach mode: %d <%d>", attachMode, err) |
|
3389 // Query packet network status (but only if the TSY is set to attach when possible) |
|
3390 if ( KErrNone == err && attachMode == RPacketService::EAttachWhenPossible ) |
|
3391 { |
|
3392 RPacketService::TStatus pcktStatus( RPacketService::EStatusUnattached ); |
|
3393 err = iPacketService.GetStatus( pcktStatus ); |
|
3394 |
|
3395 LOGIT2("GetBearerSupportInfo: pckt service status: %d <%d>", pcktStatus, err) |
|
3396 if ( KErrNone == err && pcktStatus != RPacketService::EStatusUnattached ) |
|
3397 { |
|
3398 aByCell = ETrue; |
|
3399 } |
|
3400 } |
|
3401 else |
|
3402 { |
|
3403 // Attach mode is 'EAttachWhenNeeded' |
|
3404 aByCell = ETrue; |
|
3405 } |
|
3406 } |
|
3407 } |
|
3408 |
|
3409 // 2. Check the PHONE'S MODE if it is known |
|
3410 TUint bearerId( 0 ); |
|
3411 err = GetBearerId( bearerId ); |
|
3412 |
|
3413 // If phone mode query failed, mode is unknown, or bearer ID equals connection ID. |
|
3414 if ( bearerId == 0 || bearerId == aConnectionId ) |
|
3415 { |
|
3416 // 3. Check the PHONE'S MODE CAPABILITIES |
|
3417 TUint32 capsPhone( 0 ); |
|
3418 err = iMobilePhone.GetMultimodeCaps( capsPhone ); |
|
3419 |
|
3420 LOGIT2("GetBearerSupportInfo: mobile phone mode caps: 0x%04X <%d>", capsPhone, err) |
|
3421 if ( KErrNone == err ) |
|
3422 { |
|
3423 if ( aConnectionId == EBearerIdGPRS && |
|
3424 ( capsPhone & RMobilePhone::KCapsGprsSupported ) ) |
|
3425 { |
|
3426 aByPhone = ETrue; |
|
3427 } |
|
3428 else if ( aConnectionId == EBearerIdWCDMA && |
|
3429 ( capsPhone & |
|
3430 ( RMobilePhone::KCapsWcdmaSupported | |
|
3431 RMobilePhone::KCapsGprsSupported ) ) ) |
|
3432 { |
|
3433 aByPhone = ETrue; |
|
3434 } |
|
3435 } |
|
3436 } |
|
3437 } |
|
3438 else if ( aConnectionId == EBearerIdCSD || aConnectionId == EBearerIdWcdmaCSD ) |
|
3439 { |
|
3440 LOGIT2("GetBearerSupportInfo: CSD and WcdmaCSD, dynamic caps: 0x%04X <%d>", capsDynamic, err) |
|
3441 |
|
3442 // 1. Is CSD/WcdmaCSD supported by this NETWORK CELL |
|
3443 if ( capsDynamic & RPacketService::KCapsRxCSCall ) |
|
3444 { |
|
3445 // Has phone registered to the network |
|
3446 TRequestStatus status( KErrNone ); |
|
3447 RMobilePhone::TMobilePhoneRegistrationStatus gsmReg( |
|
3448 RMobilePhone::ERegistrationUnknown ); |
|
3449 |
|
3450 iMobilePhone.GetNetworkRegistrationStatus( status, gsmReg ); |
|
3451 User::WaitForRequest( status ); |
|
3452 |
|
3453 LOGIT2("GetBearerSupportInfo: mobile phone reg status: %d <%d>", gsmReg, status.Int()) |
|
3454 if ( KErrNone == status.Int() ) |
|
3455 { |
|
3456 if ( gsmReg == RMobilePhone::ERegisteredBusy || |
|
3457 gsmReg == RMobilePhone::ERegisteredOnHomeNetwork || |
|
3458 gsmReg == RMobilePhone::ERegisteredRoaming ) |
|
3459 { |
|
3460 aByCell = ETrue; |
|
3461 } |
|
3462 } |
|
3463 } |
|
3464 |
|
3465 // 2. Check the PHONE'S MODE if it is known |
|
3466 TUint bearerId( 0 ); |
|
3467 err = GetBearerId( bearerId, ETrue ); |
|
3468 |
|
3469 // If phone mode query failed, mode is unknown, or bearer ID equals connection ID. |
|
3470 if ( bearerId == 0 || bearerId == aConnectionId ) |
|
3471 { |
|
3472 // 3. Check the PHONE'S CAPABILITIES |
|
3473 err = iTelServer.IsSupportedByModule( |
|
3474 KMmTsyModuleName, |
|
3475 KETelFuncMobileDataCall, |
|
3476 aByPhone ); |
|
3477 } |
|
3478 } |
|
3479 else |
|
3480 { |
|
3481 LOGIT1("GetBearerSupportInfo: invalid connection id: %d", aConnectionId) |
|
3482 err = KErrArgument; |
|
3483 } |
|
3484 |
|
3485 LOGIT2("GetBearerSupportInfo: by cell: %d, by phone: %d", aByCell, aByPhone) |
|
3486 LOGEXITFN1("CConnMonIAP::GetBearerSupportInfo()", err) |
|
3487 return err; |
|
3488 } |
|
3489 |
|
3490 // ----------------------------------------------------------------------------------- |
|
3491 // CConnMonIAP::GetBearerId |
|
3492 // Gets the bearer ID matching the phone's current mode. |
|
3493 // ----------------------------------------------------------------------------------- |
|
3494 // |
|
3495 TInt CConnMonIAP::GetBearerId( TUint& aBearerId, TBool aCsd ) const |
|
3496 { |
|
3497 aBearerId = 0; |
|
3498 RMobilePhone::TMobilePhoneNetworkMode mode; |
|
3499 TInt err = iMobilePhone.GetCurrentMode( mode ); |
|
3500 // If GetCurrentMode() failed for any reason, aBearerId will be 0. |
|
3501 |
|
3502 LOGIT2("CConnMonIAP::GetBearerId(): current phone mode %d <%d>", mode, err) |
|
3503 if ( err == KErrNone ) |
|
3504 { |
|
3505 switch ( mode ) |
|
3506 { |
|
3507 case RMobilePhone::ENetworkModeWcdma: |
|
3508 if ( aCsd ) |
|
3509 { |
|
3510 aBearerId = EBearerIdWcdmaCSD; |
|
3511 } |
|
3512 else |
|
3513 { |
|
3514 aBearerId = EBearerIdWCDMA; |
|
3515 } |
|
3516 break; |
|
3517 |
|
3518 case RMobilePhone::ENetworkModeGsm: |
|
3519 case RMobilePhone::ENetworkModeUnknown: // Emulator default |
|
3520 if ( aCsd ) |
|
3521 { |
|
3522 aBearerId = EBearerIdCSD; |
|
3523 } |
|
3524 else |
|
3525 { |
|
3526 aBearerId = EBearerIdGPRS; |
|
3527 } |
|
3528 break; |
|
3529 |
|
3530 case RMobilePhone::ENetworkModeCdma2000: |
|
3531 aBearerId = EBearerIdCDMA2000; |
|
3532 break; |
|
3533 |
|
3534 // ENetworkModeUnregistered |
|
3535 // ENetworkModeAmps |
|
3536 // ENetworkModeCdma95 |
|
3537 // ENetworkModeTdcdma |
|
3538 default: |
|
3539 break; |
|
3540 } |
|
3541 } |
|
3542 return err; |
|
3543 } |
|
3544 |
|
3545 // ----------------------------------------------------------------------------------- |
|
3546 // CConnMonIAP::Reconnect |
|
3547 // A new connection has been established by reconnecting to an old connection. |
|
3548 // ----------------------------------------------------------------------------------- |
|
3549 // |
|
3550 TInt CConnMonIAP::Reconnect( TUint& aConnectionId ) |
|
3551 { |
|
3552 LOGENTRFN("CConnMonIAP::Reconnect()") |
|
3553 TInt err( KErrNone ); |
|
3554 |
|
3555 TInt index = Index( aConnectionId ); |
|
3556 if ( index < 0 ) |
|
3557 { |
|
3558 //return KErrNotFound; |
|
3559 err = KErrNotFound; |
|
3560 } |
|
3561 else |
|
3562 { |
|
3563 // Prevent ConnDown notifier from being deleted |
|
3564 // It will destroy itself later in reconnect case. |
|
3565 iConnInfos[index].iConnDownNotifier = 0; |
|
3566 TBearerInfo bearerInfo( EBearerInfoUnknown, EFalse ); |
|
3567 |
|
3568 TConnInfo connInfo( iConnInfos[index].iIapId, iConnInfos[index].iNetId, 0, 0, bearerInfo ); |
|
3569 |
|
3570 // AddConnectionL will remove the old connection |
|
3571 TInt err2( KErrNone ); |
|
3572 TRAP( err2, ( err = AddConnectionL( connInfo ) ) ); |
|
3573 if ( ( err2 != KErrNone ) || ( err != KErrNone ) ) |
|
3574 { |
|
3575 err = KErrUnknown; |
|
3576 } |
|
3577 else |
|
3578 { |
|
3579 aConnectionId = connInfo.iConnectionId; |
|
3580 } |
|
3581 } |
|
3582 |
|
3583 LOGEXITFN1("CConnMonIAP::Reconnect()", err) |
|
3584 return err; |
|
3585 } |
|
3586 |
|
3587 // ----------------------------------------------------------------------------- |
|
3588 // CConnMonIAP::WlanSupportCheck |
|
3589 // |
|
3590 // Returns KErrNone if the given connection ID is EBearerIdWLAN, or belongs to |
|
3591 // an active connection where bearer has been marked as EBearerIdWLAN. |
|
3592 // ----------------------------------------------------------------------------- |
|
3593 // |
|
3594 TInt CConnMonIAP::WlanSupportCheck( const TUint& aConnectionId ) |
|
3595 { |
|
3596 LOGENTRFN("CConnMonIAP::WlanSupportCheck()") |
|
3597 TInt ret( KErrNotSupported ); |
|
3598 |
|
3599 // Check if WLAN is supported at all |
|
3600 if ( !iWlanSupport ) |
|
3601 { |
|
3602 LOGIT("WlanSupportCheck: no WLAN support") |
|
3603 ret = KErrNotSupported; |
|
3604 } |
|
3605 else |
|
3606 { |
|
3607 if ( EBearerIdWLAN == aConnectionId ) |
|
3608 { |
|
3609 ret = KErrNone; |
|
3610 } |
|
3611 else |
|
3612 { |
|
3613 // Find connection matching the given ID |
|
3614 TInt index = Index( aConnectionId ); |
|
3615 LOGIT2("WlanSupportCheck: checking connection id %d, index %d ", aConnectionId, index) |
|
3616 if ( index < 0 ) |
|
3617 { |
|
3618 ret = KErrArgument; |
|
3619 } |
|
3620 else |
|
3621 { |
|
3622 // Connection found, check if bearer is EBearerWLAN |
|
3623 if ( EBearerWLAN == iConnInfos[index].iBearer ) |
|
3624 { |
|
3625 ret = KErrNone; |
|
3626 } |
|
3627 else |
|
3628 { |
|
3629 LOGIT1("WlanSupportCheck: connection bearer %d is not WLAN", iConnInfos[index].iBearer) |
|
3630 ret = KErrArgument; |
|
3631 } |
|
3632 } |
|
3633 } |
|
3634 } |
|
3635 |
|
3636 LOGEXITFN1("CConnMonIAP::WlanSupportCheck()", ret) |
|
3637 return ret; |
|
3638 } |
|
3639 |
|
3640 // ----------------------------------------------------------------------------------- |
|
3641 // CConnMonIAP::AppendAvailableWLANIaps |
|
3642 // Gets available WLAN IAPs from WLAN engine. |
|
3643 // ----------------------------------------------------------------------------------- |
|
3644 // |
|
3645 TInt CConnMonIAP::AppendAvailableWLANIaps( RArray<TUint>& aIdArray ) |
|
3646 { |
|
3647 //LOGENTRFN("CConnMonIAP::AppendAvailableWLANIaps()") |
|
3648 TInt err( KErrNone ); |
|
3649 |
|
3650 if ( !iWlanSupport ) |
|
3651 { |
|
3652 LOGIT("AppendAvailableWLANIaps: No WLAN support") |
|
3653 err = KErrNotSupported; |
|
3654 } |
|
3655 else |
|
3656 { |
|
3657 err = iWlanSupport->AppendAvailableIaps( aIdArray ); |
|
3658 } |
|
3659 |
|
3660 //LOGEXITFN1("CConnMonIAP::AppendAvailableWLANIaps()", err) |
|
3661 return err; |
|
3662 } |
|
3663 |
|
3664 // ----------------------------------------------------------------------------------- |
|
3665 // CConnMonIAP::AppendAvailableWLANIapsBySsid |
|
3666 // Gets available WLAN IAPs from CommsDat, matching with current WLAN connection SSID. |
|
3667 // ----------------------------------------------------------------------------------- |
|
3668 // |
|
3669 TInt CConnMonIAP::AppendAvailableWLANIapsBySsid( RArray<TUint>& aIdArray ) |
|
3670 { |
|
3671 //LOGENTRFN("CConnMonIAP::AppendAvailableWLANIapsBySsid()") |
|
3672 TInt err( KErrNone ); |
|
3673 |
|
3674 if ( !iWlanSupport ) |
|
3675 { |
|
3676 LOGIT("AppendAvailableWLANIapsBySsid: No WLAN support") |
|
3677 err = KErrNotSupported; |
|
3678 } |
|
3679 else |
|
3680 { |
|
3681 TRAPD( err2, err = iWlanSupport->AppendAvailableIapsBySsidL( aIdArray ) ); |
|
3682 if ( err2 != KErrNone ) |
|
3683 { |
|
3684 LOGIT1("AppendAvailableWLANIapsBySsid: error, LEAVE <%d> from AppendAvailableIapsBySsidL()", err2) |
|
3685 err = err2; |
|
3686 } |
|
3687 } |
|
3688 |
|
3689 //LOGEXITFN1("CConnMonIAP::AppendAvailableWLANIapsBySsid()", err) |
|
3690 return err; |
|
3691 } |
|
3692 |
|
3693 // ----------------------------------------------------------------------------------- |
|
3694 // CConnMonIAP::EnableWlanScan |
|
3695 // Enables WLAN scan for the next iap availability query. |
|
3696 // ----------------------------------------------------------------------------------- |
|
3697 // |
|
3698 void CConnMonIAP::EnableWlanScan() |
|
3699 { |
|
3700 if ( iWlanSupport ) |
|
3701 { |
|
3702 iWlanSupport->EnableWlanScan(); |
|
3703 } |
|
3704 } |
|
3705 |
|
3706 // ----------------------------------------------------------------------------- |
|
3707 // CConnMonIAP::DtmStateChanged |
|
3708 // ----------------------------------------------------------------------------- |
|
3709 // |
|
3710 void CConnMonIAP::DtmStateChanged() |
|
3711 { |
|
3712 LOGENTRFN("CConnMonIAP::DtmStateChanged()") |
|
3713 |
|
3714 TEventInfo eventInfo; |
|
3715 eventInfo.Reset(); |
|
3716 |
|
3717 // When not in dual mode and call is active, gprs and wcdma bearers are unavailable |
|
3718 // Note that even the WCDMA can be unavailable, if the phone doesn't support DTM |
|
3719 if ( iDualTransferModeNotifier && !iDualTransferModeNotifier->IsInDualMode() && |
|
3720 iTelephonyNotifier && iTelephonyNotifier->IsCallActive() ) |
|
3721 { |
|
3722 LOGIT("SERVER: DtmStateChanged: Packet data UNAVAILABLE (2G&3G), no DTM and call is active") |
|
3723 eventInfo.iEventType = EConnMonPacketDataUnavailable; |
|
3724 |
|
3725 // Send event to all clients that are listening for bearer EBearerIdGPRS |
|
3726 LOGIT("SERVER: EVENT -> Packet data UNAVAILABLE (GPRS), no DTM and call is active") |
|
3727 eventInfo.iConnectionId = EBearerIdGPRS; |
|
3728 iServer->EventQueue()->Add( eventInfo ); // Create bearer availability event if needed |
|
3729 |
|
3730 // Send event to all clients that are listening for bearer EBearerIdWCDMA |
|
3731 LOGIT("SERVER: EVENT -> Packet data UNAVAILABLE (WCDMA), no DTM and call is active") |
|
3732 eventInfo.iConnectionId = EBearerIdWCDMA; |
|
3733 iServer->EventQueue()->Add( eventInfo ); |
|
3734 } |
|
3735 else |
|
3736 { |
|
3737 TBool byPhone( EFalse ); |
|
3738 TBool byCell( EFalse ); |
|
3739 |
|
3740 // Lets check if GPRS bearer is available at all |
|
3741 TInt ret = GetBearerSupportInfo( EBearerIdGPRS, byCell, byPhone ); |
|
3742 LOGIT2("Bearer support (GPRS): byCell %d, byPhone %d", byCell, byPhone) |
|
3743 if ( ret != KErrNone ) |
|
3744 { |
|
3745 LOGIT1("SERVER: DtmStateChanged: GetBearerSupportInfo (GPRS) returned error <%d>", ret) |
|
3746 return; // No event on error |
|
3747 } |
|
3748 |
|
3749 eventInfo.iConnectionId = EBearerIdGPRS; |
|
3750 if ( byCell && byPhone ) |
|
3751 { |
|
3752 LOGIT("SERVER: EVENT -> Packet data AVAILABLE (GPRS), DTM or no call is active") |
|
3753 eventInfo.iEventType = EConnMonPacketDataAvailable; |
|
3754 } |
|
3755 else |
|
3756 { |
|
3757 LOGIT("SERVER: EVENT -> Packet data UNAVAILABLE (GPRS), no GPRS bearer") |
|
3758 eventInfo.iEventType = EConnMonPacketDataUnavailable; |
|
3759 } |
|
3760 // Send event to all clients that are listening for bearer EBearerIdGPRS |
|
3761 iServer->EventQueue()->Add( eventInfo ); |
|
3762 |
|
3763 |
|
3764 // Same for WCDMA as for GPRS above |
|
3765 ret = GetBearerSupportInfo( EBearerIdWCDMA, byCell, byPhone ); |
|
3766 LOGIT2("Bearer support (WCDMA): byCell %d, byPhone %d", byCell, byPhone) |
|
3767 if ( ret != KErrNone ) |
|
3768 { |
|
3769 LOGIT1("SERVER: DtmStateChanged: GetBearerSupportInfo (WCDMA) returned error <%d>", ret) |
|
3770 return; // No event on error |
|
3771 } |
|
3772 |
|
3773 eventInfo.iConnectionId = EBearerIdWCDMA; |
|
3774 if ( byCell && byPhone ) |
|
3775 { |
|
3776 LOGIT("SERVER: EVENT -> Packet data AVAILABLE (WCDMA), DTM or no call is active") |
|
3777 eventInfo.iEventType = EConnMonPacketDataAvailable; |
|
3778 } |
|
3779 else |
|
3780 { |
|
3781 LOGIT("SERVER: EVENT -> Packet data UNAVAILABLE (WCDMA), no WCDMA bearer") |
|
3782 eventInfo.iEventType = EConnMonPacketDataUnavailable; |
|
3783 } |
|
3784 // Send event to all clients that are listening for bearer EBearerIdWCDMA |
|
3785 iServer->EventQueue()->Add( eventInfo ); |
|
3786 } |
|
3787 |
|
3788 LOGEXITFN("CConnMonIAP::DtmStateChanged()") |
|
3789 } |
|
3790 |
|
3791 // ----------------------------------------------------------------------------- |
|
3792 // CConnMonIAP::PhoneLineStatusChange |
|
3793 // ----------------------------------------------------------------------------- |
|
3794 // |
|
3795 void CConnMonIAP::PhoneLineStatusChange() |
|
3796 { |
|
3797 LOGENTRFN("CConnMonIAP::PhoneLineStatusChange()") |
|
3798 |
|
3799 // At this time the implementation would be identical |
|
3800 // to DtmStateChanged so we just call it |
|
3801 DtmStateChanged(); |
|
3802 |
|
3803 LOGEXITFN("CConnMonIAP::PhoneLineStatusChange()") |
|
3804 } |
|
3805 |
|
3806 |
|
3807 // PRIVATE METHODS BELOW |
|
3808 |
|
3809 // ----------------------------------------------------------------------------------- |
|
3810 // CConnMonIAP::OpenAndAttachTo |
|
3811 // Opens and attaches an RConnection instance. |
|
3812 // ----------------------------------------------------------------------------------- |
|
3813 // |
|
3814 TInt CConnMonIAP::OpenAndAttachTo( TConnInfo& aConnInfo ) |
|
3815 { |
|
3816 //LOGENTRFN("CConnMonIAP::OpenAndAttachTo()") |
|
3817 TInt err( KErrNone ); |
|
3818 TConnectionInfo info; |
|
3819 TPckg<TConnectionInfo> pckgInfo( info ); |
|
3820 |
|
3821 // Leave left out intentionally, check for NULL instead |
|
3822 aConnInfo.iConnAttach = new RConnection(); // No (ELeave) |
|
3823 if ( !aConnInfo.iConnAttach ) |
|
3824 { |
|
3825 err = KErrNoMemory; |
|
3826 } |
|
3827 if ( KErrNone == err ) |
|
3828 { |
|
3829 err = aConnInfo.iConnAttach->Open( iSocketServer, KAfInet ); |
|
3830 } |
|
3831 |
|
3832 if ( KErrNone == err ) |
|
3833 { |
|
3834 info.iIapId = aConnInfo.iIapId; |
|
3835 info.iNetId = aConnInfo.iNetId; |
|
3836 |
|
3837 err = aConnInfo.iConnAttach->Attach( pckgInfo, RConnection::EAttachTypeMonitor ); |
|
3838 if ( err != KErrNone ) |
|
3839 { |
|
3840 aConnInfo.iConnAttach->Close(); |
|
3841 delete aConnInfo.iConnAttach; |
|
3842 } |
|
3843 } |
|
3844 |
|
3845 //LOGEXITFN1("CConnMonIAP::OpenAndAttachTo()", err) |
|
3846 return err; |
|
3847 } |
|
3848 |
|
3849 // ----------------------------------------------------------------------------------- |
|
3850 // CConnMonIAP::StopConnection |
|
3851 // Closes a connection. |
|
3852 // ----------------------------------------------------------------------------------- |
|
3853 // |
|
3854 TInt CConnMonIAP::StopConnection( const TInt aIndex ) |
|
3855 { |
|
3856 LOGENTRFN("CConnMonIAP::StopConnection()") |
|
3857 TInt err( KErrNone ); |
|
3858 |
|
3859 if ( ( aIndex < 0 ) || ( aIndex >= iConnInfos.Count() ) ) |
|
3860 { |
|
3861 LOGEXITFN1("CConnMonIAP::StopConnection()", KErrArgument) |
|
3862 return KErrArgument; |
|
3863 } |
|
3864 |
|
3865 if ( iConnInfos[aIndex].iBearer < EBearerExternalCSD ) |
|
3866 { |
|
3867 // Stop an internal connection |
|
3868 RConnection connection; |
|
3869 TConnectionInfo info; |
|
3870 |
|
3871 // Cancel data volume and activity notifiers before stopping |
|
3872 if ( iConnInfos[aIndex].iDLDataNotifier != 0 ) |
|
3873 { |
|
3874 iConnInfos[aIndex].iDLDataNotifier->Cancel(); |
|
3875 } |
|
3876 if ( iConnInfos[aIndex].iULDataNotifier != 0 ) |
|
3877 { |
|
3878 iConnInfos[aIndex].iULDataNotifier->Cancel(); |
|
3879 } |
|
3880 if ( iConnInfos[aIndex].iDataVolumeAO != 0 ) |
|
3881 { |
|
3882 iConnInfos[aIndex].iDataVolumeAO->Cancel(); |
|
3883 } |
|
3884 if ( iConnInfos[aIndex].iActivityNotifier != 0 ) |
|
3885 { |
|
3886 iConnInfos[aIndex].iActivityNotifier->Cancel(); |
|
3887 } |
|
3888 |
|
3889 // RConnection object with EAttachTypeNormal is needed for stopping |
|
3890 err = connection.Open( iSocketServer, KAfInet ); |
|
3891 if ( KErrNone == err ) |
|
3892 { |
|
3893 info.iIapId = iConnInfos[aIndex].iIapId; |
|
3894 info.iNetId = iConnInfos[aIndex].iNetId; |
|
3895 |
|
3896 err = connection.Attach( TPckg<TConnectionInfo>( info ), |
|
3897 RConnection::EAttachTypeNormal ); |
|
3898 if ( KErrNone == err ) |
|
3899 { |
|
3900 err = connection.Stop( RConnection::EStopAuthoritative ); |
|
3901 if ( KErrNone == err ) |
|
3902 { |
|
3903 // Stop notifications, delete connection settings and remove from the table |
|
3904 // If conn up/down notifier is active, let the event remove connection later. |
|
3905 if ( !iConnUpDownNotifier || !iConnUpDownNotifier->IsActive() ) |
|
3906 { |
|
3907 RemoveConnection( iConnInfos[aIndex] ); |
|
3908 } |
|
3909 } |
|
3910 else |
|
3911 { |
|
3912 LOGIT1("StopConnection: RConnection::Stop() failed <%d>", err) |
|
3913 } |
|
3914 } |
|
3915 else |
|
3916 { |
|
3917 LOGIT1("StopConnection: RConnection::Attach() failed <%d>", err) |
|
3918 } |
|
3919 connection.Close(); |
|
3920 } |
|
3921 else |
|
3922 { |
|
3923 LOGIT1("StopConnection: RConnection::Open() failed <%d>", err) |
|
3924 } |
|
3925 } |
|
3926 |
|
3927 else if ( iConnInfos[aIndex].iBearer == EBearerExternalGPRS || |
|
3928 iConnInfos[aIndex].iBearer == EBearerExternalEdgeGPRS || |
|
3929 iConnInfos[aIndex].iBearer == EBearerExternalWCDMA || |
|
3930 iConnInfos[aIndex].iBearer == EBearerExternalCDMA2000 || |
|
3931 ( !iConnInfos[aIndex].iBearerInfo.iInternal && |
|
3932 ( iConnInfos[aIndex].iBearerInfo.iBearer == EBearerInfoHSDPA || |
|
3933 iConnInfos[aIndex].iBearerInfo.iBearer == EBearerInfoHSUPA || |
|
3934 iConnInfos[aIndex].iBearerInfo.iBearer == EBearerInfoHSxPA ) ) ) |
|
3935 { |
|
3936 // EXTERNAL PSD |
|
3937 if ( iPsdFax ) |
|
3938 { |
|
3939 err = iPsdFax->Stop( iConnInfos[aIndex].iConnectionId ); |
|
3940 } |
|
3941 else |
|
3942 { |
|
3943 err = KErrNotFound; |
|
3944 } |
|
3945 } |
|
3946 |
|
3947 else if ( iConnInfos[aIndex].iBearer == EBearerExternalCSD || |
|
3948 iConnInfos[aIndex].iBearer == EBearerExternalHSCSD || |
|
3949 iConnInfos[aIndex].iBearer == EBearerExternalWcdmaCSD ) |
|
3950 { |
|
3951 // EXTERNAL CSD |
|
3952 if ( iCsdFax ) |
|
3953 { |
|
3954 err = iCsdFax->Stop(); |
|
3955 } |
|
3956 else |
|
3957 { |
|
3958 err = KErrNotFound; |
|
3959 } |
|
3960 } |
|
3961 else |
|
3962 { |
|
3963 err = KErrNotSupported; |
|
3964 } |
|
3965 |
|
3966 LOGEXITFN1("CConnMonIAP::StopConnection()", err) |
|
3967 return err; |
|
3968 } |
|
3969 |
|
3970 // ----------------------------------------------------------------------------------- |
|
3971 // CConnMonIAP::AddConnNotificationsL |
|
3972 // Adds connection specific event watchers (connection status, data volume, activity). |
|
3973 // ----------------------------------------------------------------------------------- |
|
3974 // |
|
3975 void CConnMonIAP::AddConnNotificationsL( const TInt& aIndex ) |
|
3976 { |
|
3977 LOGENTRFN("CConnMonIAP::AddConnNotificationsL()") |
|
3978 |
|
3979 if ( iConnInfos[aIndex].iBearer < EBearerExternalCSD ) |
|
3980 { |
|
3981 // INTERNAL CONNECTIONS |
|
3982 TInt connectionStatus( 0 ); |
|
3983 GetConnectionStatus( aIndex, connectionStatus ); |
|
3984 |
|
3985 // ---------------------- |
|
3986 // Connection Status |
|
3987 // ---------------------- |
|
3988 if ( iConnInfos[aIndex].iProgressNotifier == 0 ) |
|
3989 { |
|
3990 TInt subConnectionId( 0 ); |
|
3991 |
|
3992 // Create an active object and add it to scheduler |
|
3993 iConnInfos[aIndex].iProgressNotifier = new( ELeave ) CProgressNotifier( |
|
3994 iServer, |
|
3995 iConnInfos[aIndex].iConnAttach, |
|
3996 iConnInfos[aIndex].iConnectionId, |
|
3997 subConnectionId ); |
|
3998 |
|
3999 iConnInfos[aIndex].iProgressNotifier->Construct(); |
|
4000 |
|
4001 if ( iConnUpDownNotifier->IsActive() ) |
|
4002 { |
|
4003 // Client is starting notifications. Filter old status events. |
|
4004 iConnInfos[aIndex].iProgressNotifier->Receive( connectionStatus ); |
|
4005 } |
|
4006 else |
|
4007 { |
|
4008 // Event is starting notifification. No filtering is needed. |
|
4009 iConnInfos[aIndex].iProgressNotifier->Receive(); |
|
4010 } |
|
4011 } |
|
4012 |
|
4013 // ------------------------- |
|
4014 // Amount of Downlink data |
|
4015 // ------------------------- |
|
4016 if ( iConnInfos[aIndex].iDLDataNotifier == 0 ) |
|
4017 { |
|
4018 TInt subConnectionId( 0 ); |
|
4019 |
|
4020 // Create an active object and add it to scheduler |
|
4021 iConnInfos[aIndex].iDLDataNotifier = new( ELeave ) CDataNotifier( |
|
4022 iServer, |
|
4023 iConnInfos[aIndex].iConnAttach, |
|
4024 iConnInfos[aIndex].iConnectionId, |
|
4025 subConnectionId, |
|
4026 CDataNotifier::EDownlink); |
|
4027 |
|
4028 iConnInfos[aIndex].iDLDataNotifier->Construct(); |
|
4029 |
|
4030 if ( ( connectionStatus == KLinkLayerOpen ) || |
|
4031 ( connectionStatus == KPsdSuspended ) ) |
|
4032 { |
|
4033 iConnInfos[aIndex].iDLDataNotifier->Receive(); |
|
4034 } |
|
4035 } |
|
4036 |
|
4037 // ------------------------- |
|
4038 // Amount of Uplink data |
|
4039 // ------------------------- |
|
4040 if ( iConnInfos[aIndex].iULDataNotifier == 0 ) |
|
4041 { |
|
4042 TInt subConnectionId( 0 ); |
|
4043 |
|
4044 // Create an active object and add it to scheduler |
|
4045 iConnInfos[aIndex].iULDataNotifier = new( ELeave ) CDataNotifier( |
|
4046 iServer, |
|
4047 iConnInfos[aIndex].iConnAttach, |
|
4048 iConnInfos[aIndex].iConnectionId, |
|
4049 subConnectionId, |
|
4050 CDataNotifier::EUplink); |
|
4051 |
|
4052 iConnInfos[aIndex].iULDataNotifier->Construct(); |
|
4053 |
|
4054 if ( ( connectionStatus == KLinkLayerOpen ) || |
|
4055 ( connectionStatus == KPsdSuspended ) ) |
|
4056 { |
|
4057 iConnInfos[aIndex].iULDataNotifier->Receive(); |
|
4058 } |
|
4059 } |
|
4060 |
|
4061 // --------------------------------------- |
|
4062 // Connection down event with data volumes |
|
4063 // --------------------------------------- |
|
4064 if ( iConnInfos[aIndex].iConnDownNotifier == 0 ) |
|
4065 { |
|
4066 TInt subConnectionId( 0 ); |
|
4067 |
|
4068 // Create an active object and add it to scheduler |
|
4069 iConnInfos[aIndex].iConnDownNotifier = new( ELeave ) CSubConnUpDownNotifier( |
|
4070 iServer, |
|
4071 iConnInfos[aIndex].iConnAttach, |
|
4072 iConnInfos[aIndex].iConnectionId, |
|
4073 subConnectionId ); |
|
4074 |
|
4075 iConnInfos[aIndex].iConnDownNotifier->Construct(); |
|
4076 |
|
4077 // Receiving will start only when connection status reaches KLinkLayerOpen |
|
4078 if ( ( connectionStatus == KLinkLayerOpen ) || |
|
4079 ( connectionStatus == KPsdSuspended ) ) |
|
4080 { |
|
4081 iConnInfos[aIndex].iConnDownNotifier->Receive(); |
|
4082 } |
|
4083 } |
|
4084 |
|
4085 // ---------------------- |
|
4086 // Connection Activity |
|
4087 // ---------------------- |
|
4088 if ( iConnInfos[aIndex].iActivityNotifier == 0 ) |
|
4089 { |
|
4090 // To update internal table fast at the first time |
|
4091 if ( ( connectionStatus == KLinkLayerOpen ) || |
|
4092 ( connectionStatus == KPsdSuspended ) ) |
|
4093 { |
|
4094 GetActivityOneShotL( aIndex ); |
|
4095 } |
|
4096 } |
|
4097 else |
|
4098 { |
|
4099 if ( !iConnInfos[aIndex].iActivityNotifier->IsActive() ) |
|
4100 { |
|
4101 iConnInfos[aIndex].iActivityNotifier->Receive( iConnInfos[aIndex].iActivity ); |
|
4102 } |
|
4103 } |
|
4104 |
|
4105 // ---------------------- |
|
4106 // Connection Bearer |
|
4107 // ---------------------- |
|
4108 if ( iConnInfos[aIndex].iBearerNotifier == 0 ) |
|
4109 { |
|
4110 // Create an active object and add it to scheduler |
|
4111 iConnInfos[aIndex].iBearerNotifier = CConnMonBearerNotifier::NewL( |
|
4112 iServer, |
|
4113 iMobilePhone, |
|
4114 iConnInfos[aIndex].iConnectionId ); |
|
4115 |
|
4116 // Receiving will start only when connection status reaches KLinkLayerOpen |
|
4117 if ( ( connectionStatus == KLinkLayerOpen ) || |
|
4118 ( connectionStatus == KPsdSuspended ) ) |
|
4119 { |
|
4120 iConnInfos[aIndex].iBearerNotifier->Listen(); |
|
4121 } |
|
4122 } |
|
4123 |
|
4124 // Note. iDataVolumeAO is created when client asks data volume info |
|
4125 } |
|
4126 LOGEXITFN("CConnMonIAP::AddConnNotificationsL()") |
|
4127 } |
|
4128 |
|
4129 // ----------------------------------------------------------------------------------- |
|
4130 // CConnMonIAP::DeleteConnNotifications |
|
4131 // Deletes event watchers owned by a connection |
|
4132 // ----------------------------------------------------------------------------------- |
|
4133 // |
|
4134 void CConnMonIAP::DeleteConnNotifications( const TInt& aIndex ) |
|
4135 { |
|
4136 LOGENTRFN("CConnMonIAP::DeleteConnNotifications()") |
|
4137 if ( iConnInfos[ aIndex ].iBearer < EBearerExternalCSD ) |
|
4138 { |
|
4139 if ( iConnInfos[ aIndex ].iProgressNotifier ) |
|
4140 { |
|
4141 iConnInfos[ aIndex ].iProgressNotifier->Cancel(); |
|
4142 delete iConnInfos[ aIndex ].iProgressNotifier; |
|
4143 iConnInfos[ aIndex ].iProgressNotifier = NULL; |
|
4144 } |
|
4145 |
|
4146 if ( iConnInfos[ aIndex ].iDLDataNotifier ) |
|
4147 { |
|
4148 iConnInfos[ aIndex ].iDLDataNotifier->Cancel(); |
|
4149 delete iConnInfos[ aIndex ].iDLDataNotifier; |
|
4150 iConnInfos[ aIndex ].iDLDataNotifier = NULL; |
|
4151 } |
|
4152 |
|
4153 if ( iConnInfos[ aIndex ].iULDataNotifier ) |
|
4154 { |
|
4155 iConnInfos[ aIndex ].iULDataNotifier->Cancel(); |
|
4156 delete iConnInfos[ aIndex ].iULDataNotifier; |
|
4157 iConnInfos[ aIndex ].iULDataNotifier = NULL; |
|
4158 } |
|
4159 |
|
4160 if ( iConnInfos[ aIndex ].iDataVolumeAO ) |
|
4161 { |
|
4162 iConnInfos[ aIndex ].iDataVolumeAO->Cancel(); |
|
4163 delete iConnInfos[ aIndex ].iDataVolumeAO; |
|
4164 iConnInfos[ aIndex ].iDataVolumeAO = NULL; |
|
4165 } |
|
4166 |
|
4167 if ( iConnInfos[ aIndex ].iConnDownNotifier ) |
|
4168 { |
|
4169 iConnInfos[ aIndex ].iConnDownNotifier->Cancel(); |
|
4170 delete iConnInfos[ aIndex ].iConnDownNotifier; |
|
4171 iConnInfos[ aIndex ].iConnDownNotifier = NULL; |
|
4172 } |
|
4173 |
|
4174 if ( iConnInfos[ aIndex ].iActivityNotifier ) |
|
4175 { |
|
4176 iConnInfos[ aIndex ].iActivityNotifier->Cancel(); |
|
4177 delete iConnInfos[ aIndex ].iActivityNotifier; |
|
4178 iConnInfos[ aIndex ].iActivityNotifier = NULL; |
|
4179 } |
|
4180 |
|
4181 if ( iConnInfos[ aIndex ].iBearerNotifier ) |
|
4182 { |
|
4183 iConnInfos[ aIndex ].iBearerNotifier->CancelListen(); |
|
4184 delete iConnInfos[ aIndex ].iBearerNotifier; |
|
4185 iConnInfos[ aIndex ].iBearerNotifier = NULL; |
|
4186 } |
|
4187 } |
|
4188 LOGEXITFN("CConnMonIAP::DeleteConnNotifications()") |
|
4189 } |
|
4190 |
|
4191 // ----------------------------------------------------------------------------------- |
|
4192 // CConnMonIAP::DeleteNotifications |
|
4193 // Deletes all the event watchers from the system (expect connection up/down events) |
|
4194 // ----------------------------------------------------------------------------------- |
|
4195 // |
|
4196 void CConnMonIAP::DeleteNotifications() |
|
4197 { |
|
4198 if( iTelephonyNotifier ) |
|
4199 { |
|
4200 delete iTelephonyNotifier; |
|
4201 iTelephonyNotifier = NULL; |
|
4202 } |
|
4203 |
|
4204 if( iDualTransferModeNotifier ) |
|
4205 { |
|
4206 delete iDualTransferModeNotifier; |
|
4207 iDualTransferModeNotifier = NULL; |
|
4208 } |
|
4209 |
|
4210 if ( iPsdNetwStatusNotifier ) |
|
4211 { |
|
4212 // Cancel any outstanding requests |
|
4213 iPsdNetwStatusNotifier->Cancel(); |
|
4214 delete iPsdNetwStatusNotifier; |
|
4215 iPsdNetwStatusNotifier = NULL; |
|
4216 } |
|
4217 |
|
4218 if ( iNetwRegistrationNotifier ) |
|
4219 { |
|
4220 // Cancel any outstanding requests |
|
4221 iNetwRegistrationNotifier->Cancel(); |
|
4222 delete iNetwRegistrationNotifier; |
|
4223 iNetwRegistrationNotifier = NULL; |
|
4224 } |
|
4225 |
|
4226 if ( iEdgeNotifier ) |
|
4227 { |
|
4228 // Cancel any outstanding requests |
|
4229 iEdgeNotifier->Cancel(); |
|
4230 delete iEdgeNotifier; |
|
4231 iEdgeNotifier = NULL; |
|
4232 } |
|
4233 |
|
4234 if ( iWcdmaNotifier ) |
|
4235 { |
|
4236 iWcdmaNotifier->Cancel(); |
|
4237 delete iWcdmaNotifier; |
|
4238 iWcdmaNotifier = NULL; |
|
4239 } |
|
4240 |
|
4241 if ( iModeNotifier ) |
|
4242 { |
|
4243 // Cancel any outstanding requests |
|
4244 iModeNotifier->Cancel(); |
|
4245 delete iModeNotifier; |
|
4246 iModeNotifier = NULL; |
|
4247 } |
|
4248 |
|
4249 if ( iGSMSignalNotifier ) |
|
4250 { |
|
4251 // Cancel any outstanding requests |
|
4252 iGSMSignalNotifier->Cancel(); |
|
4253 delete iGSMSignalNotifier; |
|
4254 iGSMSignalNotifier = NULL; |
|
4255 } |
|
4256 |
|
4257 if ( iGSMBearerAvailabilityNotifier ) |
|
4258 { |
|
4259 // Cancel any outstanding requests |
|
4260 iGSMBearerAvailabilityNotifier->Cancel(); |
|
4261 delete iGSMBearerAvailabilityNotifier; |
|
4262 iGSMBearerAvailabilityNotifier = NULL; |
|
4263 } |
|
4264 |
|
4265 if ( iWlanSupport ) |
|
4266 { |
|
4267 iWlanSupport->DisableEventsToClients(); |
|
4268 } |
|
4269 |
|
4270 // Delete notifications owned by the connections |
|
4271 TInt count = iConnInfos.Count(); |
|
4272 for ( TInt i = 0; i < count; i++ ) |
|
4273 { |
|
4274 DeleteConnNotifications( i ); |
|
4275 } |
|
4276 } |
|
4277 |
|
4278 // ----------------------------------------------------------------------------------- |
|
4279 // CConnMonIAP::NewConnectionId |
|
4280 // Returns a new unique connection id for the connection. |
|
4281 // ----------------------------------------------------------------------------------- |
|
4282 // |
|
4283 TUint CConnMonIAP::NewConnectionId() |
|
4284 { |
|
4285 ++iIdCounter; |
|
4286 |
|
4287 if ( iIdCounter == KMaxConnectionId ) |
|
4288 { |
|
4289 iIdCounter = 1; |
|
4290 } |
|
4291 |
|
4292 return iIdCounter; |
|
4293 } |
|
4294 |
|
4295 // ----------------------------------------------------------------------------------- |
|
4296 // CConnMonIAP::Index |
|
4297 // Finds the index of the matching object within the array. |
|
4298 // KErrNotFound, if no matching object can be found. |
|
4299 // ----------------------------------------------------------------------------------- |
|
4300 // |
|
4301 TInt CConnMonIAP::Index( const TUint& aConnectionId ) |
|
4302 { |
|
4303 TInt count = iConnInfos.Count(); |
|
4304 for ( TInt i = 0; i < count; i++ ) |
|
4305 { |
|
4306 if ( iConnInfos[i].iConnectionId == aConnectionId ) |
|
4307 { |
|
4308 return i; |
|
4309 } |
|
4310 } |
|
4311 |
|
4312 return KErrNotFound; |
|
4313 } |
|
4314 |
|
4315 // ----------------------------------------------------------------------------- |
|
4316 // CConnMonIAP::GetAccessPointName |
|
4317 // ----------------------------------------------------------------------------- |
|
4318 // |
|
4319 TInt CConnMonIAP::GetAccessPointName( const TUint& aConnectionId, TDes& aName ) |
|
4320 { |
|
4321 LOGENTRFN("CConnMonIAP::GetAccessPointName()") |
|
4322 TInt err( KErrNone ); |
|
4323 |
|
4324 // Find connection matching the given Id |
|
4325 TInt index = Index( aConnectionId ); |
|
4326 if ( index < 0 ) |
|
4327 { |
|
4328 err = KErrNotFound; |
|
4329 } |
|
4330 else |
|
4331 { |
|
4332 // Find out access point name |
|
4333 TBuf<KCommsDbSvrMaxFieldLength> settingName; |
|
4334 TBuf<KCommsDbSvrMaxFieldLength> settingValue; |
|
4335 settingName.Copy( TPtrC( IAP ) ); |
|
4336 settingName.Append( TChar( '\\' ) ); |
|
4337 settingName.Append( TPtrC( IAP_SERVICE_TYPE ) ); |
|
4338 |
|
4339 err = iConnInfos[index].iConnAttach->GetDesSetting( |
|
4340 TPtrC( settingName ), |
|
4341 settingValue ); |
|
4342 if ( KErrNone == err ) |
|
4343 { |
|
4344 if ( settingValue == TPtrC( OUTGOING_WCDMA ) || |
|
4345 settingValue == TPtrC( INCOMING_WCDMA ) ) |
|
4346 { |
|
4347 settingName.Copy( settingValue ); |
|
4348 settingName.Append( TChar( '\\' ) ); |
|
4349 settingName.Append( TPtrC( GPRS_APN ) ); |
|
4350 |
|
4351 err = iConnInfos[index].iConnAttach->GetDesSetting( |
|
4352 TPtrC( settingName ), |
|
4353 aName ); |
|
4354 } |
|
4355 else |
|
4356 { |
|
4357 err = KErrNotFound; |
|
4358 } |
|
4359 } |
|
4360 } |
|
4361 |
|
4362 LOGEXITFN1("CConnMonIAP::GetAccessPointName()", err) |
|
4363 return err; |
|
4364 } |
|
4365 |
|
4366 // ----------------------------------------------------------------------------- |
|
4367 // CConnMonIAP::GetTelNumber |
|
4368 // ----------------------------------------------------------------------------- |
|
4369 // |
|
4370 TInt CConnMonIAP::GetTelNumber( const TUint& aConnectionId, TDes& aTelNum ) |
|
4371 { |
|
4372 LOGENTRFN("CConnMonIAP::GetTelNumber()") |
|
4373 TInt err( KErrNone ); |
|
4374 |
|
4375 // Find connection matching the given Id |
|
4376 TInt index = Index( aConnectionId ); |
|
4377 if ( index < 0 ) |
|
4378 { |
|
4379 err = KErrNotFound; |
|
4380 } |
|
4381 else |
|
4382 { |
|
4383 // Find out tel. number |
|
4384 TBuf<KCommsDbSvrMaxFieldLength> settingName; |
|
4385 TBuf<KCommsDbSvrMaxFieldLength> settingValue; |
|
4386 settingName.Copy( TPtrC( IAP ) ); |
|
4387 settingName.Append( TChar( '\\' ) ); |
|
4388 settingName.Append( TPtrC( IAP_SERVICE_TYPE ) ); |
|
4389 |
|
4390 err = iConnInfos[index].iConnAttach->GetDesSetting( |
|
4391 TPtrC( settingName ), |
|
4392 settingValue ); |
|
4393 if ( KErrNone == err ) |
|
4394 { |
|
4395 if ( settingValue == TPtrC( DIAL_OUT_ISP ) || |
|
4396 settingValue == TPtrC( DIAL_IN_ISP ) ) |
|
4397 { |
|
4398 settingName.Copy( settingValue ); |
|
4399 settingName.Append( TChar( '\\' ) ); |
|
4400 settingName.Append( TPtrC( ISP_DEFAULT_TEL_NUM ) ); |
|
4401 |
|
4402 err = iConnInfos[index].iConnAttach->GetDesSetting( |
|
4403 TPtrC( settingName ), |
|
4404 aTelNum ); |
|
4405 } |
|
4406 else |
|
4407 { |
|
4408 err = KErrNotFound; |
|
4409 } |
|
4410 } |
|
4411 } |
|
4412 |
|
4413 LOGEXITFN1("CConnMonIAP::GetTelNumber()", err) |
|
4414 return err; |
|
4415 } |
|
4416 |
|
4417 // ----------------------------------------------------------------------------- |
|
4418 // CConnMonIAP::GetConnectionStatus |
|
4419 // ----------------------------------------------------------------------------- |
|
4420 // |
|
4421 TInt CConnMonIAP::GetConnectionStatus( const TInt& aIndex, TInt& aConnectionStatus ) |
|
4422 { |
|
4423 //LOGENTRFN("CConnMonIAP::GetConnectionStatus()") |
|
4424 TInt err( KErrNone ); |
|
4425 TNifProgress nifProgress; |
|
4426 |
|
4427 if ( ( aIndex < 0 ) || ( aIndex >= iConnInfos.Count() ) ) |
|
4428 { |
|
4429 LOGIT1("GetConnectionStatus: invalid index value: %d", aIndex) |
|
4430 err = KErrArgument; |
|
4431 } |
|
4432 else |
|
4433 { |
|
4434 aConnectionStatus = 0; |
|
4435 err = iConnInfos[aIndex].iConnAttach->Progress( nifProgress ); |
|
4436 if ( KErrNone == err ) |
|
4437 { |
|
4438 aConnectionStatus = nifProgress.iStage; |
|
4439 LOGIT1("GetConnectionStatus: iConnAttach->Progress() status: %d", aConnectionStatus) |
|
4440 } |
|
4441 else |
|
4442 { |
|
4443 LOGIT1("GetConnectionStatus: ERROR getting progress status <%d>", err) |
|
4444 } |
|
4445 } |
|
4446 |
|
4447 //LOGEXITFN1("CConnMonIAP::GetConnectionStatus()", err) |
|
4448 return err; |
|
4449 } |
|
4450 |
|
4451 // ----------------------------------------------------------------------------- |
|
4452 // CConnMonIAP::GetPsdNetworkStatus |
|
4453 // ----------------------------------------------------------------------------- |
|
4454 // |
|
4455 TInt CConnMonIAP::GetPsdNetworkStatus( TInt& aNetworkStatus ) const |
|
4456 { |
|
4457 LOGENTRFN("CConnMonIAP::GetPsdNetworkStatus()") |
|
4458 TInt err( KErrNone ); |
|
4459 |
|
4460 if ( iTSYLoaded && iPacketServLoaded ) |
|
4461 { |
|
4462 RPacketService::TStatus packetStatus; |
|
4463 err = iPacketService.GetStatus( packetStatus ); |
|
4464 if ( KErrNone == err ) |
|
4465 { |
|
4466 aNetworkStatus = CalculateNetworkStatus( packetStatus ); |
|
4467 LOGIT1("GetPsdNetworkStatus: status %d", aNetworkStatus) |
|
4468 } |
|
4469 } |
|
4470 else |
|
4471 { |
|
4472 aNetworkStatus = EConnMonStatusUnattached; |
|
4473 } |
|
4474 |
|
4475 LOGEXITFN1("CConnMonIAP::GetPsdNetworkStatus()", err) |
|
4476 return err; |
|
4477 } |
|
4478 |
|
4479 // ----------------------------------------------------------------------------- |
|
4480 // CConnMonIAP::GetNetworkRegistrationMode |
|
4481 // ----------------------------------------------------------------------------- |
|
4482 // |
|
4483 TInt CConnMonIAP::GetNetworkRegistrationMode( TInt& aRegistration ) const |
|
4484 { |
|
4485 return GetNetworkRegistration( aRegistration ); |
|
4486 } |
|
4487 |
|
4488 // ----------------------------------------------------------------------------- |
|
4489 // CConnMonIAP::GetNetworkRegistration |
|
4490 // ----------------------------------------------------------------------------- |
|
4491 // |
|
4492 TInt CConnMonIAP::GetNetworkRegistration( TInt& aRegistration ) const |
|
4493 { |
|
4494 LOGENTRFN("CConnMonIAP::GetNetworkRegistration()") |
|
4495 TInt err( KErrNone ); |
|
4496 |
|
4497 if ( !FeatureManager::FeatureSupported( KFeatureIdNetworkRegistration ) ) |
|
4498 { |
|
4499 LOGIT("GetNetworkRegistration: KFeatureIdNetworkRegistration not supported") |
|
4500 err = KErrNotSupported; |
|
4501 } |
|
4502 else |
|
4503 { |
|
4504 if ( iTSYLoaded ) |
|
4505 { |
|
4506 TRequestStatus status( KErrNone ); |
|
4507 RMobilePhone::TMobilePhoneRegistrationStatus registration( |
|
4508 RMobilePhone::ERegistrationUnknown ); |
|
4509 |
|
4510 iMobilePhone.GetNetworkRegistrationStatus( status, registration ); |
|
4511 User::WaitForRequest( status ); |
|
4512 err = status.Int(); |
|
4513 if ( KErrNone == err ) |
|
4514 { |
|
4515 aRegistration = CalculateNetworkRegistration( registration ); |
|
4516 LOGIT1("GetNetworkRegistration: registration %d", aRegistration) |
|
4517 } |
|
4518 } |
|
4519 else |
|
4520 { |
|
4521 aRegistration = ENetworkRegistrationNotAvailable; |
|
4522 } |
|
4523 } |
|
4524 |
|
4525 LOGEXITFN1("CConnMonIAP::GetNetworkRegistration()", err) |
|
4526 return err; |
|
4527 } |
|
4528 |
|
4529 // ----------------------------------------------------------------------------- |
|
4530 // CConnMonIAP::GetNetworkRegistration_v2 |
|
4531 // ----------------------------------------------------------------------------- |
|
4532 // |
|
4533 TInt CConnMonIAP::GetNetworkRegistration_v2( TInt& aRegistration ) const |
|
4534 { |
|
4535 LOGENTRFN("CConnMonIAP::GetNetworkRegistration_v2()") |
|
4536 TInt err( KErrNone ); |
|
4537 |
|
4538 if ( !FeatureManager::FeatureSupported( KFeatureIdNetworkRegistration ) ) |
|
4539 { |
|
4540 LOGIT("GetNetworkRegistration_v2: KFeatureIdNetworkRegistration not supported") |
|
4541 err = KErrNotSupported; |
|
4542 } |
|
4543 else |
|
4544 { |
|
4545 if ( iTSYLoaded ) |
|
4546 { |
|
4547 TRequestStatus status( KErrNone ); |
|
4548 RMobilePhone::TMobilePhoneRegistrationStatus registration( |
|
4549 RMobilePhone::ERegistrationUnknown ); |
|
4550 |
|
4551 iMobilePhone.GetNetworkRegistrationStatus( status, registration ); |
|
4552 User::WaitForRequest( status ); |
|
4553 err = status.Int(); |
|
4554 if ( KErrNone == err ) |
|
4555 { |
|
4556 aRegistration = CalculateNetworkRegistration_v2( registration ); |
|
4557 LOGIT1("GetNetworkRegistration_v2: registration <%d>", aRegistration ) |
|
4558 } |
|
4559 } |
|
4560 else |
|
4561 { |
|
4562 aRegistration = ENetworkRegistrationExtNotAvailable; |
|
4563 } |
|
4564 } |
|
4565 |
|
4566 LOGEXITFN1("CConnMonIAP::GetNetworkRegistration_v2()", err) |
|
4567 return err; |
|
4568 } |
|
4569 |
|
4570 // ----------------------------------------------------------------------------- |
|
4571 // CConnMonIAP::GetGSMSignalStrength |
|
4572 // ----------------------------------------------------------------------------- |
|
4573 // |
|
4574 TInt CConnMonIAP::GetGSMSignalStrength( TInt& aSignalStrength ) const |
|
4575 { |
|
4576 LOGENTRFN("CConnMonIAP::GetGSMSignalStrength()") |
|
4577 TInt err( KErrNone ); |
|
4578 |
|
4579 if ( iTSYLoaded ) |
|
4580 { |
|
4581 TRequestStatus status( KErrNone ); |
|
4582 TInt32 strength( 0 ); |
|
4583 TInt8 bar( -1 ); |
|
4584 |
|
4585 iMobilePhone.GetSignalStrength( status, strength, bar ); |
|
4586 User::WaitForRequest( status ); |
|
4587 |
|
4588 err = status.Int(); |
|
4589 if ( KErrNone == err ) |
|
4590 { |
|
4591 aSignalStrength = strength; |
|
4592 LOGIT1("GetGSMSignalStrength: strength %d", aSignalStrength) |
|
4593 } |
|
4594 } |
|
4595 else |
|
4596 { |
|
4597 err = KErrNotSupported; |
|
4598 } |
|
4599 |
|
4600 LOGEXITFN1("CConnMonIAP::GetGSMSignalStrength()", err) |
|
4601 return err; |
|
4602 } |
|
4603 |
|
4604 // ----------------------------------------------------------------------------- |
|
4605 // CConnMonIAP::GetProtocolTypeL |
|
4606 // ----------------------------------------------------------------------------- |
|
4607 // |
|
4608 TInt CConnMonIAP::GetProtocolTypeL( const TUint& aConnectionId, TInt& aProtocolType ) |
|
4609 { |
|
4610 LOGENTRFN("CConnMonIAP::GetProtocolTypeL()") |
|
4611 TInt err( KErrNone ); |
|
4612 |
|
4613 // Find connection matching the given Id |
|
4614 TInt index = Index( aConnectionId ); |
|
4615 if ( index < 0 ) |
|
4616 { |
|
4617 LOGEXITFN1("CConnMonIAP::GetProtocolTypeL()", KErrNotFound) |
|
4618 return KErrNotFound; |
|
4619 } |
|
4620 |
|
4621 aProtocolType = EProtocolTypeUnknown; |
|
4622 |
|
4623 if ( iTSYLoaded && iPacketServLoaded ) |
|
4624 { |
|
4625 // Get AP name for the connection |
|
4626 TBuf<KCommsDbSvrMaxFieldLength> apName; |
|
4627 |
|
4628 err = GetAccessPointName( iConnInfos[index].iConnectionId, apName ); |
|
4629 |
|
4630 if ( KErrNotFound == err ) |
|
4631 { |
|
4632 LOGEXITFN1("CConnMonIAP::GetProtocolTypeL()", err) |
|
4633 return err; |
|
4634 } |
|
4635 |
|
4636 // Enumerate all PDP contexts |
|
4637 TRequestStatus status( KErrNone ); |
|
4638 TInt contextCount( 0 ); |
|
4639 TInt maxContextCount( 0 ); |
|
4640 |
|
4641 iPacketService.EnumerateContexts( status, contextCount, maxContextCount ); |
|
4642 User::WaitForRequest( status ); |
|
4643 |
|
4644 err = status.Int(); |
|
4645 if ( err != KErrNone ) |
|
4646 { |
|
4647 LOGEXITFN1("CConnMonIAP::GetProtocolTypeL()", err) |
|
4648 return err; |
|
4649 } |
|
4650 |
|
4651 RPacketService::TContextInfo contextInfo; |
|
4652 RPacketContext context; |
|
4653 CleanupClosePushL( context ); |
|
4654 |
|
4655 // Find PDP contexts matching the given connectionId |
|
4656 for ( TInt i = 0; ( i < contextCount ) && ( aProtocolType != EProtocolTypeIP ); i++ ) |
|
4657 { |
|
4658 iPacketService.GetContextInfo( status, i, contextInfo ); //iName, iStatus |
|
4659 User::WaitForRequest( status ); |
|
4660 |
|
4661 err = status.Int(); |
|
4662 if ( err != KErrNone ) |
|
4663 { |
|
4664 LOGEXITFN1("CConnMonIAP::GetProtocolTypeL()", err) |
|
4665 return err; |
|
4666 } |
|
4667 |
|
4668 err = context.OpenExistingContext( iPacketService, contextInfo.iName ); |
|
4669 if ( err != KErrNone ) |
|
4670 { |
|
4671 LOGEXITFN1("CConnMonIAP::GetProtocolTypeL()", err) |
|
4672 return err; |
|
4673 } |
|
4674 |
|
4675 RPacketContext::TContextConfigGPRS* getParams; |
|
4676 getParams = new( ELeave ) RPacketContext::TContextConfigGPRS(); |
|
4677 TPckg<RPacketContext::TContextConfigGPRS> getContextConfigPckg( *getParams ); |
|
4678 |
|
4679 context.GetConfig( status, getContextConfigPckg ); |
|
4680 User::WaitForRequest( status ); |
|
4681 |
|
4682 err = status.Int(); |
|
4683 if ( KErrNone == err ) |
|
4684 { |
|
4685 TInt ret = CompareAccessPointNames( apName, getParams->iAccessPointName ); |
|
4686 |
|
4687 if ( ret == 0 ) |
|
4688 { |
|
4689 // PDP context matching the IAP connection found |
|
4690 if ( getParams->iPdpType == RPacketContext::EPdpTypeIPv4 ) |
|
4691 { |
|
4692 if ( aProtocolType == EProtocolTypeIPv6 ) |
|
4693 { |
|
4694 aProtocolType = EProtocolTypeIP; // Both 4 & 6 |
|
4695 } |
|
4696 else |
|
4697 { |
|
4698 aProtocolType = EProtocolTypeIPv4; |
|
4699 } |
|
4700 } |
|
4701 else if ( getParams->iPdpType == RPacketContext::EPdpTypeIPv6 ) |
|
4702 { |
|
4703 if ( aProtocolType == EProtocolTypeIPv4 ) |
|
4704 { |
|
4705 aProtocolType = EProtocolTypeIP; // Both 4 & 6 |
|
4706 } |
|
4707 else |
|
4708 { |
|
4709 aProtocolType = EProtocolTypeIPv6; |
|
4710 } |
|
4711 } |
|
4712 else |
|
4713 { |
|
4714 aProtocolType = EProtocolTypeUnknown; |
|
4715 } |
|
4716 } |
|
4717 } |
|
4718 |
|
4719 delete getParams; |
|
4720 context.Close(); |
|
4721 |
|
4722 if ( err != KErrNone ) |
|
4723 { |
|
4724 break; |
|
4725 } |
|
4726 } // for |
|
4727 CleanupStack::PopAndDestroy( &context ); |
|
4728 } // if |
|
4729 |
|
4730 LOGEXITFN1("CConnMonIAP::GetProtocolTypeL()", err) |
|
4731 return err; |
|
4732 } |
|
4733 |
|
4734 // ----------------------------------------------------------------------------- |
|
4735 // CConnMonIAP::GetActivityOneShotL |
|
4736 // ----------------------------------------------------------------------------- |
|
4737 // |
|
4738 void CConnMonIAP::GetActivityOneShotL( const TInt& aIndex ) |
|
4739 { |
|
4740 if ( iConnInfos[aIndex].iActivityNotifier == 0 ) |
|
4741 { |
|
4742 iConnInfos[aIndex].iActivityNotifier = new( ELeave ) CActivityNotifier( |
|
4743 iServer, |
|
4744 iConnInfos[aIndex].iConnAttach, |
|
4745 iConnInfos[aIndex].iConnectionId, |
|
4746 0 ); |
|
4747 iConnInfos[aIndex].iActivityNotifier->Construct(); |
|
4748 } |
|
4749 |
|
4750 if ( !iConnInfos[aIndex].iActivityNotifier->IsActive() ) |
|
4751 { |
|
4752 iConnInfos[aIndex].iActivityNotifier->ReceiveOne( |
|
4753 iConnInfos[aIndex].iActivity ); |
|
4754 |
|
4755 // This AO will cancel the activity notifier after one second in case it has not completed. |
|
4756 // AO will destroy itself in RunL. |
|
4757 CTimerAO* timerAO = new( ELeave ) CTimerAO( |
|
4758 iServer, |
|
4759 iConnInfos[aIndex].iConnectionId, |
|
4760 iConnInfos[aIndex].iActivity ); |
|
4761 |
|
4762 CleanupStack::PushL( timerAO ); |
|
4763 timerAO->ConstructL(); |
|
4764 CleanupStack::Pop( timerAO ); |
|
4765 |
|
4766 timerAO->Start(); |
|
4767 } |
|
4768 } |
|
4769 |
|
4770 // ----------------------------------------------------------------------------- |
|
4771 // CConnMonIAP::GetBearerFromETel |
|
4772 // ----------------------------------------------------------------------------- |
|
4773 // |
|
4774 TInt CConnMonIAP::GetBearerFromETel( |
|
4775 const TDes& aNumber, |
|
4776 TInt& aBearer, |
|
4777 TBearerInfo& aBearerInfo ) |
|
4778 { |
|
4779 TInt ret( KErrNone ); |
|
4780 TInt countCalls( 0 ); |
|
4781 RLine line; |
|
4782 RMobileCall call; |
|
4783 |
|
4784 // Get phone info |
|
4785 RTelServer::TPhoneInfo phoneInfo; |
|
4786 ret = iTelServer.GetPhoneInfo( 0, phoneInfo ); |
|
4787 if ( KErrNone != ret ) |
|
4788 { |
|
4789 return ret; |
|
4790 } |
|
4791 |
|
4792 ret = line.Open( iMobilePhone, KMmTsyDataLineName ); |
|
4793 if ( KErrNone != ret ) |
|
4794 { |
|
4795 return ret; |
|
4796 } |
|
4797 |
|
4798 // Enumerate calls on data line |
|
4799 ret = line.EnumerateCall( countCalls ); |
|
4800 if ( KErrNone != ret ) |
|
4801 { |
|
4802 line.Close(); |
|
4803 return ret; |
|
4804 } |
|
4805 |
|
4806 // Get call info |
|
4807 for ( TInt j = 0; j < countCalls; j++ ) |
|
4808 { |
|
4809 RLine::TCallInfo callInfo; |
|
4810 |
|
4811 ret = line.GetCallInfo( j, callInfo ); |
|
4812 if ( KErrNone != ret ) |
|
4813 { |
|
4814 line.Close(); |
|
4815 return ret; |
|
4816 } |
|
4817 |
|
4818 if ( callInfo.iStatus != RCall::EStatusIdle ) |
|
4819 { |
|
4820 TName callName; |
|
4821 |
|
4822 callName.Copy( phoneInfo.iName ); |
|
4823 callName.Append( KDoubleColon ); |
|
4824 callName.Append( KMmTsyDataLineName ); |
|
4825 callName.Append( KDoubleColon ); |
|
4826 callName.Append( callInfo.iCallName ); |
|
4827 |
|
4828 ret = call.OpenExistingCall( iTelServer, callName ); |
|
4829 if ( KErrNone != ret ) |
|
4830 { |
|
4831 line.Close(); |
|
4832 return ret; |
|
4833 } |
|
4834 |
|
4835 RMobileCall::TMobileCallInfoV1 info; |
|
4836 RMobileCall::TMobileCallInfoV1Pckg infoPckg( info ); |
|
4837 |
|
4838 ret = call.GetMobileCallInfo( infoPckg ); |
|
4839 if ( KErrNone == ret ) |
|
4840 { |
|
4841 if ( infoPckg().iRemoteParty.iRemoteNumber.iTelNumber.Length() > 0 ) |
|
4842 { |
|
4843 ret = aNumber.Compare( infoPckg().iRemoteParty.iRemoteNumber.iTelNumber ); |
|
4844 } |
|
4845 else if ( infoPckg().iDialledParty.iTelNumber.Length() > 0 ) |
|
4846 { |
|
4847 ret = aNumber.Compare( infoPckg().iDialledParty.iTelNumber ); |
|
4848 } |
|
4849 else |
|
4850 { |
|
4851 ret = KErrNotFound; |
|
4852 } |
|
4853 |
|
4854 if ( ret == 0 ) |
|
4855 { |
|
4856 aBearer = EBearerCSD; |
|
4857 aBearerInfo.iBearer = EBearerInfoCSD; |
|
4858 aBearerInfo.iInternal = ETrue; |
|
4859 |
|
4860 RMobileCall::TMobileCallHscsdInfoV1 hscsdInfo; |
|
4861 RMobileCall::TMobileCallHscsdInfoV1Pckg hscsdInfoPckg( hscsdInfo ); |
|
4862 |
|
4863 ret = call.GetCurrentHscsdInfo( hscsdInfoPckg ); |
|
4864 if ( KErrNone == ret ) |
|
4865 { |
|
4866 if ( hscsdInfo.iAiur != RMobileCall::EAiurBpsUnspecified ) |
|
4867 { |
|
4868 aBearer = EBearerHSCSD; |
|
4869 aBearerInfo.iBearer = EBearerInfoHSCSD; |
|
4870 } |
|
4871 } |
|
4872 call.Close(); |
|
4873 line.Close(); |
|
4874 return KErrNone; |
|
4875 } |
|
4876 } |
|
4877 call.Close(); |
|
4878 } |
|
4879 } // for |
|
4880 line.Close(); |
|
4881 return KErrNotFound; |
|
4882 } |
|
4883 |
|
4884 // ----------------------------------------------------------------------------- |
|
4885 // CConnMonIAP::CompareAccessPointNames |
|
4886 // ----------------------------------------------------------------------------- |
|
4887 // |
|
4888 TInt CConnMonIAP::CompareAccessPointNames( |
|
4889 const TDesC& aNameFromCommDB, |
|
4890 const TDesC& aNameFromETel ) const |
|
4891 { |
|
4892 return ( aNameFromETel.Compare( aNameFromCommDB ) ); |
|
4893 } |
|
4894 |
|
4895 // ----------------------------------------------------------------------------- |
|
4896 // CConnMonIAP::CompareAccessPointNames |
|
4897 // ----------------------------------------------------------------------------- |
|
4898 // |
|
4899 TInt CConnMonIAP::CompareAccessPointNames( |
|
4900 const TDesC& aNameFromCommDB, |
|
4901 const TDesC8& aNameFromETel ) const |
|
4902 { |
|
4903 TBuf<KCommsDbSvrMaxFieldLength> tempBuffer; |
|
4904 |
|
4905 CnvUtfConverter::ConvertToUnicodeFromUtf8( tempBuffer, aNameFromETel ); |
|
4906 |
|
4907 return( tempBuffer.Compare( aNameFromCommDB ) ); |
|
4908 } |
|
4909 |
|
4910 // ----------------------------------------------------------------------------- |
|
4911 // CConnMonIAP::SendConnectionEvents |
|
4912 // ----------------------------------------------------------------------------- |
|
4913 // |
|
4914 void CConnMonIAP::SendConnectionEvents( TConnMonBearerInfo& /*aBearerinfo*/ ) |
|
4915 { |
|
4916 if ( iConnInfos.Count() > 0 ) |
|
4917 { |
|
4918 for ( TInt i = 0; i < iConnInfos.Count(); i++ ) |
|
4919 { |
|
4920 if ( iConnInfos[i].iBearerNotifier ) |
|
4921 { |
|
4922 iConnInfos[i].iBearerNotifier->SendBearerInfoEvent(); |
|
4923 iConnInfos[i].iBearerNotifier->SendBearerGroupEvent(); |
|
4924 } |
|
4925 } |
|
4926 } |
|
4927 } |
|
4928 |
|
4929 // ----------------------------------------------------------------------------- |
|
4930 // CConnMonIAP::LastProgressError |
|
4931 // ----------------------------------------------------------------------------- |
|
4932 // |
|
4933 TInt CConnMonIAP::LastProgressError( |
|
4934 const TUint& aConnectionId, |
|
4935 TNifProgress& aProgress ) |
|
4936 { |
|
4937 TInt err( KErrNone ); |
|
4938 |
|
4939 // Find connection matching the given Id |
|
4940 TInt index = Index( aConnectionId ); |
|
4941 |
|
4942 if ( index < 0 ) |
|
4943 { |
|
4944 return KErrNotFound; |
|
4945 } |
|
4946 |
|
4947 err = iConnInfos[index].iConnAttach->LastProgressError( aProgress ); |
|
4948 |
|
4949 LOGIT3("iConnection->Progress() ret <%d> stage %d error <%d>", err, aProgress.iStage, aProgress.iError) |
|
4950 return err; |
|
4951 } |
|
4952 |
|
4953 // --------------------------------------------------------------------------- |
|
4954 // CConnMonIAP::WlanRssGoodEnough |
|
4955 // --------------------------------------------------------------------------- |
|
4956 // |
|
4957 TBool CConnMonIAP::WlanRssGoodEnough() |
|
4958 { |
|
4959 //LOGENTRFN("CConnMonIAP::WlanRssGoodEnough()") |
|
4960 TBool value( EFalse ); |
|
4961 |
|
4962 if ( !iWlanSupport ) |
|
4963 { |
|
4964 LOGIT("WlanRssGoodEnough: No WLAN support") |
|
4965 value = EFalse; |
|
4966 } |
|
4967 else |
|
4968 { |
|
4969 value = iWlanSupport->WlanRssGoodEnough(); |
|
4970 } |
|
4971 |
|
4972 //LOGEXITFN1("CConnMonIAP::WlanRssGoodEnough()", value) |
|
4973 return value; |
|
4974 } |
|
4975 |
|
4976 // --------------------------------------------------------------------------- |
|
4977 // CConnMonIAP::DiscoverBearerId |
|
4978 // --------------------------------------------------------------------------- |
|
4979 // |
|
4980 TInt CConnMonIAP::BearerIdForBearerAvailability( |
|
4981 const TUint& aConnId, |
|
4982 TUint& aBearerId ) |
|
4983 { |
|
4984 LOGENTRFN("CConnMonIAP::BearerIdForBearerAvailability()") |
|
4985 TInt err( KErrNone ); |
|
4986 |
|
4987 TInt index = Index( aConnId ); |
|
4988 if ( index < 0 ) |
|
4989 { |
|
4990 // Bearer specific connection id given as attribute |
|
4991 switch ( aConnId ) |
|
4992 { |
|
4993 case EBearerIdWLAN: aBearerId = EBearerIdWLAN; break; |
|
4994 case EBearerIdGPRS: aBearerId = EBearerIdGPRS; break; |
|
4995 case EBearerIdWCDMA: aBearerId = EBearerIdWCDMA; break; |
|
4996 case EBearerIdCSD: aBearerId = EBearerIdCSD; break; |
|
4997 case EBearerIdWcdmaCSD: aBearerId = EBearerIdWcdmaCSD; break; |
|
4998 // Let session send this request to the plugin |
|
4999 case EBearerIdLAN: err = KErrCancel; break; |
|
5000 default: err = KErrNotFound; break; |
|
5001 } |
|
5002 } |
|
5003 else |
|
5004 { |
|
5005 // Valid connection id given as attribute |
|
5006 switch ( iConnInfos[index].iBearer ) |
|
5007 { |
|
5008 case EBearerWLAN: aBearerId = EBearerIdWLAN; break; |
|
5009 case EBearerGPRS: |
|
5010 case EBearerEdgeGPRS: |
|
5011 case EBearerExternalGPRS: |
|
5012 case EBearerExternalEdgeGPRS: aBearerId = EBearerIdGPRS; break; |
|
5013 case EBearerWCDMA: |
|
5014 case EBearerExternalWCDMA: aBearerId = EBearerIdWCDMA; break; |
|
5015 case EBearerCSD: |
|
5016 case EBearerHSCSD: |
|
5017 case EBearerExternalCSD: |
|
5018 case EBearerExternalHSCSD: aBearerId = EBearerIdCSD; break; |
|
5019 case EBearerWcdmaCSD: |
|
5020 case EBearerExternalWcdmaCSD: aBearerId = EBearerIdWcdmaCSD; break; |
|
5021 // Let session send this request to the plugin |
|
5022 case EBearerLAN: err = KErrCancel; break; |
|
5023 default: err = KErrNotSupported; break; |
|
5024 } |
|
5025 } |
|
5026 |
|
5027 LOGEXITFN1("CConnMonIAP::BearerIdForBearerAvailability()", err) |
|
5028 return err; |
|
5029 } |
|
5030 |
|
5031 // End-of-file |