|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <centralrepository.h> |
|
20 #include <commsdattypesv1_1.h> |
|
21 #include <commdb.h> |
|
22 #include <commdbconnpref.h> |
|
23 #include <featdiscovery.h> |
|
24 #include <features.hrh> |
|
25 #include <ProfileEngineSDKCRKeys.h> |
|
26 #include <httpstringconstants.h> |
|
27 #include <StringLoader.h> |
|
28 #include <data_caging_path_literals.hrh> |
|
29 #include <extendedconnpref.h> |
|
30 |
|
31 #include "irdebug.h" |
|
32 #include "irfilteredapreader.h" |
|
33 #include "irnetworkcontroller.h" |
|
34 #include "irnetworkobserver.h" |
|
35 #include "irsettings.h" |
|
36 #include "iractivenetworkobserver.h" |
|
37 |
|
38 const TInt KMaxIRUAProfLength = 250; // Max length of the UAProf string |
|
39 const TInt KIRDefaultUAProfBufferSize = 0x80; |
|
40 const TUint KIRESockMessageSlots = 16; |
|
41 const TInt KArraySize = 5; |
|
42 const TInt KWlanStringMaxLength = 9; |
|
43 const TInt KTwo = 2; |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // define in WebUtilsSDKCRKeys.h |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 const TUid KCRUidWebUtils = {0x101F8731};//Web APIs removal and Internet Radio build break |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // define in WebUtilsInternalCRKeys.h |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 // Compatability fragment of useragent string |
|
56 const TUint32 KWebUtilsUsrAg2 = 0x00000001; |
|
57 |
|
58 // PlatformVersion fragment of useragent string |
|
59 const TUint32 KWebUtilsUsrAg3 = 0x00000002; |
|
60 |
|
61 // MidPVersion fragment of useragent string |
|
62 const TUint32 KWebUtilsUsrAg4 = 0x00000003; |
|
63 |
|
64 // CLDConfiguration fragment of useragent string |
|
65 const TUint32 KWebUtilsUsrAg5 = 0x00000004; |
|
66 |
|
67 // Url to useragent profile |
|
68 const TUint32 KWebUtilsUaProf = 0x00000008; |
|
69 // To Format the UAProf string |
|
70 _LIT( KIRUAProfSpace," " ); |
|
71 // WLan ( generic ) name string |
|
72 _LIT( KIRWLanName,"Easy WLAN" ); |
|
73 |
|
74 |
|
75 // ----------------------------------------------------------------------------------------------- |
|
76 // Creates an Instance of CIRNetworkController |
|
77 // ----------------------------------------------------------------------------------------------- |
|
78 // |
|
79 EXPORT_C CIRNetworkController* CIRNetworkController::OpenL( MIRNetworkController* aObserver ) |
|
80 { |
|
81 IRLOG_DEBUG( "CIRNetworkController::OpenL - Entering" ); |
|
82 CIRNetworkController* networkController = reinterpret_cast<CIRNetworkController*>( Dll::Tls() ); |
|
83 |
|
84 if ( !networkController ) |
|
85 { |
|
86 networkController = new ( ELeave ) CIRNetworkController; |
|
87 CleanupClosePushL( *networkController ); |
|
88 networkController->iSingletonInstances = 1; |
|
89 networkController->ConstructL( aObserver ); |
|
90 User::LeaveIfError( Dll::SetTls( networkController ) ); |
|
91 networkController->iSingletonInstances = 0; |
|
92 CleanupStack::Pop( networkController ); |
|
93 } |
|
94 networkController->iSingletonInstances++; |
|
95 if ( NULL != aObserver ) |
|
96 { |
|
97 networkController->iObserver = aObserver; |
|
98 networkController->iIRNetworkObserver->SetObserver( aObserver ); |
|
99 } |
|
100 IRLOG_DEBUG( "CIRNetworkController::OpenL - Exiting." ); |
|
101 return networkController; |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------------------------- |
|
105 // Conditionally destroys the IRNetworkController object |
|
106 // ----------------------------------------------------------------------------------------------- |
|
107 // |
|
108 EXPORT_C void CIRNetworkController::Close() |
|
109 { |
|
110 IRLOG_DEBUG2( "CIRNetworkController::Close - singleton instances=%d", iSingletonInstances ); |
|
111 iSingletonInstances--; |
|
112 |
|
113 if ( iSingletonInstances == 0 ) |
|
114 { |
|
115 delete this; |
|
116 } |
|
117 IRLOG_DEBUG( "CIRNetworkController::Close - Exiting." ); |
|
118 } |
|
119 |
|
120 // ----------------------------------------------------------------------------------------------- |
|
121 // CIRNetworkController::GetIRConnection |
|
122 // Returns the instance of RConnection |
|
123 // The same RConnection object is used across the entire iRAPP components to |
|
124 // provide central arbiter and monitoring of Network Connection |
|
125 // ----------------------------------------------------------------------------------------------- |
|
126 // |
|
127 EXPORT_C RConnection& CIRNetworkController::GetIRConnection() |
|
128 { |
|
129 IRLOG_DEBUG( "CIRNetworkController::GetIRConnection - Entering" ); |
|
130 // If the RConnection is open return the reference |
|
131 switch ( iNetworkConnectionState ) |
|
132 { |
|
133 case EIRNetworkConnectionActive: |
|
134 { |
|
135 // Connection is active and ready to use return the reference |
|
136 return ( *iIRNetworkConnection ); |
|
137 } |
|
138 case EIRNetworkConnectionInActive: |
|
139 { |
|
140 // Connection is not active and application cannot continue hence panic |
|
141 _LIT( KComponentName,"NetworkController" ); |
|
142 User::Panic( KComponentName,KErrCouldNotConnect ); |
|
143 } |
|
144 break; |
|
145 default: |
|
146 { |
|
147 // no implementation |
|
148 } |
|
149 break; |
|
150 } |
|
151 // Inserted to remove the compiler warning |
|
152 IRLOG_DEBUG( "CIRNetworkController::GetIRConnection - Exiting." ); |
|
153 return ( *iIRNetworkConnection ); |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------------------------- |
|
157 // CIRNetworkController::GetIRSocketServer |
|
158 // Returns the instance of RSocketServ |
|
159 // The same RSocketServ object is used across the entire iRAPP components to |
|
160 // provide central arbiter and monitoring of Network Connection |
|
161 // ----------------------------------------------------------------------------------------------- |
|
162 // |
|
163 EXPORT_C RSocketServ& CIRNetworkController::GetIRSocketServer() |
|
164 { |
|
165 IRLOG_DEBUG( "CIRNetworkController::GetIRSocketServer - Entering" ); |
|
166 switch ( iSocketServerConnectionState ) |
|
167 { |
|
168 case EIRSocketServerActive: |
|
169 { |
|
170 // Connection to Socket Server is active hence return the reference |
|
171 return iIRSocketServer; |
|
172 } |
|
173 case EIRSocketServerInActive: |
|
174 { |
|
175 // Connection to Socket Server not open hence open and return the reference |
|
176 // Connection is not active and application cannot continue hence panic |
|
177 _LIT( KComponentName,"NetworkController" ); |
|
178 User::Panic( KComponentName,KErrCouldNotConnect ); |
|
179 } |
|
180 break; |
|
181 default: |
|
182 { |
|
183 // no implemenatation |
|
184 } |
|
185 break; |
|
186 } |
|
187 // Inserted to remove the compiler warning |
|
188 IRLOG_DEBUG( "CIRNetworkController::GetIRSocketServer - Exiting." ); |
|
189 return iIRSocketServer; |
|
190 } |
|
191 |
|
192 // ----------------------------------------------------------------------------------------------- |
|
193 // CIRNetworkController::GetWapProfString |
|
194 // Returns a HBufC pointer to the x-wap-profile string |
|
195 // Transfers the ownership of the returned HBufC8 object |
|
196 // The caller must takecare of deleting the returned object |
|
197 // ----------------------------------------------------------------------------------------------- |
|
198 // |
|
199 EXPORT_C HBufC8* CIRNetworkController::GetWapProfString() |
|
200 { |
|
201 IRLOG_DEBUG( "CIRNetworkController::GetWapProfString" ); |
|
202 return iIRWapProf; |
|
203 } |
|
204 |
|
205 // ----------------------------------------------------------------------------------------------- |
|
206 // CIRNetworkController::GetUAProfString |
|
207 // Returns a HBufC pointer to the UAProf string |
|
208 // Transfers the ownership of the returned HBufC8 object |
|
209 // The caller must takecare of deleting the returned object |
|
210 // ----------------------------------------------------------------------------------------------- |
|
211 // |
|
212 EXPORT_C HBufC8* CIRNetworkController::GetUAProfString() |
|
213 { |
|
214 IRLOG_DEBUG( "CIRNetworkController::GetUAProfString" ); |
|
215 return iIRUAProf; |
|
216 } |
|
217 |
|
218 // ----------------------------------------------------------------------------------------------- |
|
219 // CIRNetworkController::GetNetworkStatus |
|
220 // Returns the variable which indicates if connection is active or not |
|
221 // ----------------------------------------------------------------------------------------------- |
|
222 // |
|
223 EXPORT_C TBool CIRNetworkController::GetNetworkStatus() const |
|
224 { |
|
225 IRLOG_DEBUG( "CIRNetworkController::GetNetworkStatus" ); |
|
226 return iIsConnectedToNetwork; |
|
227 } |
|
228 |
|
229 // ----------------------------------------------------------------------------------------------- |
|
230 // CIRNetworkController::GetIAPId |
|
231 // Gets the IAP Id of the chosen IAP |
|
232 // ----------------------------------------------------------------------------------------------- |
|
233 // |
|
234 EXPORT_C TInt CIRNetworkController::GetIAPId( TUint32& aIapId ) const |
|
235 { |
|
236 IRLOG_DEBUG( "CIRNetworkController::GetIAPId - Entering" ); |
|
237 TInt retVal( KErrNone ); |
|
238 if ( iIsConnectedToNetwork ) |
|
239 { |
|
240 if ( iIRNetworkObserver->iIsIAPIdAvailable ) |
|
241 { |
|
242 aIapId = iIRNetworkObserver->iIAPId; |
|
243 } |
|
244 } |
|
245 else |
|
246 { |
|
247 retVal = KErrNotFound; |
|
248 } |
|
249 IRLOG_DEBUG( "CIRNetworkController::GetIAPId - Exiting." ); |
|
250 return retVal; |
|
251 } |
|
252 |
|
253 // --------------------------------------------------------------------------- |
|
254 // CIRNetworkController::ChooseAccessPointL |
|
255 // Configures the Access Point which is used by all the components for network |
|
256 // connectivity |
|
257 // --------------------------------------------------------------------------- |
|
258 // |
|
259 |
|
260 |
|
261 EXPORT_C void CIRNetworkController::ChooseAccessPointL(TBool aDefaultConnection) |
|
262 { |
|
263 IRLOG_DEBUG( "CIRNetworkController::ChooseAccessPointL - Entering" ); |
|
264 if (iHandingOver) |
|
265 { |
|
266 if (iObserver) |
|
267 { |
|
268 iObserver->IRNetworkEventL(ENetworkConnectionConnecting); |
|
269 } |
|
270 IRLOG_DEBUG("CIRNetworkController::ChooseAccessPointL, ALR is handing over, Exiting"); |
|
271 return; |
|
272 } |
|
273 |
|
274 iIRNetworkObserver->SetNetworkMonitoring( ETrue ); |
|
275 iDefaultConnection = aDefaultConnection; |
|
276 |
|
277 // Always validate the Access Points status |
|
278 if ( ValidateAccessPointsL() ) |
|
279 { |
|
280 if ( NULL != iMobility ) |
|
281 { |
|
282 iMobility->Cancel(); |
|
283 delete iMobility; |
|
284 iMobility = NULL; |
|
285 } |
|
286 // Connect to the Symbian Socket Server |
|
287 iIRNetworkConnection->Close(); |
|
288 iIRSocketServer.Close(); |
|
289 TInt ReturnErrorCode = iIRSocketServer.Connect( KIRESockMessageSlots ); |
|
290 |
|
291 if(ReturnErrorCode != KErrNone ) |
|
292 { |
|
293 // Error in opening the connection to SocketServer |
|
294 iSocketServerConnectionState = EIRSocketServerInActive; |
|
295 IRLOG_DEBUG( "CIRNetworkController::ChooseAccessPointL - Exiting ( 1 )." ); |
|
296 return ; |
|
297 } |
|
298 |
|
299 // Connection to RSocketServ is sucessful |
|
300 iSocketServerConnectionState = EIRSocketServerActive; |
|
301 |
|
302 // Open the RConnection over the iIRSocketServer |
|
303 ReturnErrorCode = iIRNetworkConnection->Open(iIRSocketServer); |
|
304 |
|
305 if( ReturnErrorCode != KErrNone ) |
|
306 { |
|
307 // Error in opening the connection |
|
308 iNetworkConnectionState = EIRNetworkConnectionInActive; |
|
309 IRLOG_DEBUG( "CIRNetworkController::ChooseAccessPointL - Exiting ( 2 )." ); |
|
310 return ; |
|
311 } |
|
312 |
|
313 //Added for ALR/SNAP |
|
314 if ( !IsActive() ) |
|
315 { |
|
316 if (iDefaultConnection) |
|
317 { |
|
318 TConnPrefList prefList; |
|
319 TExtendedConnPref extPrefs; |
|
320 |
|
321 extPrefs.SetSnapPurpose(CMManager::ESnapPurposeInternet); |
|
322 extPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnDisableNotes); |
|
323 prefList.AppendL(&extPrefs); |
|
324 iIRNetworkConnection->Start(prefList, iStatus); |
|
325 } |
|
326 else |
|
327 { |
|
328 TCommDbConnPref connPref; |
|
329 connPref.SetDialogPreference(ECommDbDialogPrefPrompt); |
|
330 iIRNetworkConnection->Start(connPref, iStatus) ; |
|
331 } |
|
332 |
|
333 // Set the NetworkController state |
|
334 iNetworkControllerState = EConnectingToNetwork; |
|
335 |
|
336 SetActive(); |
|
337 iIsConnectRequestIssued = ETrue; |
|
338 if ( iObserver ) |
|
339 { |
|
340 IRLOG_DEBUG( "CIRNetworkController::ChooseAccessPointL - notify ENetworkConnectionConnecting" ); |
|
341 iObserver->IRNetworkEventL( ENetworkConnectionConnecting ); |
|
342 } |
|
343 } |
|
344 IRLOG_DEBUG( "CIRNetworkController::ChooseAccessPointL - Exiting ( 3 )." ); |
|
345 return ; |
|
346 } |
|
347 else |
|
348 { |
|
349 iObserver->IRNetworkEventL(EAccessPointSelectionCancelled ); |
|
350 } |
|
351 IRLOG_DEBUG( "CIRNetworkController::ChooseAccessPointL - Exiting ( 4 )." ); |
|
352 } |
|
353 |
|
354 // ----------------------------------------------------------------------------------------------- |
|
355 // CIRNetworkController::CancelConnecting |
|
356 // ----------------------------------------------------------------------------------------------- |
|
357 // |
|
358 EXPORT_C void CIRNetworkController::CancelConnecting() |
|
359 { |
|
360 IRLOG_DEBUG("CIRNetworkController::CancelConnecting(), Entering"); |
|
361 iIRNetworkObserver->Cancel(); |
|
362 Cancel(); |
|
363 ResetConnectionStatus(); |
|
364 IRLOG_DEBUG("CIRNetworkController::CancelConnecting(), Exiting"); |
|
365 } |
|
366 |
|
367 // ----------------------------------------------------------------------------------------------- |
|
368 // CIRNetworkController::IsOfflineMode |
|
369 // This api is used to determine if the phone is in offline mode |
|
370 // ----------------------------------------------------------------------------------------------- |
|
371 // |
|
372 EXPORT_C TBool CIRNetworkController::IsOfflineMode() |
|
373 { |
|
374 IRLOG_DEBUG( "CIRNetworkController::IsOfflineMode" ); |
|
375 // System defined value for offline mode is 5 |
|
376 const TInt KOfflineMode = 5; |
|
377 TInt returnValue = 0; |
|
378 returnValue = DetermineCurrentProfile(); |
|
379 if ( returnValue == KOfflineMode ) |
|
380 { |
|
381 IRLOG_DEBUG( "CIRNetworkController::IsOfflineMode - Exiting ( 1 )." ); |
|
382 return ETrue; |
|
383 } |
|
384 IRLOG_DEBUG( "CIRNetworkController::IsOfflineMode - Exiting ( 2 )." ); |
|
385 return EFalse; |
|
386 } |
|
387 |
|
388 // ----------------------------------------------------------------------------------------------- |
|
389 // CIRNetworkController::IsWlanSupported |
|
390 // This api is used to determine if the phone supports WLan usage |
|
391 // ----------------------------------------------------------------------------------------------- |
|
392 // |
|
393 EXPORT_C TBool CIRNetworkController::IsWlanSupported() const |
|
394 { |
|
395 IRLOG_DEBUG( "CIRNetworkController::IsWlanSupported" ); |
|
396 return iIsWlanSupported; |
|
397 } |
|
398 |
|
399 // ----------------------------------------------------------------------------------------------- |
|
400 // CIRNetworkController::ResetConnectionStatus |
|
401 // Reset the connection status to Disconnected statet |
|
402 // ----------------------------------------------------------------------------------------------- |
|
403 // |
|
404 EXPORT_C void CIRNetworkController::ResetConnectionStatus() |
|
405 { |
|
406 IRLOG_DEBUG( "CIRNetworkController::ResetConnectionStatus - Entering" ); |
|
407 iIsConnectRequestIssued = EFalse; |
|
408 iNetworkConnectionState = EIRNetworkConnectionInActive; |
|
409 iIsConnectedToNetwork = EFalse; |
|
410 iConnectionPresent = EFalse; |
|
411 IRLOG_DEBUG( "CIRNetworkController::ResetConnectionStatus - Exiting." ); |
|
412 } |
|
413 |
|
414 // ----------------------------------------------------------------------------------------------- |
|
415 // CIRNetworkController::IdentifyConnectionType |
|
416 // Used to determine the type of connection |
|
417 // ----------------------------------------------------------------------------------------------- |
|
418 // |
|
419 EXPORT_C TIRConnectionType CIRNetworkController::IdentifyConnectionType() const |
|
420 { |
|
421 IRLOG_DEBUG( "CIRNetworkController::IdentifyConnectionType" ); |
|
422 IRRDEBUG2( "CIRNetworkController::IdentifyConnectionType - Entering iConnectionType = %d", iIRNetworkObserver->iIRConnectionType ); |
|
423 |
|
424 return iIRNetworkObserver->iIRConnectionType; |
|
425 } |
|
426 |
|
427 // ----------------------------------------------------------------------------------------------- |
|
428 // CIRNetworkController::DetermineCurrentProfile |
|
429 // Used to determine the current profile |
|
430 // ----------------------------------------------------------------------------------------------- |
|
431 // |
|
432 TInt CIRNetworkController::DetermineCurrentProfile() const |
|
433 { |
|
434 IRLOG_DEBUG( "CIRNetworkController::DetermineCurrentProfile" ); |
|
435 TInt value = KErrNone; |
|
436 |
|
437 TRAPD( err, |
|
438 CRepository* cRepositoryHandle = CRepository::NewLC( KCRUidProfileEngine ); |
|
439 cRepositoryHandle->Get( KProEngActiveProfile,value ); |
|
440 CleanupStack::PopAndDestroy( cRepositoryHandle ); ) |
|
441 if ( err != KErrNone ) |
|
442 { |
|
443 value = err; |
|
444 } |
|
445 |
|
446 IRLOG_DEBUG( "CIRNetworkController::DetermineCurrentProfile - Exiting." ); |
|
447 return value; |
|
448 } |
|
449 |
|
450 // ----------------------------------------------------------------------------------------------- |
|
451 // CIRNetworkController::CheckFeatureL |
|
452 // Pops up the access point list. |
|
453 // ----------------------------------------------------------------------------------------------- |
|
454 // |
|
455 TBool CIRNetworkController::CheckFeatureL( TInt aFeatureId ) const |
|
456 { |
|
457 IRLOG_DEBUG( "CIRNetworkController::CheckFeatureL" ); |
|
458 return CFeatureDiscovery::IsFeatureSupportedL( aFeatureId ); |
|
459 } |
|
460 |
|
461 // ----------------------------------------------------------------------------------------------- |
|
462 // CIRNetworkController::CIRNetworkController |
|
463 // Default C++ Constructor |
|
464 // ----------------------------------------------------------------------------------------------- |
|
465 // |
|
466 CIRNetworkController::CIRNetworkController(): CActive( |
|
467 CActive::EPriorityHigh ) |
|
468 { |
|
469 // Add the AO to the ActiveScheduler |
|
470 IRLOG_DEBUG( "CIRNetworkController::CIRNetworkController- Entering" ); |
|
471 CActiveScheduler::Add( this ); |
|
472 // Initialize the states |
|
473 iNetworkConnectionState = EIRNetworkConnectionInActive; |
|
474 iSocketServerConnectionState = EIRSocketServerInActive; |
|
475 iNetworkControllerState = EInActive; |
|
476 |
|
477 |
|
478 IRLOG_DEBUG( "CIRNetworkController::CIRNetworkController - Exiting." ); |
|
479 } |
|
480 |
|
481 // ----------------------------------------------------------------------------------------------- |
|
482 // CIRNetworkController::~CIRNetworkController |
|
483 // Default C++ Destructor |
|
484 // ----------------------------------------------------------------------------------------------- |
|
485 // |
|
486 CIRNetworkController::~CIRNetworkController() |
|
487 { |
|
488 IRLOG_DEBUG( "CIRNetworkController::~CIRNetworkController- Entering" ); |
|
489 _LIT( KErrorMsg,"Method Close not called" ); |
|
490 __ASSERT_ALWAYS( iSingletonInstances == 0, User::Panic( KErrorMsg, KErrCorrupt ) ); |
|
491 |
|
492 if ( NULL != iMobility ) |
|
493 { |
|
494 iMobility->Cancel(); |
|
495 delete iMobility; |
|
496 iMobility = NULL; |
|
497 } |
|
498 |
|
499 if ( IsActive() ) |
|
500 { |
|
501 Cancel(); |
|
502 } |
|
503 if ( iIRNetworkConnection ) |
|
504 { |
|
505 iIRNetworkConnection->Close(); |
|
506 delete iIRNetworkConnection; |
|
507 } |
|
508 |
|
509 // Set all the state variables to indicate network connection is closed |
|
510 delete iIRUAProf; |
|
511 delete iIRWapProf; |
|
512 if ( iIRSettings ) |
|
513 { |
|
514 iIRSettings->Close(); |
|
515 iIRSettings = NULL; |
|
516 } |
|
517 delete iIRNetworkObserver; |
|
518 iIRSocketServer.Close(); |
|
519 |
|
520 if ( iIapList ) |
|
521 { |
|
522 iIapList->Reset(); |
|
523 delete iIapList; |
|
524 iIapList = NULL; |
|
525 } |
|
526 |
|
527 if ( iDataTransferTracker ) |
|
528 { |
|
529 delete iDataTransferTracker; |
|
530 iDataTransferTracker = NULL; |
|
531 } |
|
532 if ( iLogoDataTransferTracker ) |
|
533 { |
|
534 delete iLogoDataTransferTracker; |
|
535 iLogoDataTransferTracker = NULL; |
|
536 } |
|
537 iObserver = NULL; |
|
538 |
|
539 iActiveNetworkObserverArray.Close(); |
|
540 |
|
541 Dll::FreeTls(); |
|
542 IRLOG_DEBUG( "CIRNetworkController::~CIRNetworkController - Exiting." ); |
|
543 } |
|
544 |
|
545 // ----------------------------------------------------------------------------------------------- |
|
546 // CIRNetworkController::ConstructL |
|
547 // Second Phase construction. |
|
548 // aObserver pointer to the observer class if an observer is needed |
|
549 // ----------------------------------------------------------------------------------------------- |
|
550 // |
|
551 void CIRNetworkController::ConstructL( MIRNetworkController* aObserver ) |
|
552 { |
|
553 IRLOG_DEBUG( "CIRNetworkController::ConstructL- Entering" ); |
|
554 iObserver = aObserver; |
|
555 iIRNetworkObserver = CIRNetworkObserver::NewL(this); |
|
556 iIRNetworkObserver->SetObserver( iObserver ); |
|
557 |
|
558 // Create instance of DataTransferTracker ( Byte Counter Impl ) |
|
559 iDataTransferTracker = CIRDataTransferTracker::NewL(); |
|
560 iLogoDataTransferTracker = CIRDataTransferTracker::NewL(); |
|
561 |
|
562 iIRNetworkConnection = new ( ELeave ) RConnection; |
|
563 |
|
564 iIRSettings = CIRSettings::OpenL(); |
|
565 |
|
566 BuildUAProfStringL(); |
|
567 iIapList = new ( ELeave ) CDesCArrayFlat( KArraySize ); |
|
568 |
|
569 QueryCommsForIAPL(); |
|
570 |
|
571 IRLOG_DEBUG( "CIRNetworkController::ConstructL - Exiting." ); |
|
572 } |
|
573 |
|
574 // ----------------------------------------------------------------------------------------------- |
|
575 // CIRNetworkController::QueryCommsForIAPL |
|
576 // Determines the available access points using CommsDat Api |
|
577 // voilates PCLint Error 40 --Undeclared identifier 'KFeatureIdProtocolWlan' |
|
578 // as defined in featureinfo.h |
|
579 // ----------------------------------------------------------------------------------------------- |
|
580 // |
|
581 void CIRNetworkController::QueryCommsForIAPL() |
|
582 { |
|
583 IRLOG_DEBUG( "CIRNetworkController::QueryCommsForIAPL- Entering" ); |
|
584 |
|
585 // Reset all the comms info |
|
586 iIapList->Reset(); |
|
587 |
|
588 #ifndef __WINS__ |
|
589 CIRFilteredApReader* filteredReader = CIRFilteredApReader:: |
|
590 NewLC( CIRFilteredApReader::KIRFilterWAPOnly | |
|
591 CIRFilteredApReader::KIRFilterWAPMandatory | |
|
592 CIRFilteredApReader::KIRFilterEasyWLAN ); |
|
593 |
|
594 CCDIAPRecord* iapRecord = filteredReader->FirstRecordL(); |
|
595 |
|
596 while ( iapRecord ) |
|
597 { |
|
598 CleanupStack::PushL( iapRecord ); |
|
599 |
|
600 iIapList->AppendL( iapRecord->iRecordName.GetL() ); |
|
601 |
|
602 CleanupStack::PopAndDestroy( iapRecord ); |
|
603 iapRecord = filteredReader->NextRecordL(); |
|
604 } |
|
605 CleanupStack::PopAndDestroy( filteredReader ); |
|
606 #else |
|
607 CMDBSession* dbSession = CMDBSession::NewL(CMDBSession::LatestVersion()); |
|
608 CleanupStack::PushL(dbSession); |
|
609 |
|
610 CMDBRecordSet<CCDIAPRecord>* iapSet = new (ELeave) CMDBRecordSet< |
|
611 CCDIAPRecord> (KCDTIdIAPRecord); |
|
612 CleanupStack::PushL(iapSet); |
|
613 |
|
614 TRAP_IGNORE(iapSet->LoadL(*dbSession)); |
|
615 |
|
616 for ( TInt i = 0; i < iapSet->iRecords.Count(); i++ ) |
|
617 { |
|
618 CCDIAPRecord* iapRecord = |
|
619 static_cast<CCDIAPRecord*> (iapSet->iRecords[i]); |
|
620 iIapList->AppendL(iapRecord->iRecordName.GetL()); |
|
621 } |
|
622 CleanupStack::PopAndDestroy(2, dbSession); |
|
623 #endif |
|
624 |
|
625 // If WLan is supported on the device then add the WLan option |
|
626 // to the IAP List |
|
627 #ifndef __WINS__ |
|
628 iIsWlanSupported = CheckFeatureL( KFeatureIdProtocolWlan ); |
|
629 if ( iIsWlanSupported ) |
|
630 { |
|
631 TBuf<KWlanStringMaxLength> wlanString; |
|
632 wlanString.Copy( KIRWLanName ); |
|
633 iIapList->AppendL( wlanString ); |
|
634 } |
|
635 #endif |
|
636 |
|
637 iIapList->Compress(); |
|
638 |
|
639 IRLOG_DEBUG( "CIRNetworkController::QueryCommsForIAPL - Exiting." ); |
|
640 } |
|
641 |
|
642 // ----------------------------------------------------------------------------------------------- |
|
643 // CIRNetworkController::BuildUAProfStringL |
|
644 // Queries the system and extracts the UAProf information |
|
645 // Used by IRDataProvider and IRStreamSource |
|
646 // ----------------------------------------------------------------------------------------------- |
|
647 // |
|
648 void CIRNetworkController::BuildUAProfStringL() |
|
649 { |
|
650 IRLOG_DEBUG( "CIRNetworkController::BuildUAProfStringL- Entering" ); |
|
651 // Create space on heap for the UAProf String |
|
652 iIRUAProf = HBufC8::NewL( KMaxIRUAProfLength ); |
|
653 iIRWapProf = HBufC8::NewL( KMaxIRUAProfLength ); |
|
654 HBufC* cenRepPtr; |
|
655 TPtr8 irUAProf = iIRUAProf->Des(); |
|
656 TPtr8 irWapProf = iIRWapProf->Des(); |
|
657 irUAProf.Append( iIRSettings->GetIrappVersionL() ); |
|
658 |
|
659 cenRepPtr = NULL; |
|
660 irUAProf.Append( KIRUAProfSpace ); |
|
661 // extract UAProf sub-string from cenrep |
|
662 cenRepPtr = CentralRepositoryStringValueL( KCRUidWebUtils,KWebUtilsUsrAg3 ); |
|
663 // append it to form the UAProf |
|
664 irUAProf.Append( cenRepPtr->Des() ); |
|
665 delete cenRepPtr; |
|
666 cenRepPtr = NULL; |
|
667 |
|
668 irUAProf.Append( KIRUAProfSpace ); |
|
669 // extract UAProf sub-string from cenrep |
|
670 cenRepPtr = CentralRepositoryStringValueL( KCRUidWebUtils,KWebUtilsUsrAg2 ); |
|
671 // append it to form the UAProf |
|
672 irUAProf.Append( cenRepPtr->Des() ); |
|
673 delete cenRepPtr; |
|
674 cenRepPtr = NULL; |
|
675 |
|
676 irUAProf.Append( KIRUAProfSpace ); |
|
677 // extract UAProf sub-string from cenrep |
|
678 cenRepPtr = CentralRepositoryStringValueL( KCRUidWebUtils,KWebUtilsUsrAg4 ); |
|
679 // append it to form the UAProf |
|
680 irUAProf.Append( cenRepPtr->Des() ); |
|
681 delete cenRepPtr; |
|
682 cenRepPtr = NULL; |
|
683 |
|
684 irUAProf.Append( KIRUAProfSpace ); |
|
685 // extract UAProf sub-string from cenrep |
|
686 cenRepPtr = CentralRepositoryStringValueL( KCRUidWebUtils,KWebUtilsUsrAg5 ); |
|
687 // append it to form the UAProf |
|
688 irUAProf.Append( cenRepPtr->Des() ); |
|
689 delete cenRepPtr; |
|
690 cenRepPtr = NULL; |
|
691 // trim out the quotes |
|
692 irUAProf.Delete( irUAProf.Length()-1,1 ); |
|
693 // extract x-wap-profile string from cenrep |
|
694 cenRepPtr = CentralRepositoryStringValueL( KCRUidWebUtils,KWebUtilsUaProf ); |
|
695 // append it to form the UAProf |
|
696 irWapProf.Copy( cenRepPtr->Des() ); |
|
697 delete cenRepPtr; |
|
698 cenRepPtr = NULL; |
|
699 |
|
700 IRLOG_DEBUG( "CIRNetworkController::BuildUAProfStringL - Exiting." ); |
|
701 } |
|
702 |
|
703 // ----------------------------------------------------------------------------------------------- |
|
704 // CIRNetworkController::CentralRepositoryStringValueL |
|
705 // Retrievs the string from Central Repository for the specified key and cen rep uid |
|
706 // Transfers the ownership of the returned HBufC object |
|
707 // The caller must takecare of deleting the returned object* |
|
708 // ----------------------------------------------------------------------------------------------- |
|
709 // |
|
710 HBufC* CIRNetworkController::CentralRepositoryStringValueL( |
|
711 const TUid& aRepositoryUid, TUint32 aKey ) const |
|
712 { |
|
713 IRLOG_DEBUG( "CIRNetworkController::CentralRepositoryStringValueL- Entering" ); |
|
714 CRepository* pRepository = CRepository::NewL( aRepositoryUid ); |
|
715 CleanupStack::PushL( pRepository ); |
|
716 |
|
717 TInt length = KIRDefaultUAProfBufferSize; |
|
718 HBufC* valueString = HBufC::NewLC( length ); |
|
719 TInt error( KErrTooBig ); |
|
720 do |
|
721 { |
|
722 TPtr ptr = valueString->Des(); |
|
723 error = pRepository->Get( aKey, ptr ); |
|
724 if ( error == KErrTooBig ) |
|
725 { |
|
726 CleanupStack::PopAndDestroy( valueString ); |
|
727 length = KTwo * length; |
|
728 valueString = HBufC::NewLC( length ); |
|
729 } |
|
730 } while ( error == KErrTooBig ); |
|
731 |
|
732 if ( error ) |
|
733 { |
|
734 TPtr ptr = valueString->Des(); |
|
735 ptr.Copy( KNullDesC() ); |
|
736 } |
|
737 |
|
738 CleanupStack::Pop( valueString ); |
|
739 CleanupStack::PopAndDestroy( pRepository ); |
|
740 IRLOG_DEBUG( "CIRNetworkController::CentralRepositoryStringValueL - Exiting." ); |
|
741 return valueString; |
|
742 } |
|
743 |
|
744 // ----------------------------------------------------------------------------------------------- |
|
745 // CIRNetworkController::ValidateAccessPointsL( |
|
746 // Validates the access point availablity etc. |
|
747 // voilates PCLint Error 40 --Undeclared identifier 'KFeatureIdProtocolWlan' |
|
748 // as defined in featureinfo.h |
|
749 // ----------------------------------------------------------------------------------------------- |
|
750 // |
|
751 TBool CIRNetworkController::ValidateAccessPointsL() |
|
752 { |
|
753 IRLOG_DEBUG( "CIRNetworkController::ValidateAccessPointsL- Entering" ); |
|
754 TBool status = ETrue; |
|
755 #ifndef __WINS__ |
|
756 // Check if the phone is in offline mode |
|
757 // If yes, do not allow GPRS access |
|
758 // If phone is in offline mode and device does not support |
|
759 // WIFI then exit the application |
|
760 // Do not make this check in Wins |
|
761 //violates PC Lint error : Error 40: Undeclared identifier KFeatureIdProtocolWlan |
|
762 if ( IsOfflineMode() && !( CheckFeatureL( KFeatureIdProtocolWlan) ) ) |
|
763 { |
|
764 // The phone is in offline mode and WLan is not available |
|
765 iObserver->IRNetworkEventL( EDisplayOfflineMode ); |
|
766 status = EFalse; |
|
767 } |
|
768 // If phone is not in offline mode and no access points are defined |
|
769 // check if device has WIFI support then try to launch WIFI |
|
770 // selection if there is no support then display a message |
|
771 if ( !IsOfflineMode() && iIapList->MdcaCount() == 0 ) |
|
772 { |
|
773 // Check if there is WIFI support |
|
774 //violates PC Lint error : Error 40: Undeclared identifier KFeatureIdProtocolWlan |
|
775 if ( !CheckFeatureL( KFeatureIdProtocolWlan ) ) |
|
776 { |
|
777 iObserver->IRNetworkEventL( EDisplayNoAccessPointsDefined ); |
|
778 status = EFalse; |
|
779 } |
|
780 } |
|
781 #endif |
|
782 IRLOG_DEBUG( "CIRNetworkController::ValidateAccessPointsL - Exiting." ); |
|
783 return status; |
|
784 } |
|
785 |
|
786 // Derived from CActive |
|
787 // ----------------------------------------------------------------------------------------------- |
|
788 // CIRNetworkController::RunL |
|
789 // The function is called by the active scheduler when a request completion event occurs, |
|
790 // ----------------------------------------------------------------------------------------------- |
|
791 // |
|
792 void CIRNetworkController::RunL() |
|
793 { |
|
794 IRLOG_INFO2( "CIRNetworkController::RunL - iStatus=%d", iStatus.Int() ); |
|
795 iHandingOver = EFalse; |
|
796 |
|
797 TInt statusCode = iStatus.Int(); |
|
798 |
|
799 if ( iStatus == KErrNone ) |
|
800 { |
|
801 HandleRunLSuccessL(); |
|
802 } |
|
803 else |
|
804 { |
|
805 HandleRunLErrorL( statusCode ); |
|
806 } |
|
807 IRLOG_DEBUG( "CIRNetworkController::RunL - Exiting." ); |
|
808 } |
|
809 |
|
810 // ----------------------------------------------------------------------------------------------- |
|
811 // CIRNetworkController::DoCancel() |
|
812 // Cancels the pending requests on the CIRNetworkController Active object |
|
813 // ----------------------------------------------------------------------------------------------- |
|
814 // |
|
815 void CIRNetworkController::DoCancel() |
|
816 { |
|
817 IRLOG_DEBUG( "CIRNetworkController::DoCancel - Entering" ); |
|
818 if ( NULL != iMobility ) |
|
819 { |
|
820 iMobility->Cancel(); |
|
821 delete iMobility; |
|
822 iMobility = NULL; |
|
823 } |
|
824 iIRNetworkConnection->Stop(); |
|
825 iIRNetworkConnection->Close(); |
|
826 iIRSocketServer.Close(); |
|
827 IRLOG_DEBUG( "CIRNetworkController::DoCancel - Exiting." ); |
|
828 } |
|
829 |
|
830 // ----------------------------------------------------------------------------- |
|
831 // CIRNetworkController::InitializeHttpSession |
|
832 // ----------------------------------------------------------------------------- |
|
833 // |
|
834 EXPORT_C void CIRNetworkController::InitializeHttpSessionL( const RHTTPSession& aHTTPSession, |
|
835 MIRDataTransferTracker::TIRTransferCategory aCategory ) |
|
836 { |
|
837 IRLOG_DEBUG( "CVRConnection::InitializeHttpSessionL - enter" ); |
|
838 |
|
839 iDataTransferTracker->BindL( aHTTPSession, aCategory ); |
|
840 |
|
841 RStringF sockserv = aHTTPSession.StringPool().StringF( |
|
842 HTTP::EHttpSocketServ, RHTTPSession::GetTable()); |
|
843 CleanupClosePushL( sockserv ); |
|
844 |
|
845 RStringF connection = aHTTPSession.StringPool().StringF( |
|
846 HTTP::EHttpSocketConnection, RHTTPSession::GetTable()); |
|
847 CleanupClosePushL( connection ); |
|
848 |
|
849 RHTTPConnectionInfo cInfo = aHTTPSession.ConnectionInfo(); |
|
850 cInfo.SetPropertyL( sockserv, THTTPHdrVal( iIRSocketServer.Handle() ) ); |
|
851 cInfo.SetPropertyL(connection, THTTPHdrVal( |
|
852 reinterpret_cast<TInt> (iIRNetworkConnection))); |
|
853 CleanupStack::PopAndDestroy( &connection ); // sockserv.close, connection.close |
|
854 CleanupStack::PopAndDestroy( &sockserv ); // sockserv.close, connection.close |
|
855 |
|
856 IRLOG_DEBUG( "CIRNetworkController::InitializeHttpSessionL - exit" ); |
|
857 } |
|
858 |
|
859 // ----------------------------------------------------------------------------- |
|
860 // CIRNetworkController::RegisterLogoDataTransferTrackerL |
|
861 // ----------------------------------------------------------------------------- |
|
862 // |
|
863 EXPORT_C void CIRNetworkController::RegisterLogoDataTransferTrackerL( RHTTPSession& aHTTPSession ) |
|
864 { |
|
865 IRLOG_DEBUG( "CVRConnection::InitializeHttpSessionL - enter" ); |
|
866 |
|
867 iLogoDataTransferTracker->BindL(aHTTPSession, |
|
868 MIRDataTransferTracker::EIRTransferCategoryIsds); |
|
869 |
|
870 RStringF sockserv = aHTTPSession.StringPool().StringF( |
|
871 HTTP::EHttpSocketServ, RHTTPSession::GetTable()); |
|
872 CleanupClosePushL( sockserv ); |
|
873 |
|
874 RStringF connection = aHTTPSession.StringPool().StringF( |
|
875 HTTP::EHttpSocketConnection, RHTTPSession::GetTable()); |
|
876 CleanupClosePushL( connection ); |
|
877 |
|
878 RHTTPConnectionInfo cInfo = aHTTPSession.ConnectionInfo(); |
|
879 cInfo.SetPropertyL( sockserv, THTTPHdrVal( iIRSocketServer.Handle() ) ); |
|
880 cInfo.SetPropertyL(connection, THTTPHdrVal( |
|
881 reinterpret_cast<TInt> (iIRNetworkConnection))); |
|
882 CleanupStack::PopAndDestroy( &connection ); // sockserv.close, connection.close |
|
883 CleanupStack::PopAndDestroy( &sockserv ); // sockserv.close, connection.close |
|
884 |
|
885 // Subscribe to logo byte counter info |
|
886 iLogoDataTransferTracker->SetObserver( this ); |
|
887 |
|
888 IRLOG_DEBUG( "CIRNetworkController::RegisterLogoDataTransferTrackerL - exit" ); |
|
889 } |
|
890 |
|
891 // ----------------------------------------------------------------------------- |
|
892 // CIRNetworkController::DataTransferTracker() |
|
893 // ----------------------------------------------------------------------------- |
|
894 // |
|
895 EXPORT_C MIRDataTransferTracker& CIRNetworkController::DataTransferTracker() |
|
896 { |
|
897 IRLOG_DEBUG( "CIRNetworkController::DataTransferTracker" ); |
|
898 return *iDataTransferTracker; |
|
899 } |
|
900 |
|
901 // ----------------------------------------------------------------------------- |
|
902 // CIRNetworkController::LogoDataTransferTracker() |
|
903 // ----------------------------------------------------------------------------- |
|
904 // |
|
905 EXPORT_C MIRDataTransferTracker& CIRNetworkController::LogoDataTransferTracker() |
|
906 { |
|
907 IRLOG_DEBUG( "CIRNetworkController::LogoDataTransferTracker" ); |
|
908 return *iLogoDataTransferTracker; |
|
909 } |
|
910 |
|
911 // ----------------------------------------------------------------------------- |
|
912 // CIRNetworkController::LogoDataTransferTracker() |
|
913 // ----------------------------------------------------------------------------- |
|
914 // |
|
915 void CIRNetworkController::HandleDataTransferEventL( |
|
916 const MIRDataTransferTracker::TIRDataTransferPckg& aData ) |
|
917 { |
|
918 IRLOG_DEBUG( "CIRNetworkController::HandleDataTransferEventL - Entering" ); |
|
919 iDataTransferTracker->RawDataTransferredL(aData.iBytesSentTotal, |
|
920 aData.iBytesReceivedTotal, |
|
921 MIRDataTransferTracker::EIRTransferCategoryIsds ); |
|
922 IRLOG_DEBUG( "CIRNetworkController::HandleDataTransferEventL - Exiting" ); |
|
923 } |
|
924 |
|
925 // ----------------------------------------------------------------------------- |
|
926 // CIRNetworkController::PreferredCarrierAvailable() |
|
927 // ----------------------------------------------------------------------------- |
|
928 // |
|
929 void CIRNetworkController::PreferredCarrierAvailable( TAccessPointInfo aOldAPInfo, |
|
930 TAccessPointInfo aNewAPInfo, |
|
931 TBool aIsUpgrade, |
|
932 TBool aIsSeamless ) |
|
933 { |
|
934 IRLOG_DEBUG("CIRNetworkController::PreferredCarrierAvailable - Entering"); |
|
935 |
|
936 (void)aOldAPInfo; |
|
937 (void)aNewAPInfo; |
|
938 (void)aIsUpgrade; |
|
939 IRLOG_DEBUG5("CIRNetworkController::PreferredCarrierAvailable, old ap : %d, new ap : %d, aIsUpgrade : %d, aIsSeamless : %d", |
|
940 aOldAPInfo.AccessPoint(), aNewAPInfo.AccessPoint(), aIsUpgrade, aIsSeamless); |
|
941 |
|
942 if (aIsSeamless) |
|
943 { |
|
944 // It is Seamless. E.g. Mobile IP enabled. |
|
945 } |
|
946 else |
|
947 { |
|
948 // sockets used by the connection should be closed here. |
|
949 |
|
950 // We ask to migrate to the Preferred Carrier. |
|
951 if (!IsOfflineMode()) |
|
952 { |
|
953 //handling over connection may take some time, during handling over connection, |
|
954 //application should be in disconnected state |
|
955 TRAP_IGNORE( iObserver->IRNetworkEventL(ENetworkConnectionDisconnected ); ) |
|
956 |
|
957 iIRNetworkObserver->SetNetworkMonitoring(EFalse); |
|
958 |
|
959 iMobility->MigrateToPreferredCarrier(); |
|
960 iHandingOver = ETrue; |
|
961 } |
|
962 } |
|
963 |
|
964 IRLOG_DEBUG("CIRNetworkController::PreferredCarrierAvailable - Exiting"); |
|
965 } |
|
966 |
|
967 // ----------------------------------------------------------------------------- |
|
968 // CIRNetworkController::NewCarrierActive() |
|
969 // ----------------------------------------------------------------------------- |
|
970 // |
|
971 void CIRNetworkController::NewCarrierActive( TAccessPointInfo aNewAPInfo, TBool aIsSeamless ) |
|
972 { |
|
973 IRLOG_DEBUG("CIRNetworkController::NewCarrierActive - Entering"); |
|
974 (void)aNewAPInfo; |
|
975 IRLOG_DEBUG3("CIRNetworkController::NewCarrierActive, new ap : %d, aIsSeamless : %d", |
|
976 aNewAPInfo.AccessPoint(), aIsSeamless); |
|
977 |
|
978 if (aIsSeamless) |
|
979 { |
|
980 // It is Seamless. E.g. Mobile IP enabled. |
|
981 } |
|
982 else |
|
983 { |
|
984 // sockets used by the connection should be re-opened here. |
|
985 // We accept the new IAP. |
|
986 |
|
987 iMobility->NewCarrierAccepted(); |
|
988 |
|
989 iIsConnectRequestIssued = EFalse; |
|
990 iNetworkConnectionState = EIRNetworkConnectionActive; |
|
991 iIsConnectedToNetwork = ETrue; |
|
992 iConnectionPresent = ETrue; |
|
993 |
|
994 iIRNetworkObserver->SetNetworkMonitoring(ETrue); |
|
995 iIRNetworkObserver->InitializeNetworkObserver(); |
|
996 } |
|
997 |
|
998 IRLOG_DEBUG("CIRNetworkController::NewCarrierActive - Exiting"); |
|
999 } |
|
1000 |
|
1001 // ----------------------------------------------------------------------------- |
|
1002 // CIRNetworkController::Error() |
|
1003 // ----------------------------------------------------------------------------- |
|
1004 // |
|
1005 void CIRNetworkController::Error( TInt /*aError*/ ) |
|
1006 { |
|
1007 IRLOG_DEBUG( "CIRNetworkController::Error" ); |
|
1008 // Does nothing for the moment |
|
1009 } |
|
1010 |
|
1011 // ----------------------------------------------------------------------------- |
|
1012 // HandleRunLSuccessL() |
|
1013 // Handles the success case of Network connection in RunL |
|
1014 // ------------------------------------------------------------------------------------------------- |
|
1015 // |
|
1016 void CIRNetworkController::HandleRunLSuccessL() |
|
1017 { |
|
1018 IRLOG_DEBUG( "CIRNetworkController::HandleRunLSuccessL - Entering" ); |
|
1019 |
|
1020 switch ( iNetworkControllerState ) |
|
1021 { |
|
1022 case EConnectingToNetwork: |
|
1023 { |
|
1024 iIsConnectedToNetwork = ETrue; |
|
1025 // Connection to network sucessful |
|
1026 iNetworkConnectionState = EIRNetworkConnectionActive; |
|
1027 iConnectionPresent = ETrue; |
|
1028 iIsConnectRequestIssued = EFalse; |
|
1029 iIRNetworkObserver->InitializeNetworkObserver(); |
|
1030 } |
|
1031 break; |
|
1032 default: |
|
1033 { |
|
1034 // no implementation |
|
1035 } |
|
1036 break; |
|
1037 } |
|
1038 |
|
1039 if ( !iMobility ) |
|
1040 { |
|
1041 iMobility = CActiveCommsMobilityApiExt::NewL( *iIRNetworkConnection, |
|
1042 *this ); |
|
1043 } |
|
1044 IRLOG_DEBUG( "CIRNetworkController::HandleRunLSuccessL - Exiting" ); |
|
1045 } |
|
1046 |
|
1047 // ------------------------------------------------------------------------------------------------- |
|
1048 // HandleRunLErrorL() |
|
1049 // Handles the error case of Network connection in RunL |
|
1050 // ------------------------------------------------------------------------------------------------- |
|
1051 // |
|
1052 void CIRNetworkController::HandleRunLErrorL( TInt aStatusCode ) |
|
1053 { |
|
1054 IRLOG_DEBUG( "CIRNetworkController::HandleRunLErrorL - Entering" ); |
|
1055 |
|
1056 switch ( iNetworkControllerState ) |
|
1057 { |
|
1058 case EConnectingToNetwork: |
|
1059 { |
|
1060 // Connection to network failure |
|
1061 iNetworkConnectionState = EIRNetworkConnectionInActive; |
|
1062 iIsConnectedToNetwork = EFalse; |
|
1063 iConnectionPresent = EFalse; |
|
1064 iIsConnectRequestIssued = EFalse; |
|
1065 if ( aStatusCode != KErrCancel ) |
|
1066 { |
|
1067 if (iDefaultConnection) |
|
1068 { |
|
1069 //give user the second chance to select access point manually |
|
1070 ChooseAccessPointL(EFalse); |
|
1071 } |
|
1072 else |
|
1073 { |
|
1074 iObserver->IRNetworkEventL(EDisplayNetworkMessageNoConnectivity); |
|
1075 } |
|
1076 } |
|
1077 else |
|
1078 { |
|
1079 iObserver->IRNetworkEventL( EAccessPointSelectionCancelled ); |
|
1080 ResetPendingRequests( EFalse ); |
|
1081 } |
|
1082 } |
|
1083 break; |
|
1084 |
|
1085 default: |
|
1086 { |
|
1087 // no implementation |
|
1088 } |
|
1089 break; |
|
1090 } |
|
1091 |
|
1092 IRLOG_DEBUG( "CIRNetworkController::HandleRunLErrorL - Exiting" ); |
|
1093 } |
|
1094 |
|
1095 // ------------------------------------------------------------------------------------------------- |
|
1096 // Registers the observer that will be notified for |
|
1097 // a network connection. |
|
1098 // Observer requires notification to reissue pending request |
|
1099 // ------------------------------------------------------------------------------------------------- |
|
1100 // |
|
1101 EXPORT_C void CIRNetworkController::RegisterActiveNetworkObserverL( MIRActiveNetworkObserver& |
|
1102 aActiveNetworkObserver ) |
|
1103 { |
|
1104 IRLOG_DEBUG( "CIRNetworkController::RegisterActiveNetworkObserverL - Entering" ); |
|
1105 iActiveNetworkObserverArray.AppendL( &aActiveNetworkObserver ); |
|
1106 IRLOG_DEBUG( "CIRNetworkController::RegisterActiveNetworkObserverL - Exiting" ); |
|
1107 } |
|
1108 |
|
1109 // ----------------------------------------------------------------------------------------------- |
|
1110 // DeleteActiveNetworkObserver() |
|
1111 // Used to remove an observer for roaming events from the observer array |
|
1112 // ----------------------------------------------------------------------------------------------- |
|
1113 // |
|
1114 EXPORT_C void CIRNetworkController::DeleteActiveNetworkObserver( MIRActiveNetworkObserver& |
|
1115 aActiveNetworkObserver ) |
|
1116 { |
|
1117 IRLOG_DEBUG( "CIRNetworkController::DeleteActiveNetworkObserver - Entering" ); |
|
1118 TInt index = iActiveNetworkObserverArray.Find( &aActiveNetworkObserver ); |
|
1119 |
|
1120 if ( index != KErrNotFound ) |
|
1121 { |
|
1122 iActiveNetworkObserverArray.Remove( index ); |
|
1123 } |
|
1124 |
|
1125 IRLOG_DEBUG( "CIRNetworkController::DeleteActiveNetworkObserver - Exiting" ); |
|
1126 } |
|
1127 |
|
1128 // ----------------------------------------------------------------------------------------------- |
|
1129 // NotifyActiveNetworkObserversL() |
|
1130 // Used to notify all observers for network events about a change in network event |
|
1131 // ----------------------------------------------------------------------------------------------- |
|
1132 // |
|
1133 EXPORT_C void CIRNetworkController::NotifyActiveNetworkObserversL( TIRNetworkEvent aEvent ) |
|
1134 { |
|
1135 IRLOG_DEBUG( "CIRNetworkController::NotifyActiveNetworkObserversL - Entering" ); |
|
1136 |
|
1137 for ( TInt i=iActiveNetworkObserverArray.Count()-1; i>=0; i-- ) |
|
1138 { |
|
1139 iActiveNetworkObserverArray[i]->NotifyActiveNetworkObserversL( aEvent ); |
|
1140 } |
|
1141 |
|
1142 |
|
1143 IRLOG_DEBUG( "CIRNetworkController::NotifyActiveNetworkObserversL - Exiting" ); |
|
1144 } |
|
1145 |
|
1146 // ------------------------------------------------------------------------------------------------- |
|
1147 // IsHandingOverConnection() |
|
1148 // Indicates if the Hand over of Network connection has happened |
|
1149 // ------------------------------------------------------------------------------------------------- |
|
1150 // |
|
1151 EXPORT_C TBool CIRNetworkController::IsHandingOverConnection() |
|
1152 { |
|
1153 IRLOG_DEBUG("CIRNetworkController::IsHandingOverConnection - Entering"); |
|
1154 IRLOG_DEBUG("CIRNetworkController::IsHandingOverConnection - Exiting"); |
|
1155 return iHandingOver; |
|
1156 } |
|
1157 |
|
1158 // ------------------------------------------------------------------------------------------------- |
|
1159 // Reset member iHandingOver to EFalse. |
|
1160 // ------------------------------------------------------------------------------------------------- |
|
1161 // |
|
1162 void CIRNetworkController::ResetHandingOverConnection() |
|
1163 { |
|
1164 IRLOG_DEBUG("CIRNetworkController::ResetHandingOverConnection(), Entering"); |
|
1165 iHandingOver = EFalse; |
|
1166 IRLOG_DEBUG("CIRNetworkController::ResetHandingOverConnection(), Exiting"); |
|
1167 } |
|
1168 |
|
1169 // ------------------------------------------------------------------------------------------------- |
|
1170 // Notifies observers when user cancels network connection, to reset |
|
1171 // the pending requests |
|
1172 // ResetPendingRequests() |
|
1173 // ------------------------------------------------------------------------------------------------- |
|
1174 // |
|
1175 void CIRNetworkController::ResetPendingRequests( TBool aValue ) |
|
1176 { |
|
1177 for ( TInt i=0; i<iActiveNetworkObserverArray.Count(); i++ ) |
|
1178 { |
|
1179 iActiveNetworkObserverArray[i]->ResetPendingRequests( aValue ); |
|
1180 } |
|
1181 } |