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