|
1 /* |
|
2 * Copyright (c) 2002 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 the License "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 * This class provides connection/session related information. |
|
16 * Both the requested and the stored AP's are here. |
|
17 * |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 //INCLUDE FILES |
|
23 |
|
24 //System Includes |
|
25 #include <bldvariant.hrh> |
|
26 |
|
27 #include <ApAccessPointItem.h> |
|
28 #include <VpnAPEngine.h> |
|
29 #include <AknNotifyStd.h> |
|
30 #include <AknGlobalNote.h> |
|
31 #include <e32std.h> |
|
32 #include <ApUtils.h> |
|
33 #include <ApDataHandler.h> |
|
34 #include <cdbstore.h> |
|
35 #include <coemain.h> |
|
36 #include <bautils.h> |
|
37 #include <connectionmanager.rsg> |
|
38 #include <BARSREAD.H> |
|
39 #include <Avkon.rsg> |
|
40 #include <errorui.h> |
|
41 #include <aknglobalconfirmationquery.h> |
|
42 #include <aknquerydialog.h> |
|
43 #include <aknwaitdialog.h> |
|
44 #include <cdblen.h> |
|
45 #include <StringLoader.h> |
|
46 #include <connectprog.h> |
|
47 #include <nd_err.h> |
|
48 #include <CommDbConnPref.h> |
|
49 #include <MmTsy_names.h> |
|
50 #include <etelmm.h> |
|
51 #include <data_caging_path_literals.hrh> |
|
52 #include <AknsUtils.h> |
|
53 #include <avkon.mbg> |
|
54 #include <ConnMan.mbg> |
|
55 #include <rconnmon.h> |
|
56 #include <AgentDialog.h> |
|
57 #include <ConnectionUiUtilities.h> |
|
58 #include <AknQueryDialog.h> |
|
59 #include <WlanCdbCols.h> |
|
60 #include <etelpckt.h> |
|
61 #include <FeatMgr.h> |
|
62 #include <cmmanagerext.h> |
|
63 #include <cmdestinationext.h> |
|
64 #include <commsdat.h> |
|
65 #include <CommsDatTypeInfoV1_1.h> |
|
66 |
|
67 //User Includes |
|
68 #include "InternetConnectionManager.h" |
|
69 #include "connman.hrh" |
|
70 #include "connectionmanagerlogger.h" |
|
71 #include "connectionobservers.h" |
|
72 #include "connmanactiveconnector.h" |
|
73 |
|
74 using namespace CMManager; |
|
75 |
|
76 // CONSTANTS |
|
77 _LIT(KConnectionResourceFile, "\\resource\\ConnectionManager.rsc"); |
|
78 |
|
79 // ============================ MEMBER FUNCTIONS =============================== |
|
80 //-------------------------------------------------------------------------- |
|
81 //CInternetConnectionManager::ConnectL( TUint32 aIAPId1, TUint32 aIAPId2 ) |
|
82 //-------------------------------------------------------------------------- |
|
83 EXPORT_C TInt CInternetConnectionManager::ConnectL( TUint32 /*aIAPId1*/, TUint32 /*aIAPId2*/ ) |
|
84 { |
|
85 User::Panic( KNullDesC, KErrNotSupported ); |
|
86 |
|
87 return KErrGeneral; |
|
88 } |
|
89 |
|
90 //-------------------------------------------------------------------------- |
|
91 //CInternetConnectionManager::ConnectL( TUint32 aIAPId1 ) |
|
92 //-------------------------------------------------------------------------- |
|
93 EXPORT_C TInt CInternetConnectionManager::ConnectL( TUint32 aIAPId ) |
|
94 { |
|
95 //1) Check whether AP exists |
|
96 //2) Check CSD coverage |
|
97 //3) Check GPRS coverage |
|
98 //4) Check Whether a connection already exists |
|
99 |
|
100 CLOG_WRITE_1( "CInternetConnectionManager::ConnectL - %d", aIAPId ); |
|
101 |
|
102 // GPRS available |
|
103 iInternalError = KErrNone; |
|
104 iNewConnectionEstablished = EFalse; |
|
105 TInt connErr( KErrNone ); |
|
106 |
|
107 connErr = ConnectWithoutCheckL( aIAPId ); |
|
108 |
|
109 DisplayConnErrorL(); |
|
110 |
|
111 return connErr; |
|
112 } |
|
113 |
|
114 |
|
115 //--------------------------------------------------------------------------------------- |
|
116 //CInternetConnectionManager::ConnectWithoutCheckL( TUint32 aIAPId1 ) |
|
117 //----------------------------------------------------------------------------------------- |
|
118 TInt CInternetConnectionManager::ConnectWithoutCheckL( TUint32 aIAPId ) |
|
119 { |
|
120 CLOG_ENTERFN( "ConnectWithoutCheckL" ); |
|
121 |
|
122 iInternalError = KErrNone; |
|
123 TInt connErr; |
|
124 //Do the connection |
|
125 TCommDbConnPref pref; |
|
126 TBool gprsCovered( ETrue ); |
|
127 if( !CheckNetworkL( gprsCovered ) ) |
|
128 { |
|
129 //show that there is no coverage! |
|
130 ShowGlobalNoteL( EAknGlobalErrorNote, R_EXT_ERR_NO_NETWORK_COVER ); |
|
131 connErr = KErrGeneral; |
|
132 } |
|
133 else //there is coverage |
|
134 { |
|
135 TBool IsApGprs( EFalse ); |
|
136 IsApGprs = BearerTypeL( aIAPId ) == EApBearerTypeGPRS; |
|
137 if( !iRequestedAPIds.iFirstPreference ) |
|
138 { |
|
139 pref.SetDialogPreference( ECommDbDialogPrefPrompt ); |
|
140 } |
|
141 else |
|
142 { |
|
143 pref.SetDialogPreference( ECommDbDialogPrefDoNotPrompt ); |
|
144 } |
|
145 |
|
146 if( gprsCovered || !IsApGprs ) |
|
147 { |
|
148 pref.SetIapId( aIAPId ); |
|
149 if( !iSilentMode && iRequestedAPIds.iFirstPreference ) |
|
150 |
|
151 // Temp fix for CDMA |
|
152 { |
|
153 if( IsApGprs ) |
|
154 { |
|
155 pref.SetBearerSet( ECommDbBearerGPRS ); |
|
156 } |
|
157 else |
|
158 { |
|
159 pref.SetBearerSet( ECommDbBearerCSD ); |
|
160 } |
|
161 } |
|
162 |
|
163 if (BearerTypeL( aIAPId ) == EApBearerTypeAllBearers) |
|
164 { |
|
165 pref.SetBearerSet( ECommDbBearerCSD | |
|
166 ECommDbBearerPSD | // includes both KCommDbBearerWcdma and KCommDbBearerCdma2000. ECommDbBearerGPRS is ECommDbBearerWcdma |
|
167 ECommDbBearerLAN | |
|
168 ECommDbBearerVirtual | |
|
169 ECommDbBearerPAN | |
|
170 ECommDbBearerWLAN ); |
|
171 } |
|
172 |
|
173 connErr = ConnectL( pref ); |
|
174 } |
|
175 else //there is no gprs coverage and the AP needs it!!! |
|
176 { |
|
177 //show that there is no coverage!!! |
|
178 ShowGlobalNoteL( EAknGlobalErrorNote, R_EXT_ERR_NO_NETWORK_COVER ); |
|
179 connErr = KErrGeneral; |
|
180 } |
|
181 } |
|
182 |
|
183 if( connErr == KErrNone ) |
|
184 { |
|
185 iConnected = ETrue; |
|
186 |
|
187 // Enable connection cloning |
|
188 _LIT_SECURITY_POLICY_C2(KProcPolicy1, ECapabilityNetworkServices, ECapabilityNetworkControl); |
|
189 |
|
190 TSecurityPolicyBuf secPolBuf; |
|
191 secPolBuf().Set(KProcPolicy1().Package()); |
|
192 |
|
193 iConnection.Control(KCOLConnection, KCoEnableCloneOpen, secPolBuf); |
|
194 |
|
195 if( iSilentMode ) |
|
196 // Temp fix for CDMA |
|
197 { |
|
198 TUint32 iapId; |
|
199 TBuf<20> query; |
|
200 TBuf<40> val; |
|
201 |
|
202 query.Format( _L("%s\\%s"), IAP, COMMDB_ID ); |
|
203 User::LeaveIfError( iConnection.GetIntSetting( query, iapId ) ); |
|
204 iCurrentAP = (CApAccessPointItem*)iapId; |
|
205 |
|
206 query.Format(_L("%s\\%s"), IAP, COMMDB_NAME); |
|
207 User::LeaveIfError( iConnection.GetDesSetting( query, val ) ); |
|
208 |
|
209 iConnName = val.AllocL(); |
|
210 } |
|
211 else if( !iRequestedAPIds.iFirstPreference ) |
|
212 { |
|
213 TBuf<20> query; |
|
214 TBuf<40> val; |
|
215 |
|
216 query.Format( _L("%s\\%s"), IAP, COMMDB_ID ); |
|
217 User::LeaveIfError( iConnection.GetIntSetting( query, iRequestedAPIds.iFirstPreference ) ); |
|
218 #ifndef __WINS__ |
|
219 CApAccessPointItem* ap = APItemFromIAPIdLC( iRequestedAPIds.iFirstPreference ); |
|
220 UpdateCurrentAPL( *ap, EFalse ); |
|
221 CleanupStack::PopAndDestroy(); // ap |
|
222 #endif |
|
223 query.Format(_L("%s\\%s"), IAP, COMMDB_NAME); |
|
224 User::LeaveIfError( iConnection.GetDesSetting( query, val ) ); |
|
225 |
|
226 iConnName = val.AllocL(); |
|
227 } |
|
228 else |
|
229 { |
|
230 #ifndef __WINS__ |
|
231 CApAccessPointItem* ap = APItemFromIAPIdLC( aIAPId ); |
|
232 UpdateCurrentAPL( *ap, EFalse ); |
|
233 CleanupStack::PopAndDestroy(); // ap |
|
234 |
|
235 #endif |
|
236 } |
|
237 |
|
238 StartConnectionObservingL(); |
|
239 } |
|
240 |
|
241 return connErr; |
|
242 } |
|
243 |
|
244 //-------------------------------------------------------------------------- |
|
245 //CInternetConnectionManager::ConnectWithoutCheckL( TUint32 aIAPId1 ) |
|
246 //-------------------------------------------------------------------------- |
|
247 TInt CInternetConnectionManager::ConnectWithoutCheckL( TUint32 /*aIAPId1*/, TUint32 /*aIAPId2*/ ) |
|
248 { |
|
249 User::Panic( KNullDesC, KErrNotSupported ); |
|
250 |
|
251 return KErrGeneral; |
|
252 } |
|
253 |
|
254 //-------------------------------------------------------------------------- |
|
255 //CInternetConnectionManager::DisplayConnErrorL |
|
256 //-------------------------------------------------------------------------- |
|
257 void CInternetConnectionManager::DisplayConnErrorL() |
|
258 { |
|
259 CLOG_ENTERFN("DisplayConnErrorL"); |
|
260 if ( iInternalError && !iSilentMode && iInternalError!= KErrCancel && IsConnectionAllowedL( EFalse ) ) |
|
261 { |
|
262 CLOG_WRITE("Some Error should be shown"); |
|
263 CLOG_WRITE_1("Error %d", iInternalError); |
|
264 //filtering out errors that are shown by the phone app |
|
265 if( iInternalError == KErrEtelCallAlreadyActive || |
|
266 iInternalError == KErrEtelBusyDetected ) |
|
267 { |
|
268 ShowErrorNoteL( iInternalError ); |
|
269 } |
|
270 else if ( !InIntArray( KNumsOfDontShowErrors, KADontShowErrors, iInternalError ) ) |
|
271 { |
|
272 CLOG_WRITE("Error is shown by ConnMan"); |
|
273 if ( !InIntArray( KNumsOfExcludeFromConverting , |
|
274 KAExcludeFromConverting, |
|
275 iInternalError ) |
|
276 && ( iInternalError == KErrGeneral || iInternalError == KErrCommsLineFail |
|
277 || KEtelExtErrIntervalLow < iInternalError && iInternalError < KEtelExtErrIntervalHigh |
|
278 || KGsmErrIntervalLow < iInternalError && iInternalError < KGsmErrIntervalHigh |
|
279 || KEtelCoreErrIntervalLow < iInternalError && iInternalError < KEtelCoreErrIntervalHigh |
|
280 ) ) |
|
281 { |
|
282 CLOG_WRITE("KErrExitModemError"); |
|
283 ShowErrorNoteL( KErrExitModemError ); |
|
284 } |
|
285 else |
|
286 { |
|
287 if (iInternalError == KErrNotFound ) |
|
288 { |
|
289 // Since -1 is an error from bottom layer with no more information |
|
290 // The good match using "Extended Error Handling" of UI spec would |
|
291 // be "connection not available". |
|
292 ShowErrorNoteL(NW_STAT_WPS_ERROR, CTextResolver::ECtxNoCtxNoSeparator); |
|
293 } |
|
294 else |
|
295 { |
|
296 ShowErrorNoteL( iInternalError ); |
|
297 } |
|
298 } |
|
299 } |
|
300 } |
|
301 else |
|
302 { |
|
303 if( !IsConnectionAllowedL( EFalse ) ) |
|
304 { |
|
305 CLOG_WRITE("Operation is not allowed in off-line mode"); |
|
306 ShowGlobalNoteL( EAknGlobalInformationNote, R_QTN_OFFLINE_NOT_POSSIBLE ); |
|
307 iInternalError = KErrGeneral; |
|
308 } |
|
309 } |
|
310 } |
|
311 |
|
312 |
|
313 //-------------------------------------------------------------------------- |
|
314 //CInternetConnectionManager::NewL |
|
315 //-------------------------------------------------------------------------- |
|
316 |
|
317 EXPORT_C CInternetConnectionManager* CInternetConnectionManager::NewL( TBool aSilentMode ) |
|
318 { |
|
319 CInternetConnectionManager* self = CInternetConnectionManager::NewLC( aSilentMode ); |
|
320 CleanupStack::Pop(); |
|
321 return self; |
|
322 } |
|
323 |
|
324 //-------------------------------------------------------------------------- |
|
325 //CInternetConnectionManager::NewL |
|
326 //-------------------------------------------------------------------------- |
|
327 |
|
328 EXPORT_C CInternetConnectionManager* CInternetConnectionManager::NewL( CCommsDatabase* aCommsDb, TBool aSilentMode ) |
|
329 { |
|
330 CInternetConnectionManager* self = CInternetConnectionManager::NewLC( aCommsDb, aSilentMode ); |
|
331 CleanupStack::Pop(); |
|
332 return self; |
|
333 } |
|
334 |
|
335 |
|
336 //-------------------------------------------------------------------------- |
|
337 //CInternetConnectionManager::NewLC |
|
338 //-------------------------------------------------------------------------- |
|
339 EXPORT_C CInternetConnectionManager* CInternetConnectionManager::NewLC( TBool aSilentMode ) |
|
340 { |
|
341 CInternetConnectionManager* self = new( ELeave )CInternetConnectionManager( aSilentMode ); |
|
342 CleanupStack::PushL( self ); |
|
343 self->ConstructL(); |
|
344 return self; |
|
345 } |
|
346 |
|
347 //-------------------------------------------------------------------------- |
|
348 //CInternetConnectionManager::NewLC |
|
349 //-------------------------------------------------------------------------- |
|
350 EXPORT_C CInternetConnectionManager* CInternetConnectionManager::NewLC( CCommsDatabase* aCommsDb, TBool aSilentMode ) |
|
351 { |
|
352 CInternetConnectionManager* self = new( ELeave )CInternetConnectionManager( aCommsDb, aSilentMode ); |
|
353 CleanupStack::PushL( self ); |
|
354 self->ConstructL(); |
|
355 return self; |
|
356 } |
|
357 |
|
358 //-------------------------------------------------------------------------- |
|
359 //CInternetConnectionManager::ConnectL |
|
360 //-------------------------------------------------------------------------- |
|
361 |
|
362 TInt CInternetConnectionManager::ConnectL |
|
363 ( |
|
364 TCommDbConnPref& /*aPref1*/, |
|
365 TCommDbConnPref& /*aPref2*/ |
|
366 ) |
|
367 { |
|
368 User::Panic( KNullDesC, KErrNotSupported ); |
|
369 |
|
370 return KErrGeneral; |
|
371 } |
|
372 |
|
373 //-------------------------------------------------------------------------- |
|
374 //CInternetConnectionManager::ConnectL |
|
375 //-------------------------------------------------------------------------- |
|
376 |
|
377 TInt CInternetConnectionManager::ConnectL |
|
378 ( |
|
379 TCommDbConnPref& aPref1 |
|
380 ) |
|
381 { |
|
382 if ( iAlreadyInUse ) |
|
383 { |
|
384 CLOG_WRITE( "Reentering happend, calling User::Leave!!!" ); |
|
385 User::Leave( KErrAlreadyExists ); |
|
386 } |
|
387 iAlreadyInUse = ETrue; |
|
388 iInternalError = KErrNone; |
|
389 iCalledFromProcessFinish = EFalse; |
|
390 TInt connErr( KErrNone ); |
|
391 |
|
392 CLOG_WRITE( "ConnMan: Setting overides" ); |
|
393 //Leave point |
|
394 TCommDbConnPref *overrides = new (ELeave) TCommDbConnPref; |
|
395 CleanupStack::PushL( overrides ); |
|
396 |
|
397 // there's no copy constructor thus |
|
398 // I need to make a copy of this object manually |
|
399 overrides->SetDialogPreference( aPref1.DialogPreference() ); |
|
400 // Because from 2.0 there is only browser who integrates |
|
401 // connection manager there's no need for prompt |
|
402 // browser always sets valid access point id. |
|
403 // __ASSERT_DEBUG( aPref1.IapId(), User::Panic( KNullDesC, KErrArgument ) ); // Temp for CDMA fix |
|
404 // set access point id in overrides |
|
405 overrides->SetIapId( aPref1.IapId() ); |
|
406 overrides->SetBearerSet( aPref1.BearerSet() ); |
|
407 |
|
408 TInt connAllowed( ETrue ); |
|
409 |
|
410 TInt err = |
|
411 iRepository->Get( KCoreAppUIsNetworkConnectionAllowed, connAllowed); |
|
412 |
|
413 CLOG_WRITE_1( "ConnMan connAllowed: %d", connAllowed ); |
|
414 if( !connAllowed && ( KErrNone == err ) ) |
|
415 { |
|
416 CLOG_WRITE( "ConnMan SetBearerSet: EApBearerTypeWLAN" ); |
|
417 overrides->SetBearerSet( EApBearerTypeWLAN ); |
|
418 } |
|
419 |
|
420 |
|
421 //TUint32 bearer = aPref1.BearerSet(); |
|
422 CLOG_WRITE( "ConnMan Overrides set" ); |
|
423 //>>>>>>>>>>> |
|
424 if ( !iSilentMode && !connErr ) |
|
425 { |
|
426 CLOG_WRITE( "ConnMan: Starting Wait dlg with name" ); |
|
427 HBufC* buf = NULL; |
|
428 if( aPref1.IapId() ) |
|
429 { |
|
430 buf = StringLoader::LoadL |
|
431 ( |
|
432 R_ICS_WAIT_CONNECTING, |
|
433 *APNameLC( aPref1.IapId() ) |
|
434 ); |
|
435 CleanupStack::PushL( buf ); |
|
436 } |
|
437 CLOG_WRITE( "Calling StartWaitDialogL" ); |
|
438 StartWaitDialogL( buf, EWaitGPRSIcon ); |
|
439 CLOG_WRITE( "StartWaitDialogL returned with no leave" ); |
|
440 if( aPref1.IapId() ) |
|
441 { |
|
442 CleanupStack::PopAndDestroy( 2 );//buf, HBuf* returned by APNameLC |
|
443 } |
|
444 } |
|
445 //>>>>>>>>>>> |
|
446 if ( !connErr ) |
|
447 { |
|
448 TBool alreadyCancelled = ( !iSilentMode && !iWaitDialog ); |
|
449 if ( alreadyCancelled ) |
|
450 { |
|
451 connErr = KErrCancel; |
|
452 } |
|
453 else |
|
454 { |
|
455 connErr = iConnection.Open( iServ, KAfInet ); |
|
456 CLOG_WRITE_1( "RConnection: %d", connErr ); |
|
457 if( connErr == KErrNone ) |
|
458 { |
|
459 // Always pass the IAP Id to RConnection even in silent mode |
|
460 connErr = iSyncConnector->Connect( overrides ); |
|
461 } |
|
462 if( connErr != KErrNone ) |
|
463 { |
|
464 CLOG_WRITE( "Closing all" ); |
|
465 iConnection.Close(); |
|
466 } |
|
467 } |
|
468 } |
|
469 if ( iWaitDialog ) |
|
470 { |
|
471 CLOG_WRITE( "Killing wait dialog..." ); |
|
472 iCalledFromProcessFinish = ETrue; |
|
473 iWaitDialog->ProcessFinishedL(); |
|
474 CLOG_WRITE( "ProgressFinished is called" ); |
|
475 } |
|
476 CleanupStack::PopAndDestroy();//overrides |
|
477 iInternalError = connErr; |
|
478 |
|
479 CLOG_WRITE_1( "ConnectL returned with %d", connErr ); |
|
480 iNewConnectionEstablished = ( connErr == KErrNone ); |
|
481 iAlreadyInUse = EFalse; |
|
482 return connErr; |
|
483 } |
|
484 |
|
485 |
|
486 //-------------------------------------------------------------------------- |
|
487 //CInternetConnectionManager::~CInternetConnectionManager |
|
488 //-------------------------------------------------------------------------- |
|
489 |
|
490 CInternetConnectionManager::~CInternetConnectionManager() |
|
491 { |
|
492 CLOG_WRITE("Destructor"); |
|
493 |
|
494 Disconnect(); |
|
495 |
|
496 delete iStageNotifier; |
|
497 |
|
498 iMobilePhone.Close(); |
|
499 iTelServer.Close(); |
|
500 |
|
501 delete iRepository; |
|
502 |
|
503 if( !iSilentMode ) |
|
504 { |
|
505 CCoeEnv::Static()->DeleteResourceFile( iResOffset ); |
|
506 } |
|
507 delete iVpnEngine; |
|
508 delete iApDataHandler; |
|
509 delete iApUtils; |
|
510 delete iNote; |
|
511 if ( iCommsDbOwned ) |
|
512 { |
|
513 delete iCommsDb; |
|
514 } |
|
515 |
|
516 if( iConnected ) |
|
517 { |
|
518 iConnection.Close(); |
|
519 } |
|
520 |
|
521 if( !iSilentMode ) |
|
522 // Temp fix for CDMA |
|
523 { |
|
524 delete iCurrentAP; |
|
525 } |
|
526 |
|
527 delete iVpnItem; |
|
528 |
|
529 // Temp fix for CDMA |
|
530 delete iConnName; |
|
531 delete iWaitDialog; |
|
532 delete iNoteDialog; |
|
533 delete iSyncConnector; |
|
534 iRFs.Close(); |
|
535 |
|
536 iServ.Close(); |
|
537 |
|
538 CLOG_CLOSE; |
|
539 } |
|
540 |
|
541 //-------------------------------------------------------------------------- |
|
542 //CInternetConnectionManager::CInternetConnectionManager |
|
543 //-------------------------------------------------------------------------- |
|
544 |
|
545 CInternetConnectionManager::CInternetConnectionManager( TBool aSilentMode ) |
|
546 : iSilentMode( aSilentMode ) |
|
547 ,iRequestedAPIds() |
|
548 { |
|
549 CLOG_CREATE; |
|
550 CLOG_NAME_1( _L("IntConnMan_%x"), this ); |
|
551 } |
|
552 |
|
553 //-------------------------------------------------------------------------- |
|
554 //CInternetConnectionManager::CInternetConnectionManager |
|
555 //-------------------------------------------------------------------------- |
|
556 CInternetConnectionManager::CInternetConnectionManager( CCommsDatabase* aCommsDb, TBool aSilentMode ): iCommsDb( aCommsDb ), iSilentMode( aSilentMode ) |
|
557 { |
|
558 CLOG_CREATE; |
|
559 CLOG_NAME_1( _L("IntConnMan_%x"), this ); |
|
560 } |
|
561 |
|
562 //-------------------------------------------------------------------------- |
|
563 //CInternetConnectionManager::ConstructL |
|
564 //-------------------------------------------------------------------------- |
|
565 void CInternetConnectionManager::ConstructL() |
|
566 { |
|
567 CLOG_ENTERFN( "ConstructL" ); |
|
568 } |
|
569 |
|
570 //-------------------------------------------------------------------------- |
|
571 //CInternetConnectionManager::CheckNetworkL |
|
572 //-------------------------------------------------------------------------- |
|
573 TBool CInternetConnectionManager::CheckNetworkL( TBool& aGPRSAvailable ) |
|
574 { |
|
575 aGPRSAvailable = ETrue; |
|
576 return ETrue; |
|
577 } |
|
578 |
|
579 //-------------------------------------------------------------------------- |
|
580 //CInternetConnectionManager::BearerTypeL |
|
581 //-------------------------------------------------------------------------- |
|
582 TApBearerType CInternetConnectionManager::BearerTypeL( TUint32 aIAPId ) |
|
583 { |
|
584 TApBearerType apbearerType = EApBearerTypeAllBearers; |
|
585 if( iSilentMode || !iRequestedAPIds.iFirstPreference ) |
|
586 // Temp fix for CDMA |
|
587 { |
|
588 return EApBearerTypeAllBearers; |
|
589 } |
|
590 |
|
591 #ifndef __WINS__ |
|
592 CApAccessPointItem* ap = APItemFromIAPIdLC( aIAPId ); |
|
593 TUint32 wapAPId = ap->WapUid(); |
|
594 CleanupStack::PopAndDestroy( ap ); // ap |
|
595 TRAPD(err, apbearerType = iApUtils->BearerTypeL( wapAPId )); |
|
596 if( err == KErrNone) |
|
597 { |
|
598 return(apbearerType); |
|
599 } |
|
600 else |
|
601 { |
|
602 return (EApBearerTypeAllBearers); |
|
603 } |
|
604 #else |
|
605 aIAPId = 0; |
|
606 return EApBearerTypeGPRS; |
|
607 #endif |
|
608 } |
|
609 |
|
610 //--------------------------------------------------------- |
|
611 // CInternetConnectionManager::ShowGeneralConnectionErrorL |
|
612 //--------------------------------------------------------- |
|
613 |
|
614 EXPORT_C void CInternetConnectionManager::ShowGeneralConnectionErrorL() |
|
615 { |
|
616 ShowErrorNoteL( KErrGeneralConnection ); |
|
617 } |
|
618 |
|
619 //--------------------------------------------------------- |
|
620 // CInternetConnectionManager::ShowErrorNoteL |
|
621 //--------------------------------------------------------- |
|
622 void CInternetConnectionManager::ShowErrorNoteL( |
|
623 TInt aErrorStat, |
|
624 CTextResolver::TErrorContext aContext ) |
|
625 { |
|
626 if ( !iSilentMode ) |
|
627 { |
|
628 CLOG_WRITE_1( "Showing Error: %d", aErrorStat ); |
|
629 CErrorUI* errorUI = CErrorUI::NewLC( ); |
|
630 if ( !errorUI->ShowGlobalErrorNoteL( aErrorStat, aContext) ) |
|
631 { |
|
632 errorUI->ShowGlobalErrorNoteL( KErrGeneralConnection, aContext); |
|
633 } |
|
634 CleanupStack::PopAndDestroy();//errorUI |
|
635 } |
|
636 } |
|
637 |
|
638 //--------------------------------------------------------- |
|
639 // CInternetConnectionManager::StopConnectionL |
|
640 //--------------------------------------------------------- |
|
641 EXPORT_C void CInternetConnectionManager::StopConnectionL() |
|
642 { |
|
643 CLOG_ENTERFN( "StopConnectionL()" ); |
|
644 |
|
645 StopConnectionObserving(); |
|
646 iConnection.Close(); |
|
647 // iServ.Close(); |
|
648 iConnected = EFalse; |
|
649 iEasyWlan = EFalse; |
|
650 |
|
651 if( !iSilentMode ) |
|
652 { |
|
653 delete iCurrentAP; |
|
654 } |
|
655 iCurrentAP = NULL; |
|
656 } |
|
657 |
|
658 //------------------------------------------------------------------------- |
|
659 // CInternetConnectionManager::NewConnectionEstablished() |
|
660 //------------------------------------------------------------------------- |
|
661 EXPORT_C TBool CInternetConnectionManager::NewConnectionEstablished( ) const |
|
662 { |
|
663 return iNewConnectionEstablished; |
|
664 } |
|
665 |
|
666 //--------------------------------------------------------------- |
|
667 //CInternetConnectionManager::ShowConfQueryNoteL |
|
668 //--------------------------------------------------------------- |
|
669 TInt CInternetConnectionManager::ShowConfQueryNoteL( TInt aTextResId ) |
|
670 { |
|
671 TInt retVal( EAknSoftkeyCancel ); |
|
672 if ( !iSilentMode ) |
|
673 { |
|
674 HBufC* buf = StringLoader::LoadLC( aTextResId ); |
|
675 CAknQueryDialog* dialog = CAknQueryDialog::NewL(); |
|
676 dialog->PrepareLC( R_CONNMAN_CONF_QUERY ); |
|
677 dialog->SetPromptL( buf->Des() ); |
|
678 retVal = dialog->RunLD(); |
|
679 CleanupStack::PopAndDestroy();//buf |
|
680 } |
|
681 return retVal; |
|
682 } |
|
683 |
|
684 //--------------------------------------------------------------- |
|
685 //CInternetConnectionManager::APNameLC |
|
686 //--------------------------------------------------------------- |
|
687 HBufC* CInternetConnectionManager::APNameLC( TUint32 aIAPId ) const |
|
688 { |
|
689 TBuf <KCommsDbSvrMaxFieldLength> apName; |
|
690 #ifndef __WINS__ |
|
691 TUint32 wapAPId = iApUtils->WapIdFromIapIdL( aIAPId ); |
|
692 |
|
693 iApUtils->NameL( wapAPId, apName ); |
|
694 #else |
|
695 aIAPId = 0; |
|
696 #endif |
|
697 return ( apName.AllocLC() ); |
|
698 } |
|
699 |
|
700 //--------------------------------------------------------------- |
|
701 //CInternetConnectionManager::DialogDismissedL |
|
702 //--------------------------------------------------------------- |
|
703 void CInternetConnectionManager::DialogDismissedL( TInt /*aButtonId*/ ) |
|
704 { |
|
705 if ( !iCalledFromProcessFinish ) |
|
706 { |
|
707 CLOG_WRITE( "Dialog Dismissed called" ); |
|
708 iSyncConnector->Cancel(); |
|
709 CLOG_WRITE( "Stopping connection" ); |
|
710 } |
|
711 } |
|
712 //--------------------------------------------------------------- |
|
713 //CInternetConnectionManager::ShowGlobalNoteL |
|
714 //--------------------------------------------------------------- |
|
715 void CInternetConnectionManager::ShowGlobalNoteL( TAknGlobalNoteType aNoteType, TInt aTextResId ) |
|
716 { |
|
717 if (!iSilentMode ) |
|
718 { |
|
719 HBufC* buf; |
|
720 buf = StringLoader::LoadLC( aTextResId ); |
|
721 iNote->ShowNoteL( aNoteType, buf->Des() ); |
|
722 CleanupStack::PopAndDestroy();//Cleanup the buf |
|
723 } |
|
724 } |
|
725 |
|
726 |
|
727 //--------------------------------------------------------------- |
|
728 //CInternetConnectionManager::ShowInformationNoteL |
|
729 //--------------------------------------------------------------- |
|
730 void CInternetConnectionManager::ShowInformationNoteL( TInt aTextResId ) |
|
731 { |
|
732 if (!iSilentMode ) |
|
733 { |
|
734 if ( iNoteDialog ) |
|
735 { |
|
736 delete iNoteDialog ; |
|
737 iNoteDialog = NULL; |
|
738 } |
|
739 iNoteDialog = new (ELeave) CAknNoteDialog |
|
740 ( REINTERPRET_CAST( CEikDialog**, &iNoteDialog ), |
|
741 CAknNoteDialog::EConfirmationTone,CAknNoteDialog::ELongTimeout ); |
|
742 HBufC* buf = StringLoader::LoadLC( aTextResId ); |
|
743 iNoteDialog->PrepareLC( R_CONNMAN_INFORMATION_NOTE ); |
|
744 iNoteDialog->SetTextL( buf->Des() ); |
|
745 iNoteDialog->RunLD(); |
|
746 CleanupStack::PopAndDestroy();//buf |
|
747 } |
|
748 } |
|
749 |
|
750 |
|
751 //------------------------------------------------------------------------ |
|
752 //CInternetConnectionManager::InIntArray |
|
753 //------------------------------------------------------------------------ |
|
754 TBool CInternetConnectionManager::InIntArray( TInt aUpperBound, const TInt* aArray, TInt aElement ) |
|
755 { |
|
756 TBool found( EFalse ); |
|
757 for (TInt i = 0; i< aUpperBound ; i++ ) |
|
758 { |
|
759 if ( aArray[i] == aElement ) |
|
760 { |
|
761 found = ETrue; |
|
762 break; |
|
763 } |
|
764 } |
|
765 return found; |
|
766 } |
|
767 |
|
768 //------------------------------------------------------------------- |
|
769 //CInternetConnectionManager::Connection |
|
770 //------------------------------------------------------------------- |
|
771 // |
|
772 EXPORT_C RConnection& CInternetConnectionManager::Connection() |
|
773 { |
|
774 return iConnection; |
|
775 } |
|
776 |
|
777 //------------------------------------------------------------------- |
|
778 //CInternetConnectionManager::ConnectionNameL |
|
779 //------------------------------------------------------------------- |
|
780 // |
|
781 EXPORT_C TName* CInternetConnectionManager::ConnectionNameL() |
|
782 { |
|
783 if( !iConnected ) |
|
784 { |
|
785 User::Leave( KErrGeneral ); |
|
786 } |
|
787 |
|
788 TName *name = new (ELeave) TName; |
|
789 CleanupStack::PushL( name ); |
|
790 |
|
791 User::LeaveIfError( iConnection.Name( *name ) ); |
|
792 |
|
793 CleanupStack::Pop( name ); |
|
794 |
|
795 return name; |
|
796 } |
|
797 |
|
798 //------------------------------------------------------------------- |
|
799 //CInternetConnectionManager::SocketServer |
|
800 //------------------------------------------------------------------- |
|
801 // |
|
802 EXPORT_C RSocketServ& CInternetConnectionManager::SocketServer() |
|
803 { |
|
804 return iServ; |
|
805 } |
|
806 |
|
807 //------------------------------------------------------------------- |
|
808 //CInternetConnectionManager::SetRequestedAPs |
|
809 //------------------------------------------------------------------- |
|
810 // |
|
811 EXPORT_C void CInternetConnectionManager::SetRequestedAPs( TIdPair aRequestedAPIds ) |
|
812 { |
|
813 iRequestedAPIds = aRequestedAPIds; |
|
814 iNoSecondPreference = EFalse; |
|
815 } |
|
816 |
|
817 |
|
818 //------------------------------------------------------------------- |
|
819 //CInternetConnectionManager::SetRequestedAP |
|
820 //------------------------------------------------------------------- |
|
821 // |
|
822 EXPORT_C void CInternetConnectionManager::SetRequestedAP( TUint32 aRequestedAPId, TBool /*aDefault*/ ) |
|
823 { |
|
824 iRequestedAPIds.iFirstPreference = aRequestedAPId; |
|
825 iNoSecondPreference = ETrue; |
|
826 } |
|
827 |
|
828 //------------------------------------------------------------------- |
|
829 //CInternetConnectionManager::RequestedAPValidityL |
|
830 //------------------------------------------------------------------- |
|
831 // |
|
832 EXPORT_C TAPValidity CInternetConnectionManager::RequestedAPValidityL() |
|
833 { |
|
834 return EBoth; |
|
835 } |
|
836 |
|
837 // --------------------------------------------------------- |
|
838 // CInternetConnectionManager::Connected |
|
839 // --------------------------------------------------------- |
|
840 // |
|
841 EXPORT_C TBool CInternetConnectionManager::Connected() |
|
842 { |
|
843 CLOG_WRITE_1( "Int::Connected: %d", iConnected ); |
|
844 return iConnected; |
|
845 } |
|
846 |
|
847 //------------------------------------------------------------------- |
|
848 //CInternetConnectionManager::CurrentAccessPoint |
|
849 //------------------------------------------------------------------- |
|
850 // |
|
851 EXPORT_C const CApAccessPointItem* |
|
852 CInternetConnectionManager::CurrentAccessPoint() const |
|
853 { |
|
854 User::Panic( KNullDesC, KErrNotSupported ); |
|
855 |
|
856 return NULL; |
|
857 } |
|
858 |
|
859 // --------------------------------------------------------- |
|
860 // CInternetConnectionManager::CurrentAPId |
|
861 // --------------------------------------------------------- |
|
862 // |
|
863 EXPORT_C TUint32 CInternetConnectionManager::CurrentAPId() const |
|
864 { |
|
865 if( !iSilentMode ) |
|
866 { |
|
867 if ( iCurrentAP ) |
|
868 { |
|
869 TUint32 ret( 0 ); |
|
870 TRAPD( err, ret = iApUtils->IapIdFromWapIdL( iCurrentAP->WapUid() ) ); |
|
871 ret = ( KErrNone != err ) ? KPrompt : ret; |
|
872 return ret; |
|
873 } |
|
874 else |
|
875 { |
|
876 return KPrompt; |
|
877 } |
|
878 } |
|
879 else |
|
880 // Temp fix for CDMA |
|
881 { |
|
882 return (TUint32)iCurrentAP; |
|
883 } |
|
884 } |
|
885 |
|
886 // --------------------------------------------------------- |
|
887 // CInternetConnectionManager::CurrentSessionSecure |
|
888 // --------------------------------------------------------- |
|
889 // |
|
890 EXPORT_C TBool CInternetConnectionManager::CurrentSessionSecure() const |
|
891 { |
|
892 User::Panic( KNullDesC, KErrNotSupported ); |
|
893 |
|
894 return EFalse; |
|
895 } |
|
896 |
|
897 // -------------------------------------------------------------- |
|
898 // CInternetConnectionManager::CurrentSessionConnectionOriented |
|
899 // -------------------------------------------------------------- |
|
900 // |
|
901 EXPORT_C TBool CInternetConnectionManager::CurrentSessionConnectionOriented() const |
|
902 { |
|
903 User::Panic( KNullDesC, KErrNotSupported ); |
|
904 |
|
905 return EFalse; |
|
906 } |
|
907 |
|
908 // --------------------------------------------------------- |
|
909 // CInternetConnectionManager::CurrentGatewayLC |
|
910 // --------------------------------------------------------- |
|
911 // |
|
912 EXPORT_C HBufC* CInternetConnectionManager::CurrentGatewayLC() const |
|
913 { |
|
914 User::Panic( KNullDesC, KErrNotSupported ); |
|
915 |
|
916 return NULL; |
|
917 } |
|
918 |
|
919 // --------------------------------------------------------- |
|
920 // CInternetConnectionManager::CurrentStartPageLC |
|
921 // --------------------------------------------------------- |
|
922 // |
|
923 EXPORT_C HBufC* CInternetConnectionManager::CurrentStartPageLC() const |
|
924 { |
|
925 User::Panic( KNullDesC, KErrNotSupported ); |
|
926 |
|
927 return NULL; |
|
928 } |
|
929 |
|
930 // --------------------------------------------------------- |
|
931 // CInternetConnectionManager::CurrentApNameLC |
|
932 // --------------------------------------------------------- |
|
933 // |
|
934 EXPORT_C HBufC* CInternetConnectionManager::CurrentApNameLC() const |
|
935 { |
|
936 if( iSilentMode ) |
|
937 // Temp fix for CDMA |
|
938 { |
|
939 return iConnName->AllocLC(); |
|
940 } |
|
941 |
|
942 #ifndef __WINS__ |
|
943 if( iCurrentAP ) |
|
944 { |
|
945 return APNameLC( iApUtils->IapIdFromWapIdL( iCurrentAP->WapUid() ) ); |
|
946 } |
|
947 else |
|
948 { |
|
949 User::Panic( KNullDesC, KErrGeneral ); |
|
950 |
|
951 // to avoid compiler warning |
|
952 return NULL; |
|
953 } |
|
954 #else |
|
955 return KNullDesC().AllocLC(); |
|
956 #endif |
|
957 } |
|
958 |
|
959 // -------------------------------------------------------------- |
|
960 // CInternetConnectionManager::CurrentConnectionSpeed |
|
961 // -------------------------------------------------------------- |
|
962 // |
|
963 EXPORT_C TApCallSpeed CInternetConnectionManager::CurrentConnectionSpeed() const |
|
964 { |
|
965 TApCallSpeed connectionSpeed( KSpeedAutobaud ); |
|
966 if ( iCurrentAP && !iSilentMode ) |
|
967 // Temp fix for CDMA |
|
968 { |
|
969 iCurrentAP->ReadUint( EApIspBearerSpeed, (TUint32&)connectionSpeed ); |
|
970 } |
|
971 |
|
972 return connectionSpeed; |
|
973 } |
|
974 |
|
975 // --------------------------------------------------------- |
|
976 // CInternetConnectionManager::CurrentBearerTypeL |
|
977 // --------------------------------------------------------- |
|
978 // |
|
979 |
|
980 EXPORT_C TApBearerType CInternetConnectionManager::CurrentBearerTypeL() const |
|
981 { |
|
982 #ifndef __WINS__ |
|
983 if ( iCurrentAP && !iSilentMode ) |
|
984 // Temp fix for CDMA |
|
985 { |
|
986 CLOG_WRITE_1("BT: %d", iCurrentAP->BearerTypeL() ); |
|
987 return iCurrentAP->BearerTypeL(); |
|
988 } |
|
989 |
|
990 CLOG_WRITE( "Unknown BT" ); |
|
991 return EApBearerTypeAll; |
|
992 #else |
|
993 return EApBearerTypeGPRS; |
|
994 #endif |
|
995 } |
|
996 |
|
997 // --------------------------------------------------------- |
|
998 // CInternetConnectionManager::Disconnect |
|
999 // --------------------------------------------------------- |
|
1000 // |
|
1001 EXPORT_C void CInternetConnectionManager::Disconnect() |
|
1002 { |
|
1003 TRAP_IGNORE( StopConnectionL() ); |
|
1004 } |
|
1005 |
|
1006 // --------------------------------------------------------- |
|
1007 // CInternetConnectionManager::SetApChangeObserver |
|
1008 // --------------------------------------------------------- |
|
1009 // |
|
1010 EXPORT_C void CInternetConnectionManager::SetApChangeObserver( MApChangeObserver& aObserver ) |
|
1011 { |
|
1012 __ASSERT_DEBUG ( iApObserver == NULL, User::Panic( KNullDesC, KErrInUse ) ); |
|
1013 iApObserver = &aObserver; |
|
1014 } |
|
1015 |
|
1016 // --------------------------------------------------------- |
|
1017 // CInternetConnectionManager::UnsetApChangeObserver |
|
1018 // --------------------------------------------------------- |
|
1019 // |
|
1020 EXPORT_C void CInternetConnectionManager::UnsetApChangeObserver() |
|
1021 { |
|
1022 iApObserver = 0; |
|
1023 } |
|
1024 |
|
1025 // --------------------------------------------------------- |
|
1026 // CInternetConnectionManager::StartConnectionL |
|
1027 // --------------------------------------------------------- |
|
1028 // |
|
1029 EXPORT_C TInt CInternetConnectionManager::StartConnectionL( TBool aDisableConnNeeded, TBool /*aIgnoreSecureAttribute*/ ) |
|
1030 { |
|
1031 CLOG_ENTERFN( "StartConnectionL" ); |
|
1032 CLOG_WRITE_1( "IAPid: [%d]", iRequestedAPIds.iFirstPreference ); |
|
1033 |
|
1034 TUint32 newIapId; |
|
1035 TBool doConnect( EFalse ); |
|
1036 TInt err( KErrNone ); |
|
1037 |
|
1038 InitializeL(); |
|
1039 |
|
1040 //Connect with Snap Id if the connection type is Destination Nw |
|
1041 |
|
1042 if (iConnectionType == EDestination) |
|
1043 { |
|
1044 err = ConnectWithSnapId(iRequestedSnapId); |
|
1045 return err; |
|
1046 } |
|
1047 else |
|
1048 { |
|
1049 |
|
1050 TApBearerType bearerType( EApBearerTypeAllBearers ); |
|
1051 |
|
1052 if( iRequestedAPIds.iFirstPreference ) |
|
1053 { |
|
1054 bearerType = BearerTypeL( iRequestedAPIds.iFirstPreference ); |
|
1055 } |
|
1056 |
|
1057 CLOG_WRITE_1("Bearer type: %d", bearerType ); |
|
1058 |
|
1059 /* Connecting to VPN tunnel on the same real IAP using which VPN configurations were made then |
|
1060 the existing connection would not be disconnected but a new VPN tunnel will be created on top of it. |
|
1061 so iConnected would be true which was making it to leave with only if(iConnected), it should not leave |
|
1062 incase of VPN tunnel so that VPN tunnel could be created further. To avoid leaving from this condition |
|
1063 incase of VPN connection added a new connection for checking if iConnected is true + its a non VPN connection |
|
1064 incase of VPN this condition will be ignored and following connectL function will be called to create a VPN connection.*/ |
|
1065 |
|
1066 if( iConnected && !iVpnItem) |
|
1067 { |
|
1068 CLOG_WRITE("Already connected"); |
|
1069 return KErrNone; |
|
1070 } |
|
1071 |
|
1072 |
|
1073 |
|
1074 if( iRequestedAPIds.iFirstPreference && CheckIfAlreadyConnected( newIapId ) ) |
|
1075 // there's connection with any of the requested AP point |
|
1076 // try to attach to the that |
|
1077 { |
|
1078 CLOG_WRITE("Already connected with this IAPId"); |
|
1079 err = ConnectL( newIapId ); |
|
1080 if( err != KErrNone && err != KErrCancel ) |
|
1081 // we couldn't attach but give me one more chance |
|
1082 { |
|
1083 CLOG_WRITE_1("Attach failed:%d", err); |
|
1084 doConnect = ETrue; |
|
1085 } |
|
1086 } |
|
1087 else |
|
1088 { |
|
1089 if( !IsConnectionAllowedL( ETrue ) ) |
|
1090 // In offline mode it's not possible to start connection |
|
1091 { |
|
1092 return KErrGeneral; |
|
1093 } |
|
1094 |
|
1095 |
|
1096 TBool nw3G = Check3GNetworkL(); |
|
1097 // In 3G network or if bearer type is WLAN |
|
1098 // we don't have to check if there is (HS)CSD connection |
|
1099 // opened in the phone |
|
1100 TBool isThere = nw3G || bearerType == EApBearerTypeWLAN ? EFalse : IsThereActiveHSCSDConnectionL(); |
|
1101 |
|
1102 if( !isThere ) |
|
1103 { |
|
1104 // In 3G network or if bearer type is WLAN |
|
1105 // we don't have to check if there is active voice |
|
1106 // call in the phone |
|
1107 isThere = nw3G || bearerType == EApBearerTypeWLAN ? EFalse : IsThereActiveVoiceCall(); |
|
1108 |
|
1109 if( !isThere ) |
|
1110 { |
|
1111 if ( !iSilentMode && !aDisableConnNeeded ) |
|
1112 { |
|
1113 if ( ShowConfQueryNoteL ( R_WML_CONF_CONN_NEED ) ) |
|
1114 { |
|
1115 if( IsConnectionAllowedL( ETrue ) ) |
|
1116 { |
|
1117 doConnect = ETrue; |
|
1118 } |
|
1119 else |
|
1120 { |
|
1121 err = KErrGeneral; |
|
1122 } |
|
1123 } |
|
1124 else |
|
1125 { |
|
1126 err = KErrCancel; |
|
1127 } |
|
1128 } |
|
1129 else |
|
1130 // we are in silent mode, conn query is not needed. |
|
1131 // in this case connection has to be started automatically. |
|
1132 { |
|
1133 doConnect = ETrue; |
|
1134 } |
|
1135 } |
|
1136 else |
|
1137 { |
|
1138 err = iInternalError = KErrEtelCallAlreadyActive; |
|
1139 DisplayConnErrorL(); |
|
1140 } |
|
1141 } |
|
1142 else |
|
1143 { |
|
1144 err = KErrGeneral; |
|
1145 ShowInformationNoteL( R_ICS_NOTE_CLOSE_CONNECTION ); |
|
1146 } |
|
1147 } |
|
1148 |
|
1149 if( !err ) |
|
1150 { |
|
1151 if( doConnect ) |
|
1152 { |
|
1153 TUint32 usedAp( iRequestedAPIds.iFirstPreference ); |
|
1154 |
|
1155 if( IsConnectionAllowedL( ETrue ) ) |
|
1156 { |
|
1157 err = ConnectL( usedAp ); |
|
1158 } |
|
1159 } |
|
1160 } |
|
1161 |
|
1162 if( err == KErrNone ) |
|
1163 { |
|
1164 CLOG_WRITE( "No error in connection" ); |
|
1165 #if !defined( __WINS__ ) |
|
1166 // it's not a critical problem if this flag |
|
1167 // cannot be updated. |
|
1168 TRAP_IGNORE( UpdateEasyWlanFlagL() ); |
|
1169 #endif |
|
1170 } |
|
1171 else if( err == KErrEtelCallNotActive ) |
|
1172 // this is a special case. User pressed end key |
|
1173 // while (HS)CSD connection was coming up. |
|
1174 { |
|
1175 err = KErrCancel; |
|
1176 } |
|
1177 else if( err != KErrCancel ) |
|
1178 // to make it compatible with old connman. |
|
1179 { |
|
1180 CLOG_WRITE_1( "Error: %d", err ); |
|
1181 err = KErrGeneral; |
|
1182 } |
|
1183 |
|
1184 return err; |
|
1185 } //if iConnection |
|
1186 } |
|
1187 |
|
1188 // --------------------------------------------------------- |
|
1189 // CInternetConnectionManager::CurrentAP |
|
1190 // --------------------------------------------------------- |
|
1191 // |
|
1192 EXPORT_C CApAccessPointItem* CInternetConnectionManager::CurrentAP() |
|
1193 { |
|
1194 if( iSilentMode ) |
|
1195 // Temp fix for CDMA |
|
1196 { |
|
1197 User::Panic( KNullDesC, KErrGeneral ); |
|
1198 } |
|
1199 CLOG_WRITE_1( "CurrentAP(): %d", (TUint32)iCurrentAP ); |
|
1200 return iCurrentAP; |
|
1201 } |
|
1202 |
|
1203 // --------------------------------------------------------- |
|
1204 // CInternetConnectionManager::UpdateCurrentAPL |
|
1205 // --------------------------------------------------------- |
|
1206 // |
|
1207 void CInternetConnectionManager::UpdateCurrentAPL( CApAccessPointItem& aBaseAP,TBool aOnlyWAPpart ) |
|
1208 { |
|
1209 if( iSilentMode ) |
|
1210 // Temp fix for CDMA |
|
1211 { |
|
1212 User::Panic( KNullDesC, KErrGeneral ); |
|
1213 } |
|
1214 |
|
1215 CLOG_WRITE( "CIntConnMan::UpdateCurrentAPL" ); |
|
1216 if ( !aOnlyWAPpart || !iCurrentAP ) |
|
1217 { |
|
1218 delete iCurrentAP; |
|
1219 iCurrentAP = NULL; |
|
1220 iCurrentAP = CApAccessPointItem::NewLC(); |
|
1221 CleanupStack::Pop();//Don't leave it on cleanup stack because it is a member |
|
1222 iCurrentAP->CopyFromL( aBaseAP ); |
|
1223 TUint32 wapId; |
|
1224 aBaseAP.ReadUint( EApWapAccessPointID, wapId ); |
|
1225 iCurrentAP->WriteUint( EApWapAccessPointID, wapId ); |
|
1226 } |
|
1227 else |
|
1228 { |
|
1229 TUint32 length( 0 ); |
|
1230 length = aBaseAP.ReadTextLengthL( EApWapGatewayAddress ); |
|
1231 HBufC* gw = HBufC::NewLC( length );//C:1 |
|
1232 TPtr addressPtr( gw->Des() ); |
|
1233 aBaseAP.ReadTextL( EApWapGatewayAddress, addressPtr ); |
|
1234 |
|
1235 const HBufC* sp = aBaseAP.ReadConstLongTextL( EApWapStartPage );//Not owned! |
|
1236 |
|
1237 length = aBaseAP.ReadTextLengthL( EApWapAccessPointName ); |
|
1238 HBufC* apn = HBufC::NewLC( length );//C:2 |
|
1239 TPtr apnPtr( apn->Des() ); |
|
1240 aBaseAP.ReadTextL( EApWapAccessPointName, apnPtr ); |
|
1241 |
|
1242 TBool sec; |
|
1243 aBaseAP.ReadBool( EApWapSecurity, sec ); |
|
1244 |
|
1245 TUint32 ct; |
|
1246 aBaseAP.ReadUint( EApWapWspOption, ct ); |
|
1247 |
|
1248 TUint32 wapUid; |
|
1249 aBaseAP.ReadUint( EApWapAccessPointID, wapUid ); |
|
1250 |
|
1251 TPtrC temp = ( const_cast<HBufC*>(sp) )->Des(); |
|
1252 iCurrentAP->WriteLongTextL( EApWapStartPage, temp ); |
|
1253 iCurrentAP->WriteTextL( EApWapGatewayAddress, gw->Des() ); |
|
1254 iCurrentAP->WriteTextL( EApWapAccessPointName, apn->Des() ); |
|
1255 iCurrentAP->WriteBool( EApWapSecurity, sec ); |
|
1256 iCurrentAP->WriteUint( EApWapWspOption, ct ); |
|
1257 iCurrentAP->WriteUint( EApWapAccessPointID, wapUid );//change the wapUid of the current one |
|
1258 CleanupStack::PopAndDestroy( 2 );//apn, gw |
|
1259 } |
|
1260 CLOG_WRITE( "CIntConnMan::UpdateCurrentAPL done" ); |
|
1261 } |
|
1262 |
|
1263 //------------------------------------------------------------------- |
|
1264 //CInternetConnectionManager::RequestedIdPair |
|
1265 //------------------------------------------------------------------- |
|
1266 // |
|
1267 TIdPair& CInternetConnectionManager::RequestedIdPair() |
|
1268 { |
|
1269 return iRequestedAPIds; |
|
1270 } |
|
1271 |
|
1272 //------------------------------------------------------------------- |
|
1273 //CInternetConnectionManager::NoSecondPreference |
|
1274 //------------------------------------------------------------------- |
|
1275 // |
|
1276 TBool CInternetConnectionManager::NoSecondPreference() const |
|
1277 { |
|
1278 return iNoSecondPreference; |
|
1279 } |
|
1280 |
|
1281 //------------------------------------------------------------------- |
|
1282 //CInternetConnectionManager::SetNoSecondPreference |
|
1283 //------------------------------------------------------------------- |
|
1284 // |
|
1285 void CInternetConnectionManager::SetNoSecondPreference( TBool aNoSecondPreference ) |
|
1286 { |
|
1287 iNoSecondPreference = aNoSecondPreference; |
|
1288 } |
|
1289 |
|
1290 //------------------------------------------------------------------- |
|
1291 //CInternetConnectionManager::SilentMode |
|
1292 //------------------------------------------------------------------- |
|
1293 // |
|
1294 TBool CInternetConnectionManager::SilentMode() const |
|
1295 { |
|
1296 return iSilentMode; |
|
1297 } |
|
1298 |
|
1299 //------------------------------------------------------------------- |
|
1300 //CInternetConnectionManager::ApUtils |
|
1301 //------------------------------------------------------------------- |
|
1302 // |
|
1303 CApUtils* CInternetConnectionManager::ApUtils() |
|
1304 { |
|
1305 return iApUtils; |
|
1306 } |
|
1307 |
|
1308 //------------------------------------------------------------------- |
|
1309 //CInternetConnectionManager::ApObserver |
|
1310 //------------------------------------------------------------------- |
|
1311 // |
|
1312 MApChangeObserver* CInternetConnectionManager::ApObserver() |
|
1313 { |
|
1314 return iApObserver; |
|
1315 } |
|
1316 |
|
1317 //------------------------------------------------------------------- |
|
1318 //CInternetConnectionManager::StartConnectionObservingL |
|
1319 //------------------------------------------------------------------- |
|
1320 // |
|
1321 void CInternetConnectionManager::StartConnectionObservingL() |
|
1322 { |
|
1323 CLOG_ENTERFN( "StartConnectionObservingL()" ); |
|
1324 |
|
1325 TName* name = ConnectionNameL(); |
|
1326 __ASSERT_DEBUG( name, User::Panic( KNullDesC, KErrCorrupt ) ); |
|
1327 CleanupStack::PushL( name ); |
|
1328 |
|
1329 iSatges[0] = KConnectionUninitialised; |
|
1330 iSatges[1] = KConnectionClosed; |
|
1331 iSatges[2] = KLinkLayerClosed; |
|
1332 |
|
1333 iStageNotifier->StartNotificationL( name,iSatges,KMaxStages,this, ETrue ); |
|
1334 |
|
1335 CleanupStack::PopAndDestroy( name ); |
|
1336 } |
|
1337 |
|
1338 //------------------------------------------------------------------- |
|
1339 //CInternetConnectionManager::StopConnectionObserving |
|
1340 //------------------------------------------------------------------- |
|
1341 // |
|
1342 void CInternetConnectionManager::StopConnectionObserving() |
|
1343 { |
|
1344 CLOG_ENTERFN( "StopConnectionObserving()" ); |
|
1345 if ( iStageNotifier ) |
|
1346 { |
|
1347 iStageNotifier->Cancel(); |
|
1348 } |
|
1349 } |
|
1350 |
|
1351 //------------------------------------------------------------------- |
|
1352 //CInternetConnectionManager::ConnectionStageAchievedL |
|
1353 //------------------------------------------------------------------- |
|
1354 // |
|
1355 void CInternetConnectionManager::ConnectionStageAchievedL(TInt /*aStage*/) |
|
1356 { |
|
1357 CLOG_ENTERFN( "ConnectionStageAchievedL()" ); |
|
1358 // CLOG_WRITE_1( "ConnectionStageAchievedL() Stage = %d ", aStage); |
|
1359 if(iConnected) |
|
1360 { |
|
1361 // this is a connection closed event |
|
1362 iConnection.Close(); |
|
1363 iConnected = EFalse; |
|
1364 |
|
1365 if( !iSilentMode ) |
|
1366 // Temp fix for CDMA |
|
1367 { |
|
1368 delete iCurrentAP; |
|
1369 } |
|
1370 iCurrentAP = NULL; |
|
1371 } |
|
1372 |
|
1373 } |
|
1374 |
|
1375 // --------------------------------------------------------- |
|
1376 // CInternetConnectionManager::APItemFromAPIdLC |
|
1377 // --------------------------------------------------------- |
|
1378 // |
|
1379 CApAccessPointItem* CInternetConnectionManager::APItemFromAPIdLC( TUint32 aAPId ) |
|
1380 { |
|
1381 CLOG_ENTERFN( "APItemFromAPIdLC" ); |
|
1382 CLOG_WRITE_1( "iapId: %d", aAPId ); |
|
1383 CApAccessPointItem* apItem = CApAccessPointItem::NewLC(); |
|
1384 |
|
1385 if( iVpnEngine->IsVpnApL( aAPId ) ) |
|
1386 { |
|
1387 delete iVpnItem; |
|
1388 iVpnItem = NULL; |
|
1389 |
|
1390 iVpnItem = CVpnApItem::NewLC(); |
|
1391 CleanupStack::Pop(); |
|
1392 |
|
1393 iVpnEngine->VpnDataL( aAPId, *iVpnItem ); |
|
1394 |
|
1395 // get real WAP id |
|
1396 iVpnItem->ReadUint( EApVpnRealWapID, aAPId ); |
|
1397 } |
|
1398 |
|
1399 TRAP_IGNORE(iApDataHandler->AccessPointDataL( aAPId, *apItem )); |
|
1400 |
|
1401 return apItem; |
|
1402 } |
|
1403 |
|
1404 //------------------------------------------------------------------- |
|
1405 //CInternetConnectionManager::APItemFromIAPIdLC |
|
1406 //------------------------------------------------------------------- |
|
1407 // |
|
1408 CApAccessPointItem* CInternetConnectionManager::APItemFromIAPIdLC( TUint32 aIAPId ) |
|
1409 { |
|
1410 CLOG_ENTERFN( "APItemFromIAPIdLC" ); |
|
1411 TUint32 wapAPId = ApUtils()->WapIdFromIapIdL( aIAPId ); |
|
1412 return APItemFromAPIdLC( wapAPId ); |
|
1413 } |
|
1414 |
|
1415 //------------------------------------------------------------------- |
|
1416 //CInternetConnectionManager::ApDataHandler |
|
1417 //------------------------------------------------------------------- |
|
1418 // |
|
1419 CApDataHandler* CInternetConnectionManager::ApDataHandler() |
|
1420 { |
|
1421 return iApDataHandler; |
|
1422 } |
|
1423 |
|
1424 //------------------------------------------------------------------------ |
|
1425 //CInternetConnectionManager::IsThereActiveCSDConnection |
|
1426 //------------------------------------------------------------------------ |
|
1427 EXPORT_C TBool CInternetConnectionManager::IsThereActiveHSCSDConnectionL() |
|
1428 { |
|
1429 return EFalse; |
|
1430 } |
|
1431 |
|
1432 //------------------------------------------------------------------------ |
|
1433 //CInternetConnectionManager::CheckIfAlreadyConnected |
|
1434 //------------------------------------------------------------------------ |
|
1435 TBool CInternetConnectionManager::CheckIfAlreadyConnected( TUint32& aNewIapId ) |
|
1436 { |
|
1437 CLOG_ENTERFN( "CheckIfAlreadyConnected" ); |
|
1438 |
|
1439 TBool retVal( EFalse ); |
|
1440 RSocketServ serv; |
|
1441 RConnection connection; |
|
1442 TUint count; |
|
1443 |
|
1444 if( serv.Connect() == KErrNone ) |
|
1445 { |
|
1446 if( connection.Open( serv, KAfInet ) == KErrNone ) |
|
1447 { |
|
1448 TUint32 reqId1( iRequestedAPIds.iFirstPreference ); |
|
1449 |
|
1450 if( connection.EnumerateConnections( count ) == KErrNone ) |
|
1451 { |
|
1452 TPckgBuf<TConnectionInfo> connInfo; |
|
1453 |
|
1454 CLOG_WRITE_1( "Conns: %d", count ); |
|
1455 |
|
1456 for( TUint i = 1; i <= count; ++i ) |
|
1457 { |
|
1458 connection.GetConnectionInfo( i, connInfo ); |
|
1459 |
|
1460 if( connInfo().iIapId == reqId1 ) |
|
1461 { |
|
1462 CLOG_WRITE( "Found request1(Int)" ); |
|
1463 aNewIapId = reqId1; |
|
1464 retVal = ETrue; |
|
1465 break; |
|
1466 } |
|
1467 } |
|
1468 } |
|
1469 |
|
1470 connection.Close(); |
|
1471 } |
|
1472 |
|
1473 serv.Close(); |
|
1474 } |
|
1475 |
|
1476 CLOG_WRITE_1( "CheckIfAlreadyConnected(Int): %d", retVal ); |
|
1477 return retVal; |
|
1478 } |
|
1479 |
|
1480 //------------------------------------------------------------------------ |
|
1481 //CInternetConnectionManager::Check3GNetworkL |
|
1482 //------------------------------------------------------------------------ |
|
1483 TBool CInternetConnectionManager::Check3GNetworkL() |
|
1484 { |
|
1485 // This method must not be called if 2G/3G distinction is not supported; |
|
1486 // the RMobilePhone-related classes are not open in that case. |
|
1487 TBool is3g( EFalse ); |
|
1488 #if !defined( __WINS__ ) |
|
1489 RMobilePhone::TMobilePhoneNetworkMode networkMode; |
|
1490 User::LeaveIfError( iMobilePhone.GetCurrentMode( networkMode ) ); |
|
1491 |
|
1492 CLOG_WRITE_1( "Network mode: %d", networkMode ); |
|
1493 |
|
1494 if( networkMode == RMobilePhone::ENetworkModeCdma2000 || |
|
1495 networkMode == RMobilePhone::ENetworkModeWcdma ) |
|
1496 { |
|
1497 is3g = ETrue; |
|
1498 } |
|
1499 #endif |
|
1500 return is3g; |
|
1501 } |
|
1502 |
|
1503 //------------------------------------------------------------------------ |
|
1504 //CInternetConnectionManager::IsThereActiveVoiceCall |
|
1505 //------------------------------------------------------------------------ |
|
1506 TBool CInternetConnectionManager::IsThereActiveVoiceCall() |
|
1507 { |
|
1508 return EFalse; |
|
1509 } |
|
1510 |
|
1511 //------------------------------------------------------------------------ |
|
1512 //CInternetConnectionManager::SetInternalError |
|
1513 //------------------------------------------------------------------------ |
|
1514 void CInternetConnectionManager::SetInternalError( TInt aInternalError ) |
|
1515 { |
|
1516 iInternalError = aInternalError; |
|
1517 } |
|
1518 |
|
1519 //------------------------------------------------------------------------ |
|
1520 //CInternetConnectionManager::OfflineModeChanged |
|
1521 //------------------------------------------------------------------------ |
|
1522 void CInternetConnectionManager::OfflineModeChanged( TBool /*aAllowed*/ ) |
|
1523 { |
|
1524 // This function is not used anymore |
|
1525 } |
|
1526 |
|
1527 //------------------------------------------------------------------------ |
|
1528 //CInternetConnectionManager::CheckForWLAN |
|
1529 //------------------------------------------------------------------------ |
|
1530 TBool CInternetConnectionManager::CheckForWLAN() |
|
1531 { |
|
1532 TBool IsWLANSupported(EFalse); |
|
1533 |
|
1534 TRAPD(err, FeatureManager::InitializeLibL()); |
|
1535 |
|
1536 if(err == KErrNone && FeatureManager::FeatureSupported( KFeatureIdProtocolWlan )) |
|
1537 IsWLANSupported = ETrue; |
|
1538 |
|
1539 FeatureManager::UnInitializeLib(); |
|
1540 return IsWLANSupported; |
|
1541 } |
|
1542 |
|
1543 //------------------------------------------------------------------------ |
|
1544 //CInternetConnectionManager::IsConnectionAllowedL |
|
1545 //------------------------------------------------------------------------ |
|
1546 TBool CInternetConnectionManager::IsConnectionAllowedL( TBool aDisplayError ) |
|
1547 { |
|
1548 CLOG_ENTERFN("IsConnectionAllowedL"); |
|
1549 CLOG_WRITE_1("Disp: %d", aDisplayError ); |
|
1550 |
|
1551 if( iRequestedAPIds.iFirstPreference ) |
|
1552 { |
|
1553 if( BearerTypeL( iRequestedAPIds.iFirstPreference ) == EApBearerTypeWLAN ) |
|
1554 // WLAN is enabled in off-line mode, too. |
|
1555 { |
|
1556 return ETrue; |
|
1557 } |
|
1558 } |
|
1559 else |
|
1560 { |
|
1561 // Always ask - enable connection because of WLAN |
|
1562 TBool IsWLANSupported(ETrue); |
|
1563 |
|
1564 #if !defined( __WINS__ ) |
|
1565 |
|
1566 TInt OfflineModeConnAllowed( ETrue ); |
|
1567 |
|
1568 iRepository->Get( KCoreAppUIsNetworkConnectionAllowed, OfflineModeConnAllowed); |
|
1569 |
|
1570 //Check whether WLAN is supported in offline mode |
|
1571 if( !OfflineModeConnAllowed ) |
|
1572 { |
|
1573 |
|
1574 IsWLANSupported = CheckForWLAN(); |
|
1575 |
|
1576 if(!IsWLANSupported && aDisplayError) |
|
1577 DisplayConnErrorL(); |
|
1578 } |
|
1579 #endif |
|
1580 return IsWLANSupported; |
|
1581 } |
|
1582 |
|
1583 TInt connAllowed( ETrue ); |
|
1584 |
|
1585 iRepository->Get( KCoreAppUIsNetworkConnectionAllowed, connAllowed); |
|
1586 |
|
1587 if( !connAllowed && aDisplayError ) |
|
1588 { |
|
1589 DisplayConnErrorL(); |
|
1590 } |
|
1591 |
|
1592 return connAllowed; |
|
1593 } |
|
1594 |
|
1595 //------------------------------------------------------------------------ |
|
1596 //CInternetConnectionManager::ChangeIapL |
|
1597 //------------------------------------------------------------------------ |
|
1598 EXPORT_C void CInternetConnectionManager::ChangeIapL( |
|
1599 TConManChangeConn& aChangeConn, |
|
1600 TUint32& aNewIap ) |
|
1601 { |
|
1602 CLOG_ENTERFN("ChangeIapL"); |
|
1603 |
|
1604 CLOG_WRITE_2( "aNewAp: [%d], old: [%d]", aNewIap, iRequestedAPIds.iFirstPreference ); |
|
1605 |
|
1606 aChangeConn = EConManDoNothing; |
|
1607 |
|
1608 if( !DoChangeIapL( aNewIap ) ) |
|
1609 { |
|
1610 CLOG_WRITE("Do nothing1"); |
|
1611 return; // Do nothing |
|
1612 } |
|
1613 |
|
1614 if( iRequestedAPIds.iFirstPreference == aNewIap && !iEasyWlan ) |
|
1615 // Do nothing if the the selected AP is the same as we |
|
1616 // already have, but it's not EasyWlan. |
|
1617 // In case of EasyWlan we always disconnects |
|
1618 { |
|
1619 CLOG_WRITE("Do nothing2"); |
|
1620 return; // Do nothing |
|
1621 } |
|
1622 else |
|
1623 { |
|
1624 TRAPD( err, CheckVPNL(aNewIap,aChangeConn) ); |
|
1625 CLOG_WRITE_2( "CheckVPNL - err: [%d], aChangeConn: [%d]", err, aChangeConn ); |
|
1626 |
|
1627 if( err ) |
|
1628 { |
|
1629 aChangeConn = EConManCloseAndStart; |
|
1630 } |
|
1631 } |
|
1632 } |
|
1633 |
|
1634 //------------------------------------------------------------------------ |
|
1635 //CInternetConnectionManager::ShowConnectionChangedDlg |
|
1636 //------------------------------------------------------------------------ |
|
1637 EXPORT_C void CInternetConnectionManager::ShowConnectionChangedDlg() |
|
1638 { |
|
1639 TRAP_IGNORE( DoShowConnectionChangedDlgL() ); |
|
1640 } |
|
1641 |
|
1642 //------------------------------------------------------------------------ |
|
1643 //CInternetConnectionManager::AskIap |
|
1644 //------------------------------------------------------------------------ |
|
1645 EXPORT_C TInt CInternetConnectionManager::AskIap( TUint32& aNewIap ) |
|
1646 { |
|
1647 CLOG_ENTERFN("AskIap"); |
|
1648 TInt retVal( KErrNone ); |
|
1649 RGenConAgentDialogServer dlgSv; |
|
1650 |
|
1651 retVal = dlgSv.Connect(); |
|
1652 if ( retVal == KErrNone ) |
|
1653 { |
|
1654 TConnectionPrefs prefs; |
|
1655 prefs.iRank = 1; |
|
1656 prefs.iDirection = ECommDbConnectionDirectionOutgoing; |
|
1657 prefs.iBearerSet = ECommDbBearerCSD | ECommDbBearerWcdma | ECommDbBearerVirtual | ECommDbBearerWLAN; |
|
1658 |
|
1659 TRequestStatus status; |
|
1660 dlgSv.IapConnection( aNewIap, prefs, status ); |
|
1661 User::WaitForRequest( status ); |
|
1662 retVal = status.Int(); |
|
1663 } |
|
1664 |
|
1665 dlgSv.Close(); |
|
1666 |
|
1667 return retVal; |
|
1668 } |
|
1669 |
|
1670 //------------------------------------------------------------------- |
|
1671 //CInternetConnectionManager::SetConnectionType |
|
1672 //------------------------------------------------------------------- |
|
1673 // |
|
1674 EXPORT_C void CInternetConnectionManager::SetConnectionType( TCmSettingSelectionMode aConnectionType ) |
|
1675 { |
|
1676 CLOG_ENTERFN("CInternetConnectionManager::SetConnectionType"); |
|
1677 CLOG_WRITE_1( "CInternetConnectionManager::SetConnectionType - %d", aConnectionType ); |
|
1678 iConnectionType = aConnectionType; |
|
1679 } |
|
1680 |
|
1681 //------------------------------------------------------------------- |
|
1682 //CInternetConnectionManager::SetRequestedSnap |
|
1683 //------------------------------------------------------------------- |
|
1684 // |
|
1685 EXPORT_C void CInternetConnectionManager::SetRequestedSnap (TUint32 aRequestedSnapId) |
|
1686 { |
|
1687 CLOG_ENTERFN("CInternetConnectionManager::SetRequestedSnap"); |
|
1688 iRequestedSnapId = aRequestedSnapId; |
|
1689 } |
|
1690 //------------------------------------------------------------------------ |
|
1691 //CInternetConnectionManager::DoChangeIapL |
|
1692 //------------------------------------------------------------------------ |
|
1693 TBool CInternetConnectionManager::DoChangeIapL( TUint32& aNewAp ) |
|
1694 { |
|
1695 CLOG_ENTERFN("DoChangeIapL"); |
|
1696 |
|
1697 |
|
1698 TBool returnValue; |
|
1699 TUint32 elementID; |
|
1700 |
|
1701 TConnectionPrefs prefs; |
|
1702 prefs.iRank = 1; |
|
1703 prefs.iDirection = ECommDbConnectionDirectionOutgoing; |
|
1704 prefs.iBearerSet = ECommDbBearerCSD | ECommDbBearerWcdma | ECommDbBearerWLAN |ECommDbBearerVirtual; |
|
1705 |
|
1706 TRequestStatus status; |
|
1707 TUint32 dummy( 0 ); |
|
1708 |
|
1709 RCmManagerExt cmManagerExt; |
|
1710 cmManagerExt.OpenL(); |
|
1711 CleanupClosePushL( cmManagerExt ); |
|
1712 |
|
1713 RCmDestinationExt cmDestExt; |
|
1714 RCmConnectionMethodExt cmConnMethodExt; |
|
1715 |
|
1716 // Getting elementID in both Edestination and ConnectionMethod cases as new NW APIs require elementID as 1 of its parameter. |
|
1717 if ( EDestination == iConnectionType ) |
|
1718 { |
|
1719 cmDestExt = cmManagerExt.DestinationL( iRequestedSnapId ); |
|
1720 elementID = cmDestExt.ElementId(); |
|
1721 cmDestExt.Close(); |
|
1722 } |
|
1723 else |
|
1724 { |
|
1725 cmConnMethodExt = cmManagerExt.ConnectionMethodL( iRequestedAPIds.iFirstPreference ); |
|
1726 CleanupClosePushL( cmConnMethodExt ); |
|
1727 elementID = cmConnMethodExt.GetIntAttributeL( ECmElementID ); |
|
1728 CleanupStack::PopAndDestroy(); //cmConnMethodExt |
|
1729 } |
|
1730 |
|
1731 RGenConAgentDialogServer dlgSv; |
|
1732 User::LeaveIfError( dlgSv.Connect() ); |
|
1733 CleanupClosePushL( dlgSv ); |
|
1734 //Changed NW API which will take elementID of existing IAP and return elementID of selected IAP after selecting new connection from the list displayed |
|
1735 dlgSv.AccessPointConnection( dummy, dummy, elementID, prefs.iBearerSet, status ); |
|
1736 User::WaitForRequest( status ); |
|
1737 |
|
1738 if(KErrNone == status.Int()) |
|
1739 { |
|
1740 |
|
1741 TMDBElementId tableId = elementID & KCDMaskShowRecordType; |
|
1742 TUint32 destId; |
|
1743 const TInt ID( 0 ); |
|
1744 |
|
1745 /*If tableid is KCDTIdNetworkRecord then the result of ( elementID & KCDMaskShowRecordId ) >> 8 will be SnapId otherwise its IAP |
|
1746 This is dependent on User Selection, while change connection user gets a list of SNAPs available for changing connection, |
|
1747 if user go into the options of a particular SNAP and selects a IAP |
|
1748 within that SNAP then the below condition will fall in else part and connection type/mode will change to EConnectionMethod*/ |
|
1749 |
|
1750 if ( KCDTIdNetworkRecord == tableId ) |
|
1751 { |
|
1752 destId = ( elementID & KCDMaskShowRecordId ) >> 8; |
|
1753 SetRequestedSnap( destId ); // if SnapId recovered then setting snapid for creating new Connection further |
|
1754 |
|
1755 cmDestExt = cmManagerExt.DestinationL( destId ); |
|
1756 CleanupClosePushL( cmDestExt ); |
|
1757 |
|
1758 cmConnMethodExt = cmDestExt.ConnectionMethodL( ID ); |
|
1759 |
|
1760 CleanupClosePushL( cmConnMethodExt ); |
|
1761 aNewAp = cmConnMethodExt.GetIntAttributeL( ECmIapId ); |
|
1762 CleanupStack::PopAndDestroy();//cmConnMethodExt |
|
1763 CleanupStack::PopAndDestroy();//cmDestExt |
|
1764 |
|
1765 } |
|
1766 else |
|
1767 { |
|
1768 aNewAp = ( elementID & KCDMaskShowRecordId ) >> 8; |
|
1769 /* if Iap recovered then now connection type/mode changed to EConnectionMethod because in this case |
|
1770 user has selected a IAP instead of SNAP.*/ |
|
1771 SetConnectionType( EConnectionMethod ); |
|
1772 } |
|
1773 returnValue = ETrue; |
|
1774 } |
|
1775 else |
|
1776 { |
|
1777 dlgSv.CancelAccessPointConnection(); |
|
1778 returnValue = EFalse; |
|
1779 } |
|
1780 |
|
1781 CLOG_WRITE_1( "New IAP: [%d]", aNewAp ); |
|
1782 CLOG_WRITE_1( "retVal: %d", returnValue ); |
|
1783 |
|
1784 CleanupStack::PopAndDestroy();//dlgSv |
|
1785 CleanupStack::PopAndDestroy();//cmManagerExt |
|
1786 return returnValue; |
|
1787 } |
|
1788 |
|
1789 //------------------------------------------------------------------------ |
|
1790 //CInternetConnectionManager::CheckVPN |
|
1791 //------------------------------------------------------------------------ |
|
1792 void CInternetConnectionManager::CheckVPNL( TUint32 aNewIap, |
|
1793 TConManChangeConn& aChangeConn ) |
|
1794 { |
|
1795 CLOG_ENTERFN( "CheckVPNL" ); |
|
1796 |
|
1797 TInt wap( 0 ); |
|
1798 wap = ApUtils()->WapIdFromIapIdL( aNewIap ); |
|
1799 if( iVpnEngine->IsVpnApL( wap ) ) |
|
1800 { |
|
1801 delete iVpnItem; |
|
1802 iVpnItem = NULL; |
|
1803 |
|
1804 iVpnItem = CVpnApItem::NewLC(); |
|
1805 CleanupStack::Pop(); |
|
1806 |
|
1807 iVpnEngine->VpnDataL( aNewIap, *iVpnItem ); |
|
1808 |
|
1809 // Fix for the TSW error JSIN-738BLA for making VPN work on changing connection. |
|
1810 // get real IAP id |
|
1811 iVpnItem->ReadUint( EApVpnRealIapID, aNewIap ); |
|
1812 if( iRequestedAPIds.iFirstPreference == aNewIap ) |
|
1813 { |
|
1814 aChangeConn = EConManStartAgain; |
|
1815 } |
|
1816 else |
|
1817 { |
|
1818 aChangeConn = EConManCloseAndStart; |
|
1819 } |
|
1820 } |
|
1821 else |
|
1822 { |
|
1823 aChangeConn = EConManCloseAndStart; |
|
1824 } |
|
1825 } |
|
1826 |
|
1827 //------------------------------------------------------------------------ |
|
1828 //CInternetConnectionManager::UpdateEasyWlanFlagL |
|
1829 //------------------------------------------------------------------------ |
|
1830 void CInternetConnectionManager::UpdateEasyWlanFlagL() |
|
1831 { |
|
1832 CLOG_ENTERFN( "UpdateEasyWlanFlagL" ); |
|
1833 |
|
1834 iEasyWlan = EFalse; |
|
1835 |
|
1836 if( iSilentMode ) |
|
1837 // This is always CDMA |
|
1838 { |
|
1839 return; |
|
1840 } |
|
1841 |
|
1842 __ASSERT_DEBUG( iCommsDb, User::Panic( KNullDesC, KErrNone ) ); |
|
1843 |
|
1844 TUint32 serviceId; |
|
1845 |
|
1846 CLOG_WRITE( "Getting servideId" ); |
|
1847 User::LeaveIfError( iCurrentAP->ReadUint( EApIapServiceId, serviceId ) ); |
|
1848 |
|
1849 CCommsDbTableView* wLanServiceTable = NULL; |
|
1850 |
|
1851 CLOG_WRITE( "Opening view" ); |
|
1852 wLanServiceTable = iCommsDb->OpenViewMatchingUintLC( |
|
1853 TPtrC( WLAN_SERVICE ), |
|
1854 TPtrC( WLAN_SERVICE_ID ), |
|
1855 serviceId ); |
|
1856 |
|
1857 CLOG_WRITE_1( "ServiceId: %d", serviceId ); |
|
1858 |
|
1859 TInt errorCode = wLanServiceTable->GotoFirstRecord(); |
|
1860 |
|
1861 CLOG_WRITE_1( "GotoFirstRecord returned %d", errorCode ); |
|
1862 TWlanSsid sSID; |
|
1863 |
|
1864 if ( errorCode == KErrNone ) |
|
1865 { |
|
1866 wLanServiceTable->ReadTextL( TPtrC( WLAN_SSID ), sSID ); |
|
1867 CLOG_WRITE8_1( "SSID: [%S]", &sSID ); |
|
1868 // this is Easy WLan if string is empty. |
|
1869 iEasyWlan = sSID.Length() == 0; |
|
1870 CLOG_WRITE_1( "iEasyWlan: %d", iEasyWlan ); |
|
1871 } |
|
1872 |
|
1873 CleanupStack::PopAndDestroy(); // wLanServiceTable |
|
1874 } |
|
1875 |
|
1876 //------------------------------------------------------------------------ |
|
1877 //CInternetConnectionManager::DoShowConnectionChangedDlgL |
|
1878 //------------------------------------------------------------------------ |
|
1879 void CInternetConnectionManager::DoShowConnectionChangedDlgL() |
|
1880 { |
|
1881 CConnectionUiUtilities* connUiUtils = CConnectionUiUtilities::NewL(); |
|
1882 CleanupStack::PushL( connUiUtils ); |
|
1883 |
|
1884 connUiUtils->ShowConnectionChangedNoteL( iRequestedAPIds.iFirstPreference ); |
|
1885 |
|
1886 CleanupStack::PopAndDestroy( connUiUtils ); |
|
1887 } |
|
1888 |
|
1889 //------------------------------------------------------------------------ |
|
1890 //CInternetConnectionManager::InitializeL |
|
1891 //------------------------------------------------------------------------ |
|
1892 void CInternetConnectionManager::InitializeL() |
|
1893 { |
|
1894 CLOG_ENTERFN( "InitializeL" ); |
|
1895 if( iInitialized ) |
|
1896 { |
|
1897 return; |
|
1898 } |
|
1899 |
|
1900 //Constructing commsdb |
|
1901 if ( !iCommsDb ) |
|
1902 { |
|
1903 iCommsDb = CCommsDatabase::NewL( EDatabaseTypeIAP ); |
|
1904 iCommsDbOwned = ETrue; |
|
1905 } |
|
1906 |
|
1907 if( !iNote ) |
|
1908 { |
|
1909 iNote = CAknGlobalNote::NewL( ); |
|
1910 iNote->SetPriority( CActive::EPriorityHigh ); |
|
1911 } |
|
1912 |
|
1913 if( !iRFs.Handle() ) |
|
1914 { |
|
1915 User::LeaveIfError( iRFs.Connect() ); |
|
1916 } |
|
1917 |
|
1918 if( !iSilentMode && !iResOffset ) |
|
1919 { |
|
1920 TFileName fileName; |
|
1921 TParse parse; |
|
1922 |
|
1923 Dll::FileName (fileName); |
|
1924 parse.Set(KConnectionResourceFile, &fileName, NULL); |
|
1925 fileName = parse.FullName(); |
|
1926 BaflUtils::NearestLanguageFile(CCoeEnv::Static()->FsSession(), fileName); |
|
1927 if ( !BaflUtils::FileExists( CCoeEnv::Static()->FsSession(), fileName ) ) |
|
1928 { |
|
1929 // Use the Z drive one |
|
1930 fileName.Format( KConnectionResourceFileFormatter, &KDC_RESOURCE_FILES_DIR ); |
|
1931 BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(),fileName ); |
|
1932 } |
|
1933 iResOffset = CCoeEnv::Static()->AddResourceFileL( fileName ); |
|
1934 } |
|
1935 |
|
1936 if( !iApUtils ) |
|
1937 { |
|
1938 iApUtils = CApUtils::NewLC( *iCommsDb ); |
|
1939 CleanupStack::Pop(); |
|
1940 } |
|
1941 |
|
1942 if( !iApDataHandler ) |
|
1943 { |
|
1944 iApDataHandler = CApDataHandler::NewLC( *iCommsDb ); |
|
1945 CleanupStack::Pop(); |
|
1946 } |
|
1947 |
|
1948 if( !iVpnEngine ) |
|
1949 { |
|
1950 iVpnEngine = CVpnApEngine::NewLC( iCommsDb ); |
|
1951 CleanupStack::Pop(); |
|
1952 } |
|
1953 |
|
1954 if( !iSyncConnector ) |
|
1955 { |
|
1956 iSyncConnector = CActiveConnectorSyncWrapper::NewL( iConnection ); |
|
1957 CLOG_ATTACH( iSyncConnector, this ); |
|
1958 } |
|
1959 |
|
1960 if( !iRepository ) |
|
1961 { |
|
1962 iRepository = CRepository::NewL( KCRUidCoreApplicationUIs ); |
|
1963 } |
|
1964 |
|
1965 if( !iTelServer.Handle() ) |
|
1966 { |
|
1967 // this initialization needed for identifying 3G networks |
|
1968 // |
|
1969 User::LeaveIfError( iTelServer.Connect() ); |
|
1970 User::LeaveIfError( iTelServer.LoadPhoneModule( KMmTsyModuleName ) ); |
|
1971 |
|
1972 TInt numPhones; |
|
1973 User::LeaveIfError( iTelServer.EnumeratePhones( numPhones ) ); |
|
1974 if( numPhones <= 0 ) |
|
1975 { |
|
1976 // Huh??? |
|
1977 User::Leave( KErrCorrupt ); |
|
1978 } |
|
1979 |
|
1980 RTelServer::TPhoneInfo phoneInfo; |
|
1981 User::LeaveIfError( iTelServer.GetPhoneInfo( 0, phoneInfo ) ); |
|
1982 User::LeaveIfError( iMobilePhone.Open( iTelServer, phoneInfo.iName ) ); |
|
1983 User::LeaveIfError( iMobilePhone.Initialise() ); |
|
1984 } |
|
1985 |
|
1986 if( !iStageNotifier ) |
|
1987 { |
|
1988 iStageNotifier = CConnectionStageNotifierWCB::NewL(); |
|
1989 } |
|
1990 |
|
1991 if( !iServ.Handle() ) |
|
1992 { |
|
1993 User::LeaveIfError( iServ.Connect() ); |
|
1994 } |
|
1995 |
|
1996 CLOG_WRITE( "Fully initialized" ); |
|
1997 iInitialized = ETrue; |
|
1998 } |
|
1999 |
|
2000 //------------------------------------------------------------------------ |
|
2001 //CInternetConnectionManager::ConnectWithSnapId |
|
2002 //------------------------------------------------------------------------ |
|
2003 TInt CInternetConnectionManager::ConnectWithSnapId(TUint32 aRequestedSnapId) |
|
2004 { |
|
2005 |
|
2006 CLOG_WRITE_1( "CInternetConnectionManager::ConnectWithSnapId - %d", aRequestedSnapId ); |
|
2007 |
|
2008 iInternalError = KErrNone; |
|
2009 iNewConnectionEstablished = EFalse; |
|
2010 TInt connErr( KErrNone ); |
|
2011 |
|
2012 connErr = ConnectSnapWithoutCheckL( aRequestedSnapId ); |
|
2013 |
|
2014 DisplayConnErrorL(); |
|
2015 #ifndef __WINS__ |
|
2016 if( KErrNone == connErr ) |
|
2017 { |
|
2018 TUint32 iIapID; |
|
2019 TBuf<20> query; |
|
2020 query.Format( _L("%s\\%s"), IAP, COMMDB_ID ); |
|
2021 if( iConnection.GetIntSetting( query, iIapID ) == KErrNone ) |
|
2022 { |
|
2023 CLOG_WRITE_1( "ConnectWithSnapId::AccessPoint - %d", iIapID ); |
|
2024 CApAccessPointItem* ap = APItemFromIAPIdLC( iIapID ); |
|
2025 UpdateCurrentAPL( *ap, EFalse ); |
|
2026 CleanupStack::PopAndDestroy(); // ap |
|
2027 } |
|
2028 } |
|
2029 |
|
2030 #endif |
|
2031 |
|
2032 return connErr; |
|
2033 |
|
2034 } |
|
2035 |
|
2036 //------------------------------------------------------------------------ |
|
2037 //CInternetConnectionManager::ConnectSnapWithoutCheckL |
|
2038 //------------------------------------------------------------------------ |
|
2039 |
|
2040 |
|
2041 TInt CInternetConnectionManager::ConnectSnapWithoutCheckL(TUint32 aRequestedSnapId) |
|
2042 { |
|
2043 CLOG_ENTERFN( "ConnectSnapWithoutCheckL" ); |
|
2044 |
|
2045 iInternalError = KErrNone; |
|
2046 TInt connErr; |
|
2047 //Do the connection |
|
2048 TConnSnapPref pref; |
|
2049 |
|
2050 pref.SetSnap(aRequestedSnapId); |
|
2051 |
|
2052 connErr = ConnectSnapL( pref ); |
|
2053 |
|
2054 if( connErr == KErrNone ) |
|
2055 { |
|
2056 iConnected = ETrue; |
|
2057 |
|
2058 // Enable connection cloning |
|
2059 _LIT_SECURITY_POLICY_C2(KProcPolicy1, ECapabilityNetworkServices, ECapabilityNetworkControl); |
|
2060 |
|
2061 TSecurityPolicyBuf secPolBuf; |
|
2062 secPolBuf().Set(KProcPolicy1().Package()); |
|
2063 |
|
2064 iConnection.Control(KCOLConnection, KCoEnableCloneOpen, secPolBuf); |
|
2065 |
|
2066 StartConnectionObservingL(); |
|
2067 } |
|
2068 |
|
2069 return connErr; |
|
2070 } |
|
2071 |
|
2072 //------------------------------------------------------------------------ |
|
2073 //CInternetConnectionManager::ConnectSnapL |
|
2074 //------------------------------------------------------------------------ |
|
2075 |
|
2076 TInt CInternetConnectionManager::ConnectSnapL |
|
2077 ( |
|
2078 TConnSnapPref& aPref1 |
|
2079 ) |
|
2080 { |
|
2081 if ( iAlreadyInUse ) |
|
2082 { |
|
2083 CLOG_WRITE( "Reentering happend, calling User::Leave!!!" ); |
|
2084 User::Leave( KErrAlreadyExists ); |
|
2085 } |
|
2086 iAlreadyInUse = ETrue; |
|
2087 iInternalError = KErrNone; |
|
2088 TInt connErr( KErrNone ); |
|
2089 |
|
2090 CLOG_WRITE( "ConnMan: Setting overides" ); |
|
2091 //Leave point |
|
2092 TConnSnapPref *overrides = new (ELeave) TConnSnapPref; |
|
2093 CleanupStack::PushL( overrides ); |
|
2094 |
|
2095 // set access snap id in overrides |
|
2096 overrides->SetSnap( aPref1.Snap() ); |
|
2097 |
|
2098 CLOG_WRITE( "ConnMan Overrides set" ); |
|
2099 |
|
2100 if ( !connErr ) |
|
2101 { |
|
2102 connErr = iConnection.Open( iServ, KAfInet ); |
|
2103 CLOG_WRITE_1( "RConnection: %d", connErr ); |
|
2104 if( connErr == KErrNone ) |
|
2105 { |
|
2106 //connect with snap id |
|
2107 connErr = iSyncConnector->ConnectSnap( overrides ); |
|
2108 } |
|
2109 if( connErr != KErrNone ) |
|
2110 { |
|
2111 CLOG_WRITE( "Closing all" ); |
|
2112 iConnection.Close(); |
|
2113 } |
|
2114 } |
|
2115 |
|
2116 CleanupStack::PopAndDestroy();//overrides |
|
2117 iInternalError = connErr; |
|
2118 |
|
2119 CLOG_WRITE_1( "ConnectSnapL returned with %d", connErr ); |
|
2120 iNewConnectionEstablished = ( connErr == KErrNone ); |
|
2121 iAlreadyInUse = EFalse; |
|
2122 return connErr; |
|
2123 } |
|
2124 |
|
2125 //--------------------------------------------------------------- |
|
2126 //CInternetConnectionManager::StartWaitDialogL |
|
2127 //--------------------------------------------------------------- |
|
2128 void CInternetConnectionManager::StartWaitDialogL( HBufC* aLabel, TWaitIconType aType ) |
|
2129 { |
|
2130 delete iWaitDialog; |
|
2131 |
|
2132 iWaitDialog = NULL; |
|
2133 iWaitDialog = new ( ELeave )CAknWaitDialog( REINTERPRET_CAST(CEikDialog**,&iWaitDialog), ETrue ); |
|
2134 |
|
2135 switch( aType ) |
|
2136 { |
|
2137 case EWaitDataIcon: |
|
2138 iWaitDialog->PrepareLC( R_CONNMAN_WAIT_NOTE_CSD ); |
|
2139 break; |
|
2140 case EWaitGPRSIcon: |
|
2141 iWaitDialog->PrepareLC( R_CONNMAN_WAIT_NOTE_GPRS ); |
|
2142 break; |
|
2143 case EWaitNoIcon: |
|
2144 default: |
|
2145 iWaitDialog->PrepareLC( R_CONNMAN_WAIT_NOTE ); |
|
2146 } |
|
2147 |
|
2148 iWaitDialog->SetCallback( this ); |
|
2149 if( aLabel ) |
|
2150 { |
|
2151 iWaitDialog->SetTextL( aLabel->Des() ); |
|
2152 } |
|
2153 iWaitDialog->RunLD(); |
|
2154 } |
|
2155 |
|
2156 // End of File |