|
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: Receives and stores NAT/FW Traversal settings internally. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32base.h> |
|
21 #include <CWPAdapter.h> |
|
22 #include <CWPCharacteristic.h> |
|
23 #include <CWPParameter.h> |
|
24 #include <wpnatfwtraversaladapter.rsg> |
|
25 #include <WPAdapterUtil.h> // Adapter utils |
|
26 #include <utf.h> // Unicode conversion |
|
27 #include <cmmanagerext.h> |
|
28 #include <cmdestinationext.h> |
|
29 #include <cmconnectionmethoddef.h> |
|
30 #include "natfwdomainspecificitem.h" |
|
31 #include "natfwiapspecificitem.h" |
|
32 #include "natfwtraversaladapter.h" |
|
33 #include "wpnatfwitem.h" |
|
34 #include "wpnatfwdebug.h" |
|
35 #include "natfwdefaults.h" |
|
36 #include "stunserveritem.h" |
|
37 #include "turnserveritem.h" |
|
38 |
|
39 // Central Repository keys for NAT-FW Traversal settings |
|
40 #include <unsafprotocolscrkeys.h> |
|
41 #include "centralrepository.h" |
|
42 |
|
43 // LOCAL CONSTANTS |
|
44 // Application related constants |
|
45 _LIT( KNATFWTraversalAdapterName, "WPNATFWTraversalAdapter"); |
|
46 _LIT( KNATFWAppID, "w902E" ); // OMA CP AC document for NATFW. |
|
47 _LIT8( KNATFWAppID8, "w902E" ); |
|
48 // Network (domain) specific settings. |
|
49 _LIT( KNetwork, "NW" ); |
|
50 _LIT( KAdditionalStun, "ADDITIONALSTUN" ); |
|
51 _LIT( KStunsrvaddr, "STUNSRVADDR" ); |
|
52 _LIT( KStunsrvport, "STUNSRVPORT" ); |
|
53 _LIT( KNatRefreshTcp, "NATREFRESHTCP" ); |
|
54 _LIT( KNatRefreshUdp, "NATREFRESHUDP" ); |
|
55 _LIT( KCrlfRefresh, "CRLFREFRESH" ); |
|
56 // Access point specific settings. |
|
57 _LIT( KNatIap, "NATIAP" ); |
|
58 _LIT( KToNapId, "TONAPID" ); |
|
59 _LIT( KRefreshTcp, "REFRESHTCP" ); |
|
60 _LIT( KRefreshUdp, "REFRESHUDP" ); |
|
61 _LIT( KStunRetransmit, "STUNRETRANSMIT" ); |
|
62 |
|
63 // Network (domain) specific settings. |
|
64 _LIT( KStunSharedSecret, "SHAREDSECRET" ); |
|
65 _LIT( KPortPoolStart, "SPRANGE" ); |
|
66 _LIT( KPortPoolEnd, "EPRANGE" ); |
|
67 // ICE specific settings. |
|
68 _LIT( KIce, "ICE" ); |
|
69 _LIT( KNatUtilities, "NATUTILITIES" ); |
|
70 _LIT( KHostPref, "HOSTPREF" ); |
|
71 _LIT( KServerReflexivePref, "SERVERREFPREF" ); |
|
72 _LIT( KRelayPref, "RELAYPREF" ); |
|
73 _LIT( KPeerReflexivePref, "PEERREFPREF" ); |
|
74 _LIT( KIPv4Pref, "IPV4PREF" ); |
|
75 _LIT( KIPv6Pref, "IPV6PREF" ); |
|
76 _LIT( KVPNPref, "VPNPREF" ); |
|
77 _LIT( KUDPPref, "UDPPREF" ); |
|
78 _LIT( KTCPPref, "TCPPREF" ); |
|
79 _LIT( KTCPActivePref, "TCPACTIVEPREF" ); |
|
80 _LIT( KTCPPassivePref, "TCPPASSIVEPREF" ); |
|
81 _LIT( KTCPSimultaneousOpenPref, "TCPSIMULTPREF" ); |
|
82 // TURN specific settings. |
|
83 _LIT( KTurnServer, "TURNSERVER" ); |
|
84 _LIT( KTurnSrvAddr, "TURNSRVADDR" ); |
|
85 _LIT( KTurnSrvPort, "TURNSRVPORT" ); |
|
86 |
|
87 // ================= MEMBER FUNCTIONS ====================== |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CNATFWTraversalAdapter::CNATFWTraversalAdapter |
|
91 // |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 CNATFWTraversalAdapter::CNATFWTraversalAdapter() : CWPAdapter() |
|
95 { |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // CNATFWTraversalAdapter::ConstructL |
|
100 // |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 void CNATFWTraversalAdapter::ConstructL() |
|
104 { |
|
105 DBG_PRINT( "CNATFWTraversalAdapter::ConstructL - begin" ); |
|
106 // read default title and name from resources. |
|
107 TFileName fileName; |
|
108 Dll::FileName( fileName ); |
|
109 iDefaultName = WPAdapterUtil::ReadHBufCL( fileName, |
|
110 KNATFWTraversalAdapterName, |
|
111 R_QTN_SM_DEFAULT_NAME_NATFW ); |
|
112 iTitle = WPAdapterUtil::ReadHBufCL( fileName, |
|
113 KNATFWTraversalAdapterName, |
|
114 R_QTN_SM_HEAD_NATFW ); |
|
115 |
|
116 iCharacteristicNw = EFalse; |
|
117 iCharacteristicIce = EFalse; |
|
118 iCharacteristicTurn = EFalse; |
|
119 iCharacteristicNatIap = EFalse; |
|
120 iCharacteristicTurnServer = EFalse; |
|
121 iCharacteristicAdditionalStun = EFalse; |
|
122 |
|
123 DBG_PRINT( "CNATFWTraversalAdapter::ConstructL - end" ); |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // CNATFWTraversalAdapter::NewL |
|
128 // Static constructor. |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 CNATFWTraversalAdapter* CNATFWTraversalAdapter::NewL() |
|
132 { |
|
133 CNATFWTraversalAdapter* self = new ( ELeave ) CNATFWTraversalAdapter; |
|
134 CleanupStack::PushL( self ); |
|
135 self->ConstructL(); |
|
136 CleanupStack::Pop( self ); |
|
137 return self; |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------------------------- |
|
141 // CNATFWTraversalAdapter::~CNATFWTraversalAdapter |
|
142 // |
|
143 // --------------------------------------------------------------------------- |
|
144 // |
|
145 CNATFWTraversalAdapter::~CNATFWTraversalAdapter() |
|
146 { |
|
147 DBG_PRINT( "CNATFWTraversalAdapter::~CNATFWTraversalAdapter - begin" ); |
|
148 delete iDefaultName; |
|
149 delete iTitle; |
|
150 iDatas.ResetAndDestroy(); |
|
151 iDatas.Close(); |
|
152 DBG_PRINT( "CNATFWTraversalAdapter::~CNATFWTraversalAdapter - end" ); |
|
153 } |
|
154 |
|
155 // --------------------------------------------------------------------------- |
|
156 // CNATFWTraversalAdapter::ContextExtension |
|
157 // |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 TInt CNATFWTraversalAdapter::ContextExtension( |
|
161 MWPContextExtension*& aExtension ) |
|
162 { |
|
163 aExtension = this; |
|
164 return KErrNone; |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // CNATFWTraversalAdapter::VisitLinkL |
|
169 // |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 void CNATFWTraversalAdapter::VisitLinkL( CWPCharacteristic& aLink ) |
|
173 { |
|
174 DBG_PRINT( "CNATFWTraversalAdapter::VisitLinkL - begin" ); |
|
175 if ( ( KWPNapDef == aLink.Type() ) && iCurrentIapItem |
|
176 && !iCurrentIapItem->NapDef() ) |
|
177 { |
|
178 iCurrentIapItem->SetNapDef( &aLink ); |
|
179 } |
|
180 DBG_PRINT( "CNATFWTraversalAdapter::VisitLinkL - end" ); |
|
181 } |
|
182 |
|
183 // --------------------------------------------------------------------------- |
|
184 // CNATFWTraversalAdapter::SaveDataL |
|
185 // |
|
186 // --------------------------------------------------------------------------- |
|
187 // |
|
188 const TDesC8& CNATFWTraversalAdapter::SaveDataL( TInt aIndex ) const |
|
189 { |
|
190 return iDatas[aIndex]->SaveData(); |
|
191 } |
|
192 |
|
193 // --------------------------------------------------------------------------- |
|
194 // CNATFWTraversalAdapter::DeleteL |
|
195 // |
|
196 // --------------------------------------------------------------------------- |
|
197 // |
|
198 void CNATFWTraversalAdapter::DeleteL( const TDesC8& aSaveData ) |
|
199 { |
|
200 DBG_PRINT( "CNATFWTraversalAdapter::DeleteL - begin" ); |
|
201 // Central Repository for NAT-FW Traversal settings. |
|
202 CRepository* rep = CRepository::NewLC( KCRUidUNSAFProtocols ); |
|
203 TInt step( 0 ); |
|
204 |
|
205 // Delete all keys that are stored. |
|
206 while ( step < aSaveData.Length() ) |
|
207 { |
|
208 TUint32 key = DesToTUint( aSaveData.Mid( step, KMaxCharsInTUint32 ) ); |
|
209 key &= KUNSAFProtocolsTableMask; |
|
210 TUint32 errorKey; |
|
211 rep->Delete( key, KUNSAFProtocolsTableMask, errorKey ); |
|
212 step += KMaxCharsInTUint32; |
|
213 } |
|
214 |
|
215 CleanupStack::PopAndDestroy( rep ); |
|
216 DBG_PRINT( "CNATFWTraversalAdapter::DeleteL - end" ); |
|
217 } |
|
218 |
|
219 // --------------------------------------------------------------------------- |
|
220 // CNATFWTraversalAdapter::Uid |
|
221 // |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 TUint32 CNATFWTraversalAdapter::Uid() const |
|
225 { |
|
226 return iDtor_ID_Key.iUid; |
|
227 } |
|
228 |
|
229 // --------------------------------------------------------------------------- |
|
230 // CNATFWTraversalAdapter::DetailsL |
|
231 // |
|
232 // --------------------------------------------------------------------------- |
|
233 // |
|
234 TInt CNATFWTraversalAdapter::DetailsL( |
|
235 TInt /*aItem*/, MWPPairVisitor& /*aVisitor */ ) |
|
236 { |
|
237 return KErrNotSupported; |
|
238 } |
|
239 |
|
240 // --------------------------------------------------------------------------- |
|
241 // CNATFWTraversalAdapter::ItemCount |
|
242 // |
|
243 // --------------------------------------------------------------------------- |
|
244 // |
|
245 TInt CNATFWTraversalAdapter::ItemCount() const |
|
246 { |
|
247 return iDatas.Count(); |
|
248 } |
|
249 |
|
250 // --------------------------------------------------------------------------- |
|
251 // CNATFWTraversalAdapter::SummaryTitle |
|
252 // |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 const TDesC16& CNATFWTraversalAdapter::SummaryTitle( TInt /*aIndex*/ ) const |
|
256 { |
|
257 return *iTitle; |
|
258 } |
|
259 |
|
260 // --------------------------------------------------------------------------- |
|
261 // CNATFWTraversalAdapter::SummaryText |
|
262 // |
|
263 // --------------------------------------------------------------------------- |
|
264 // |
|
265 const TDesC16& CNATFWTraversalAdapter::SummaryText( TInt aIndex ) const |
|
266 { |
|
267 // If there is no value for NAME parameter the default value is set here. |
|
268 if ( 0 == iDatas[aIndex]->Name().Length() ) |
|
269 { |
|
270 TRAP_IGNORE( iDatas[aIndex]->SetNameL( iDefaultName->Des() ) ); |
|
271 } |
|
272 return iDatas[aIndex]->Name(); |
|
273 } |
|
274 |
|
275 // --------------------------------------------------------------------------- |
|
276 // CNATFWTraversalAdapter::SaveL |
|
277 // |
|
278 // --------------------------------------------------------------------------- |
|
279 // |
|
280 void CNATFWTraversalAdapter::SaveL( TInt aIndex ) |
|
281 { |
|
282 DBG_PRINT( "CNATFWTraversalAdapter::SaveL - begin" ); |
|
283 CWPNATFWItem* cNATFWItem = iDatas[aIndex]; |
|
284 const TInt iapItemCount( iDatas[aIndex]->IAPItems().Count() ); |
|
285 for ( TInt counter = 0; counter < iapItemCount; counter++ ) |
|
286 { |
|
287 // Set access point ID to current IAP item (access point is always |
|
288 // stored before NAT/FW settings). |
|
289 CNATFWIAPSpecificItem* cIapItem = iDatas[aIndex]->IAPItems()[counter]; |
|
290 if ( cIapItem->NapDef() ) |
|
291 { |
|
292 // Get WAP ID. |
|
293 TPckgBuf<TUint32> uid; |
|
294 uid.Copy( cIapItem->NapDef()->Data( 0 ) ); |
|
295 |
|
296 TUint32 wapId( uid() ); |
|
297 // Get corresponding IAP ID. |
|
298 TUint32 iapId = IapIdFromWapIdL( wapId ); |
|
299 cIapItem->SetIAPId( iapId ); |
|
300 }// if |
|
301 cIapItem = NULL; |
|
302 } |
|
303 cNATFWItem->StoreL(); |
|
304 cNATFWItem = NULL; |
|
305 DBG_PRINT( "CNATFWTraversalAdapter::SaveL - end" ); |
|
306 } |
|
307 |
|
308 // --------------------------------------------------------------------------- |
|
309 // CNATFWTraversalAdapter::CanSetAsDefault |
|
310 // |
|
311 // --------------------------------------------------------------------------- |
|
312 // |
|
313 TBool CNATFWTraversalAdapter::CanSetAsDefault( TInt /*aIndex*/ ) const |
|
314 { |
|
315 // NATFW profile cannot be set as default via OMA CP. |
|
316 return EFalse; |
|
317 } |
|
318 |
|
319 // --------------------------------------------------------------------------- |
|
320 // CNATFWTraversalAdapter::SetAsDefaultL |
|
321 // |
|
322 // --------------------------------------------------------------------------- |
|
323 // |
|
324 void CNATFWTraversalAdapter::SetAsDefaultL( TInt /*aIndex*/ ) |
|
325 { |
|
326 // NATFW profile cannot be set as default via OMA CP. |
|
327 } |
|
328 |
|
329 // --------------------------------------------------------------------------- |
|
330 // CNATFWTraversalAdapter::VisitL |
|
331 // |
|
332 // --------------------------------------------------------------------------- |
|
333 // |
|
334 void CNATFWTraversalAdapter::VisitL( CWPCharacteristic& aCharacteristic ) |
|
335 { |
|
336 DBG_PRINT( "CNATFWTraversalAdapter::VisitL( characteristic ) - begin" ); |
|
337 |
|
338 switch( aCharacteristic.Type() ) |
|
339 { |
|
340 // Core NATFW settings. |
|
341 case KWPApplication: |
|
342 { |
|
343 |
|
344 iCurrentNATFWItem = CWPNATFWItem::NewL(); |
|
345 aCharacteristic.AcceptL( *this ); |
|
346 |
|
347 // If NATFW settings, append the item into array. |
|
348 if ( KNATFWAppID() == iAppID ) |
|
349 { |
|
350 User::LeaveIfError( iDatas.Append( iCurrentNATFWItem ) ); |
|
351 } |
|
352 else // Else the settings are no longer of type NATFW. |
|
353 { |
|
354 delete iCurrentNATFWItem; |
|
355 iCurrentNATFWItem = NULL; |
|
356 iCharacteristicNw = EFalse; |
|
357 iCharacteristicIce = EFalse; |
|
358 iCharacteristicTurn = EFalse; |
|
359 iCharacteristicNatIap = EFalse; |
|
360 iCharacteristicTurnServer = EFalse; |
|
361 iCharacteristicAdditionalStun = EFalse; |
|
362 } |
|
363 break; |
|
364 } |
|
365 |
|
366 case KWPNamedCharacteristic: |
|
367 { |
|
368 // Domain specific settings. |
|
369 if ( aCharacteristic.Name().Compare( KNetwork() ) == 0 ) |
|
370 { |
|
371 iCurrentDomainItem = CNATFWDomainSpecificItem::NewL(); |
|
372 iCharacteristicNw = ETrue; |
|
373 iCurrentDomainItem->SetDefaultValuesL(); |
|
374 aCharacteristic.AcceptL( *this ); |
|
375 // Ownership transfer: |
|
376 iCurrentNATFWItem->AddDomainSpecificL( iCurrentDomainItem ); |
|
377 } |
|
378 // IAP specific settings. |
|
379 else if ( aCharacteristic.Name().Compare( KNatIap() ) == 0 ) |
|
380 { |
|
381 iCurrentIapItem = CNATFWIAPSpecificItem::NewL(); |
|
382 iCharacteristicNatIap = ETrue; |
|
383 |
|
384 // Set defaults for IAP specific item. |
|
385 iCurrentIapItem->SetSTUNRetransmitTimer( |
|
386 KDefaultSTUNRetransmitTimer ); |
|
387 // Default values for UDP and TCP refresh intervals are set in |
|
388 // NATFWItem if there are no values for either Domain or IAP |
|
389 // specific items. |
|
390 iCurrentIapItem->SetIntervalUDP( KNotSet ); |
|
391 iCurrentIapItem->SetIntervalTCP( KNotSet ); |
|
392 aCharacteristic.AcceptL( *this ); |
|
393 // Ownership transfer: |
|
394 iCurrentNATFWItem->AddIAPSpecificL( iCurrentIapItem ); |
|
395 } |
|
396 |
|
397 // ICE specific settings. |
|
398 else if ( 0 == aCharacteristic.Name().Compare( KIce() ) ) |
|
399 { |
|
400 if ( !iCurrentDomainItem ) |
|
401 { |
|
402 break; |
|
403 } |
|
404 else |
|
405 { |
|
406 iCharacteristicIce = ETrue; |
|
407 aCharacteristic.AcceptL( *this ); |
|
408 } |
|
409 } |
|
410 // TURNSERVER specific settings. |
|
411 else if ( 0 == aCharacteristic.Name().Compare( KTurnServer() ) ) |
|
412 { |
|
413 if ( !iCurrentDomainItem ) |
|
414 { |
|
415 break; |
|
416 } |
|
417 else |
|
418 { |
|
419 iCurrentTurnServer = CWPTurnServerItem::NewL(); |
|
420 iCharacteristicTurnServer = ETrue; |
|
421 aCharacteristic.AcceptL( *this ); |
|
422 // Ownership transfer: |
|
423 iCurrentDomainItem->AddTurnServerItemL( |
|
424 iCurrentTurnServer ); |
|
425 } |
|
426 } |
|
427 // ADDITIONALSTUN specific settings. |
|
428 else if ( 0 == aCharacteristic.Name().Compare( |
|
429 KAdditionalStun() ) ) |
|
430 { |
|
431 if ( !iCurrentDomainItem ) |
|
432 { |
|
433 break; |
|
434 } |
|
435 else |
|
436 { |
|
437 iCurrentStunServer = CWPStunServerItem::NewL(); |
|
438 iCharacteristicAdditionalStun = ETrue; |
|
439 aCharacteristic.AcceptL( *this ); |
|
440 // Ownership transfer: |
|
441 iCurrentDomainItem->AddStunServerItemL( |
|
442 iCurrentStunServer ); |
|
443 } |
|
444 } |
|
445 break; |
|
446 } |
|
447 default: |
|
448 break; |
|
449 } |
|
450 DBG_PRINT( "CNATFWTraversalAdapter::VisitL( characteristic ) - end" ); |
|
451 } |
|
452 |
|
453 // --------------------------------------------------------------------------- |
|
454 // CNATFWTraversalAdapter::VisitL |
|
455 // |
|
456 // --------------------------------------------------------------------------- |
|
457 // |
|
458 void CNATFWTraversalAdapter::VisitL( CWPParameter& aParameter ) |
|
459 { |
|
460 DBG_PRINT( "CNATFWTraversalAdapter::VisitL( parameter ) - begin" ); |
|
461 |
|
462 // tmpValue holds the value converted from Unicode to UTF8. |
|
463 HBufC8* tmpValue = HBufC8::NewLC( aParameter.Value().Length() ); // CS:1 |
|
464 TPtr8 ptrTmpValue( tmpValue->Des() ); |
|
465 CnvUtfConverter::ConvertFromUnicodeToUtf8( ptrTmpValue, |
|
466 aParameter.Value() ); |
|
467 |
|
468 switch( aParameter.ID() ) |
|
469 { |
|
470 case EWPParameterAppID: |
|
471 { |
|
472 iAppID.Set( aParameter.Value() ); |
|
473 break; |
|
474 } |
|
475 case EWPParameterDomain: |
|
476 { |
|
477 if ( iCurrentDomainItem ) |
|
478 { |
|
479 iCurrentDomainItem->SetDomainL( tmpValue->Des() ); |
|
480 } |
|
481 break; |
|
482 } |
|
483 // Here at case 0 are handled the NAT/FW parameters that are |
|
484 // extensions to OMA Client Provisioning parameter set. |
|
485 case 0: |
|
486 |
|
487 // NW/STUNSRVADDR |
|
488 if ( 0 == aParameter.Name().Compare( KStunsrvaddr ) ) |
|
489 { |
|
490 if ( iCharacteristicNw ) |
|
491 { |
|
492 // Domain STUN server settings. |
|
493 if ( !iCharacteristicAdditionalStun ) |
|
494 { |
|
495 iCurrentDomainItem->SetSTUNServerAddrL( |
|
496 tmpValue->Des() ); |
|
497 } |
|
498 // Additional STUN server settings. |
|
499 else |
|
500 { |
|
501 iCurrentStunServer->SetStunSrvAddrL( |
|
502 tmpValue->Des() ); |
|
503 } |
|
504 } |
|
505 } |
|
506 |
|
507 // NW/STUNSRVPORT |
|
508 else if ( 0 == aParameter.Name().Compare( KStunsrvport ) ) |
|
509 { |
|
510 if ( iCharacteristicNw ) |
|
511 { |
|
512 // Domain STUN server settings. |
|
513 if ( !iCharacteristicAdditionalStun ) |
|
514 { |
|
515 iCurrentDomainItem->SetSTUNServerPort( |
|
516 DesToInt( tmpValue->Des() ) ); |
|
517 } |
|
518 // Additional STUN server settings. |
|
519 else |
|
520 { |
|
521 iCurrentStunServer->SetStunSrvPort( DesToInt( |
|
522 tmpValue->Des() ) ); |
|
523 } |
|
524 } |
|
525 } |
|
526 |
|
527 // NW/NATREFRESHTCP |
|
528 else if ( 0 == aParameter.Name().Compare( KNatRefreshTcp ) ) |
|
529 { |
|
530 if ( iCharacteristicNw ) |
|
531 { |
|
532 iCurrentDomainItem->SetNATRefreshTCP( DesToInt( |
|
533 tmpValue->Des() ) ); |
|
534 } |
|
535 } |
|
536 |
|
537 // NW/NATREFRESHUDP |
|
538 else if ( 0 == aParameter.Name().Compare( KNatRefreshUdp ) ) |
|
539 { |
|
540 if ( iCharacteristicNw ) |
|
541 { |
|
542 iCurrentDomainItem->SetNATRefreshUDP( DesToInt( |
|
543 tmpValue->Des() ) ); |
|
544 } |
|
545 } |
|
546 |
|
547 // NW/CRLFREFRESH |
|
548 else if ( 0 == aParameter.Name().Compare( KCrlfRefresh ) ) |
|
549 { |
|
550 if ( iCharacteristicNw ) |
|
551 { |
|
552 iCurrentDomainItem->SetEnableCRLFRefresh( ETrue ); |
|
553 } |
|
554 } |
|
555 // VoIP rel 2.2 parameters |
|
556 |
|
557 // NW/SHAREDSECRET |
|
558 else if ( 0 == aParameter.Name().Compare( KStunSharedSecret ) |
|
559 && iCharacteristicNw ) |
|
560 { |
|
561 // The CentRep key is for not using STUN shared secret so we |
|
562 // must check the provisioned value for using STUN shared |
|
563 // secret and reverse it. |
|
564 if ( TInt( ETrue ) == DesToInt( tmpValue->Des() ) ) |
|
565 { |
|
566 iCurrentDomainItem->SetDisableStunSharedSecret( EFalse ); |
|
567 } |
|
568 else if ( TInt( EFalse ) == DesToInt( tmpValue->Des() ) ) |
|
569 { |
|
570 iCurrentDomainItem->SetDisableStunSharedSecret( ETrue ); |
|
571 } |
|
572 } |
|
573 // NW/SPRANGE |
|
574 else if ( 0 == aParameter.Name().Compare( KPortPoolStart ) |
|
575 && iCharacteristicNw ) |
|
576 { |
|
577 iCurrentDomainItem->SetStartPortRange( DesToInt( |
|
578 tmpValue->Des() ) ); |
|
579 } |
|
580 // NW/EPRANGE |
|
581 else if ( 0 == aParameter.Name().Compare( KPortPoolEnd ) |
|
582 && iCharacteristicNw ) |
|
583 { |
|
584 iCurrentDomainItem->SetEndPortRange( DesToInt( |
|
585 tmpValue->Des() ) ); |
|
586 } |
|
587 // NATIAP/TONAPID |
|
588 else if ( 0 == aParameter.Name().Compare( KToNapId ) ) |
|
589 { |
|
590 if ( iCharacteristicNatIap ) |
|
591 { |
|
592 iCurrentIapItem->SetNapDefNameL( tmpValue->Des() ); |
|
593 } |
|
594 } |
|
595 // NATIAP/REFRESHTCP |
|
596 else if ( 0 == aParameter.Name().Compare( KRefreshTcp ) ) |
|
597 { |
|
598 if ( iCharacteristicNatIap ) |
|
599 { |
|
600 iCurrentIapItem->SetIntervalTCP( DesToInt( |
|
601 tmpValue->Des() ) ); |
|
602 } |
|
603 } |
|
604 // NATIAP/REFRESHUDP |
|
605 else if ( 0 == aParameter.Name().Compare( KRefreshUdp ) ) |
|
606 { |
|
607 if ( iCharacteristicNatIap ) |
|
608 { |
|
609 iCurrentIapItem->SetIntervalUDP( DesToInt( |
|
610 tmpValue->Des() ) ); |
|
611 } |
|
612 } |
|
613 // NATIAP/STUNRETRANSMIT |
|
614 else if ( 0 == aParameter.Name().Compare( KStunRetransmit ) ) |
|
615 { |
|
616 if ( iCharacteristicNatIap ) |
|
617 { |
|
618 iCurrentIapItem->SetSTUNRetransmitTimer( |
|
619 DesToInt( tmpValue->Des() ) ); |
|
620 } |
|
621 } |
|
622 |
|
623 // ICE/NATUTILITIES |
|
624 else if ( 0 == aParameter.Name().Compare( |
|
625 KNatUtilities ) && iCharacteristicIce ) |
|
626 { |
|
627 iCurrentDomainItem->SetNatUtilitiesL( tmpValue->Des() ); |
|
628 } |
|
629 // ICE/HOSTPREF |
|
630 else if ( 0 == aParameter.Name().Compare( KHostPref ) && |
|
631 iCharacteristicIce ) |
|
632 { |
|
633 iCurrentDomainItem->SetHostPref( DesToInt( |
|
634 tmpValue->Des() ) ); |
|
635 } |
|
636 // ICE/SERVERREFPREF |
|
637 else if ( 0 == aParameter.Name().Compare( KServerReflexivePref ) |
|
638 && iCharacteristicIce ) |
|
639 { |
|
640 iCurrentDomainItem->SetServerRefPref( DesToInt( |
|
641 tmpValue->Des() ) ); |
|
642 } |
|
643 // ICE/RELAYPREF |
|
644 else if ( 0 == aParameter.Name().Compare( KRelayPref ) && |
|
645 iCharacteristicIce ) |
|
646 { |
|
647 iCurrentDomainItem->SetRelayPref( DesToInt( |
|
648 tmpValue->Des() ) ); |
|
649 } |
|
650 // ICE/PEERREFPREF |
|
651 else if ( 0 == aParameter.Name().Compare( KPeerReflexivePref ) && |
|
652 iCharacteristicIce ) |
|
653 { |
|
654 iCurrentDomainItem->SetPeerRefPref( DesToInt( |
|
655 tmpValue->Des() ) ); |
|
656 } |
|
657 // ICE/IPV4PREF |
|
658 else if ( 0 == aParameter.Name().Compare( KIPv4Pref ) && |
|
659 iCharacteristicIce ) |
|
660 { |
|
661 iCurrentDomainItem->SetIPv4Pref( DesToInt( |
|
662 tmpValue->Des() ) ); |
|
663 } |
|
664 // ICE/IPV6PREF |
|
665 else if ( 0 == aParameter.Name().Compare( KIPv6Pref ) && |
|
666 iCharacteristicIce ) |
|
667 { |
|
668 iCurrentDomainItem->SetIPv6Pref( DesToInt( |
|
669 tmpValue->Des() ) ); |
|
670 } |
|
671 // ICE/VPNPREF |
|
672 else if ( 0 == aParameter.Name().Compare( KVPNPref ) && |
|
673 iCharacteristicIce ) |
|
674 { |
|
675 iCurrentDomainItem->SetVpnPref( DesToInt( tmpValue->Des() ) ); |
|
676 } |
|
677 // ICE/UDPPREF |
|
678 else if ( 0 == aParameter.Name().Compare( KUDPPref ) && |
|
679 iCharacteristicIce ) |
|
680 { |
|
681 iCurrentDomainItem->SetUdpPref( DesToInt( tmpValue->Des() ) ); |
|
682 } |
|
683 // ICE/TCPPREF |
|
684 else if ( 0 == aParameter.Name().Compare( KTCPPref ) && |
|
685 iCharacteristicIce ) |
|
686 { |
|
687 iCurrentDomainItem->SetTcpPref( DesToInt( tmpValue->Des() ) ); |
|
688 } |
|
689 // ICE/TCPACTIVEPREF |
|
690 else if ( 0 == aParameter.Name().Compare( KTCPActivePref ) && |
|
691 iCharacteristicIce ) |
|
692 { |
|
693 iCurrentDomainItem->SetTcpActivePref( DesToInt( |
|
694 tmpValue->Des() ) ); |
|
695 } |
|
696 // ICE/TCPPASSIVEPREF |
|
697 else if ( 0 == aParameter.Name().Compare( KTCPPassivePref ) && |
|
698 iCharacteristicIce ) |
|
699 { |
|
700 iCurrentDomainItem->SetTcpPassivePref( DesToInt( |
|
701 tmpValue->Des() ) ); |
|
702 } |
|
703 // ICE/TCPSIMULTPREF |
|
704 else if ( 0 == aParameter.Name().Compare( |
|
705 KTCPSimultaneousOpenPref ) && iCharacteristicIce ) |
|
706 { |
|
707 iCurrentDomainItem->SetTcpSimultPref( DesToInt( |
|
708 tmpValue->Des() ) ); |
|
709 } |
|
710 // TURNSERVER/TURNSRVADDR |
|
711 else if ( 0 == aParameter.Name().Compare( KTurnSrvAddr ) && |
|
712 iCharacteristicTurnServer ) |
|
713 { |
|
714 iCurrentTurnServer->SetTurnSrvAddrL( tmpValue->Des() ); |
|
715 } |
|
716 // TURNSERVER/TURNSRVPORT |
|
717 else if ( 0 == aParameter.Name().Compare( KTurnSrvPort ) && |
|
718 iCharacteristicTurnServer ) |
|
719 { |
|
720 iCurrentTurnServer->SetTurnSrvPort( DesToInt( |
|
721 tmpValue->Des() ) ); |
|
722 } |
|
723 break; // case 0 |
|
724 |
|
725 case EWPParameterName: // APPLICATION/NAME |
|
726 iCurrentNATFWItem->SetNameL( aParameter.Value() ); |
|
727 break; |
|
728 |
|
729 case EWPParameterToNapID: // NATIAP/TO-NAPID |
|
730 { |
|
731 if ( iCurrentIapItem ) |
|
732 { |
|
733 iCurrentIapItem->SetNapDefNameL( tmpValue->Des() ); |
|
734 } |
|
735 break; |
|
736 } |
|
737 |
|
738 case EWPParameterAppRef: // APPLICATION/APPREF |
|
739 { |
|
740 if ( 0 == iCurrentNATFWItem->AppRef().Length() ) |
|
741 { |
|
742 iCurrentNATFWItem->SetAppRefL( tmpValue->Des() ); |
|
743 } |
|
744 break; |
|
745 } |
|
746 |
|
747 case EWPParameterAProtocol: // NW/APROTOCOL |
|
748 { |
|
749 if ( iCharacteristicNw ) |
|
750 { |
|
751 iCurrentDomainItem->SetNatProtocolL( tmpValue->Des() ); |
|
752 } |
|
753 break; |
|
754 } |
|
755 |
|
756 case EWPParameterAAuthName: // TURNSERVER/AAUTHNAME |
|
757 { |
|
758 if ( iCharacteristicTurnServer ) |
|
759 { |
|
760 iCurrentTurnServer->SetTurnUsernameL( tmpValue->Des() ); |
|
761 } |
|
762 else if ( iCharacteristicAdditionalStun ) |
|
763 { |
|
764 iCurrentStunServer->SetStunUsernameL( tmpValue->Des() ); |
|
765 } |
|
766 else if ( iCharacteristicNw ) |
|
767 { |
|
768 iCurrentDomainItem->SetSTUNUsernameL( tmpValue->Des() ); |
|
769 } |
|
770 break; |
|
771 } |
|
772 |
|
773 case EWPParameterAAuthSecret: // TURNSERVER/AAUTHSECRET |
|
774 { |
|
775 if ( iCharacteristicTurnServer ) |
|
776 { |
|
777 iCurrentTurnServer->SetTurnPasswordL( tmpValue->Des() ); |
|
778 } |
|
779 else if ( iCharacteristicAdditionalStun ) |
|
780 { |
|
781 iCurrentStunServer->SetStunPasswordL( tmpValue->Des() ); |
|
782 } |
|
783 else if ( iCharacteristicNw ) |
|
784 { |
|
785 iCurrentDomainItem->SetSTUNPasswordL( tmpValue->Des() ); |
|
786 } |
|
787 break; |
|
788 } |
|
789 |
|
790 default: |
|
791 break; |
|
792 }// switch |
|
793 CleanupStack::PopAndDestroy( tmpValue ); |
|
794 |
|
795 DBG_PRINT( "CNATFWTraversalAdapter::VisitL( parameter ) - end" ); |
|
796 } |
|
797 |
|
798 // --------------------------------------------------------------------------- |
|
799 // CNATFWTraversalAdapter::GetSavingInfoL |
|
800 // |
|
801 // --------------------------------------------------------------------------- |
|
802 // |
|
803 void CNATFWTraversalAdapter::GetSavingInfoL( TInt aIndex, |
|
804 RPointerArray<HBufC8> &aSavingInfo ) |
|
805 { |
|
806 DBG_PRINT( "CNATFWTraversalAdapter::GetSavingInfoL - begin" ); |
|
807 |
|
808 if(iDatas[aIndex]->SavedDomainId().Length() > 0 ) |
|
809 { |
|
810 // APPID into place [0]. |
|
811 aSavingInfo.AppendL( KNATFWAppID8().AllocL() ); |
|
812 |
|
813 // APPREF into place [1]. |
|
814 aSavingInfo.AppendL( iDatas[aIndex]->AppRef().AllocL() ); |
|
815 |
|
816 // Domain specific settings key ID into place [2]. |
|
817 // This is the information that is stored in VoIPAdapter. |
|
818 aSavingInfo.AppendL( iDatas[aIndex]->SavedDomainId().AllocL() ); |
|
819 } |
|
820 |
|
821 DBG_PRINT( "CNATFWTraversalAdapter::GetSavingInfoL - end" ); |
|
822 } |
|
823 |
|
824 // --------------------------------------------------------------------------- |
|
825 // CNATFWTraversalAdapter::SettingsSavedL |
|
826 // |
|
827 // --------------------------------------------------------------------------- |
|
828 // |
|
829 void CNATFWTraversalAdapter::SettingsSavedL ( |
|
830 const TDesC8& /*aAppIdOfSavingItem */, const TDesC8& /*aAppRef*/, |
|
831 const TDesC8& /*aStorageIdValue*/ ) |
|
832 { |
|
833 } |
|
834 |
|
835 // --------------------------------------------------------------------------- |
|
836 // CNATFWTraversalAdapter::SavingFinalizedL() |
|
837 // |
|
838 // --------------------------------------------------------------------------- |
|
839 // |
|
840 void CNATFWTraversalAdapter::SavingFinalizedL() |
|
841 { |
|
842 } |
|
843 |
|
844 // --------------------------------------------------------------------------- |
|
845 // CNATFWTraversalAdapter::DesToInt |
|
846 // Converts a 8 bit descriptor to TInt. |
|
847 // --------------------------------------------------------------------------- |
|
848 // |
|
849 TInt CNATFWTraversalAdapter::DesToInt( |
|
850 const TDesC8& aDes ) |
|
851 { |
|
852 TLex8 lex( aDes ); |
|
853 TInt value = 0; |
|
854 lex.Val( value ); |
|
855 return value; |
|
856 } |
|
857 |
|
858 // --------------------------------------------------------------------------- |
|
859 // CNATFWTraversalAdapter::DesToTUint |
|
860 // Converts a 8 bit descriptor to TUint. |
|
861 // --------------------------------------------------------------------------- |
|
862 // |
|
863 TUint CNATFWTraversalAdapter::DesToTUint( |
|
864 const TDesC8& aDes ) |
|
865 { |
|
866 TLex8 lex( aDes ); |
|
867 TInt value = 0; |
|
868 lex.Val( value ); |
|
869 return value; |
|
870 } |
|
871 |
|
872 // --------------------------------------------------------------------------- |
|
873 // CNATFWTraversalAdapter::IapIdFromWapIdL |
|
874 // Returns IAP ID from WAP ID. |
|
875 // --------------------------------------------------------------------------- |
|
876 // |
|
877 TUint32 CNATFWTraversalAdapter::IapIdFromWapIdL( TUint32 aWapId ) |
|
878 { |
|
879 DBG_PRINT( "CNATFWTraversalAdapter::IapIdFromWapIdL - begin" ); |
|
880 RCmManagerExt cmManager; |
|
881 cmManager.OpenLC(); // CS:1 |
|
882 RArray<TUint32> iapIds; |
|
883 |
|
884 TUint32 iapId( 0 ); |
|
885 |
|
886 // First get all free IAP ID's. |
|
887 cmManager.ConnectionMethodL( iapIds ); |
|
888 CleanupClosePushL( iapIds ); // CS:2 |
|
889 |
|
890 // Then get IAP ID's from all destinations. |
|
891 RArray<TUint32> destIds; |
|
892 cmManager.AllDestinationsL( destIds ); |
|
893 CleanupClosePushL( destIds ); // CS:3 |
|
894 |
|
895 TInt destCount = destIds.Count(); |
|
896 for ( TInt destIndex = 0; destIndex < destCount; destIndex++ ) |
|
897 { |
|
898 RCmDestinationExt dest = cmManager.DestinationL( |
|
899 destIds[destIndex] ); |
|
900 |
|
901 CleanupClosePushL( dest ); // CS:4 |
|
902 TInt cmCount = dest.ConnectionMethodCount(); |
|
903 for ( TInt cmIndex = 0; cmIndex < cmCount; cmIndex++ ) |
|
904 { |
|
905 TUint32 apId = dest.ConnectionMethodL( |
|
906 cmIndex ).GetIntAttributeL( CMManager::ECmIapId ); |
|
907 iapIds.AppendL( apId ); |
|
908 } |
|
909 CleanupStack::PopAndDestroy( &dest ); // CS:3 |
|
910 } |
|
911 // Finally, go through all connection methods and find correct IAP ID. |
|
912 const TInt cmCount = iapIds.Count(); |
|
913 for ( TInt counter = 0; counter < cmCount; counter++ ) |
|
914 { |
|
915 TUint32 id = cmManager.GetConnectionMethodInfoIntL( |
|
916 iapIds[counter], CMManager::ECmWapId ); |
|
917 |
|
918 if ( id == aWapId ) |
|
919 { |
|
920 iapId = iapIds[counter]; |
|
921 // No need to go through rest of IAPs. |
|
922 break; |
|
923 } |
|
924 } |
|
925 |
|
926 // PopAndDestroy destIds, iapIds, cmManager. |
|
927 CleanupStack::PopAndDestroy( 3, &cmManager ); // CS:0 |
|
928 |
|
929 DBG_PRINT( "CNATFWTraversalAdapter::IapIdFromWapIdL - end" ); |
|
930 return iapId; |
|
931 } |
|
932 |
|
933 // End of File |