22
|
1 |
/*
|
|
2 |
* Copyright (c) 2009-2010 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: IAP handler for VoIP XML processor
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <e32cmn.h>
|
|
20 |
#include <coecntrl.h>
|
|
21 |
#include <cmmanagerext.h>
|
|
22 |
#include <cmdestinationext.h>
|
|
23 |
#include <cmconnectionmethodext.h>
|
|
24 |
#include <cmconnectionmethoddef.h>
|
|
25 |
#include <cmpluginwlandef.h>
|
|
26 |
#include <WPASecuritySettingsUI.h>
|
|
27 |
#include <WEPSecuritySettingsUI.h>
|
|
28 |
#include <EapSettings.h>
|
|
29 |
#include <EapType.h>
|
|
30 |
|
|
31 |
#include "voipxmlutils.h"
|
|
32 |
#include "voipxmliaphandler.h"
|
|
33 |
#include "voipxmlprocessorlogger.h"
|
|
34 |
|
|
35 |
// ---------------------------------------------------------------------------
|
|
36 |
// CVoipXmlIapHandler::CVoipXmlIapHandler
|
|
37 |
// ---------------------------------------------------------------------------
|
|
38 |
//
|
|
39 |
CVoipXmlIapHandler::CVoipXmlIapHandler()
|
|
40 |
{
|
|
41 |
}
|
|
42 |
|
|
43 |
// ---------------------------------------------------------------------------
|
|
44 |
// CVoipXmlIapHandler::NewL
|
|
45 |
// ---------------------------------------------------------------------------
|
|
46 |
//
|
|
47 |
CVoipXmlIapHandler* CVoipXmlIapHandler::NewL()
|
|
48 |
{
|
|
49 |
CVoipXmlIapHandler* self = new ( ELeave ) CVoipXmlIapHandler;
|
|
50 |
CleanupStack::PushL( self );
|
|
51 |
self->ConstructL();
|
|
52 |
CleanupStack::Pop( self );
|
|
53 |
return self;
|
|
54 |
}
|
|
55 |
|
|
56 |
// ---------------------------------------------------------------------------
|
|
57 |
// CVoipXmlIapHandler::ConstructL
|
|
58 |
// ---------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
void CVoipXmlIapHandler::ConstructL()
|
|
61 |
{
|
|
62 |
iDestinationName = HBufC::NewL( 0 );
|
|
63 |
iDestinationId = 0;
|
|
64 |
iCurrentIap.iSsid = NULL;
|
|
65 |
iCurrentIap.iName = NULL;
|
|
66 |
iCurrentIap.iPreSharedKey = NULL;
|
|
67 |
iCurrentIap.iSecurityType = CMManager::EWlanSecModeOpen;
|
|
68 |
iCurrentIap.iNetworkMode = CMManager::EInfra;
|
|
69 |
iCurrentIap.iWepAuthMode = CWEPSecuritySettings::EAuthOpen;
|
|
70 |
iCurrentIap.iEapType = EAPSettings::EEapNone;
|
|
71 |
iCurrentIap.iEapUsername = NULL;
|
|
72 |
iCurrentIap.iEapPassword = NULL;
|
|
73 |
}
|
|
74 |
|
|
75 |
// ---------------------------------------------------------------------------
|
|
76 |
// CVoipXmlIapHandler::~CVoipXmlIapHandler
|
|
77 |
// ---------------------------------------------------------------------------
|
|
78 |
//
|
|
79 |
CVoipXmlIapHandler::~CVoipXmlIapHandler()
|
|
80 |
{
|
|
81 |
if ( iDestinationName )
|
|
82 |
{
|
|
83 |
delete iDestinationName;
|
|
84 |
}
|
|
85 |
ResetCurrentIap( ETrue );
|
|
86 |
ResetTempIapArray( ETrue );
|
|
87 |
}
|
|
88 |
|
|
89 |
// ---------------------------------------------------------------------------
|
|
90 |
// Sets SIP setting.
|
|
91 |
// ---------------------------------------------------------------------------
|
|
92 |
//
|
|
93 |
void CVoipXmlIapHandler::SetSetting( TInt aType, TInt aParam,
|
|
94 |
const TDesC& aValue )
|
|
95 |
{
|
|
96 |
// Ignore too long descriptors.
|
|
97 |
if ( KMaxNodeValueLength < aValue.Length() )
|
|
98 |
{
|
|
99 |
return;
|
|
100 |
}
|
|
101 |
TInt intValue;
|
|
102 |
|
|
103 |
switch ( aParam )
|
|
104 |
{
|
|
105 |
case EName:
|
|
106 |
{
|
|
107 |
TInt err( KErrNotFound );
|
|
108 |
//lint -e{960} No need for else statement here
|
|
109 |
if ( EDestination == aType )
|
|
110 |
{
|
|
111 |
delete iDestinationName;
|
|
112 |
iDestinationName = NULL;
|
|
113 |
TRAP( err, iDestinationName = aValue.AllocL() );
|
|
114 |
}
|
|
115 |
else if ( EWlan == aType && !iCurrentIap.iName )
|
|
116 |
{
|
|
117 |
TRAP( err, iCurrentIap.iName = aValue.AllocL() );
|
|
118 |
}
|
|
119 |
if ( KErrNone == err )
|
|
120 |
{
|
|
121 |
iSettingsSet = ETrue;
|
|
122 |
}
|
|
123 |
break;
|
|
124 |
}
|
|
125 |
case EType:
|
|
126 |
{
|
|
127 |
TBuf<KMaxNodeValueLength> value;
|
|
128 |
value.Copy( aValue );
|
|
129 |
value.UpperCase();
|
|
130 |
|
|
131 |
if ( EEap == aType )
|
|
132 |
{
|
|
133 |
if ( 0 == value.Compare( KEapTypeLeap ) )
|
|
134 |
{
|
|
135 |
iCurrentIap.iEapType = EAPSettings::EEapLeap;
|
|
136 |
}
|
|
137 |
}
|
|
138 |
|
|
139 |
if ( EWlan != aType )
|
|
140 |
{
|
|
141 |
break;
|
|
142 |
}
|
|
143 |
//lint -e{960} No need for else statement here
|
|
144 |
if ( 0 == value.Compare( KSecurityTypeWep ) )
|
|
145 |
{
|
|
146 |
iCurrentIap.iSecurityType = CMManager::EWlanSecModeWep;
|
|
147 |
}
|
|
148 |
else if ( 0 == value.Compare( KSecurityTypeWpa ) )
|
|
149 |
{
|
|
150 |
iCurrentIap.iSecurityType = CMManager::EWlanSecModeWpa;
|
|
151 |
}
|
|
152 |
else if ( 0 == value.Compare( KSecurityTypeWpa2 ) )
|
|
153 |
{
|
|
154 |
iCurrentIap.iSecurityType = CMManager::EWlanSecModeWpa2;
|
|
155 |
}
|
|
156 |
else if ( 0 == value.Compare( KSecurityType8021x ) )
|
|
157 |
{
|
|
158 |
iCurrentIap.iSecurityType = CMManager::EWlanSecMode802_1x;
|
|
159 |
}
|
|
160 |
break;
|
|
161 |
}
|
|
162 |
case ESsid:
|
|
163 |
{
|
|
164 |
if ( EWlan == aType && !iCurrentIap.iSsid )
|
|
165 |
{
|
|
166 |
iCurrentIap.iSsid = aValue.Alloc();
|
|
167 |
if ( iCurrentIap.iSsid )
|
|
168 |
{
|
|
169 |
iSettingsSet = ETrue;
|
|
170 |
}
|
|
171 |
}
|
|
172 |
break;
|
|
173 |
}
|
|
174 |
case EHidden:
|
|
175 |
{
|
|
176 |
if ( EWlan == aType &&
|
|
177 |
KErrNone == VoipXmlUtils::DesToInt( aValue, intValue ) )
|
|
178 |
{
|
|
179 |
iCurrentIap.iHidden = intValue;
|
|
180 |
}
|
|
181 |
break;
|
|
182 |
}
|
|
183 |
case ENetworkMode:
|
|
184 |
{
|
|
185 |
if ( EWlan != aType )
|
|
186 |
{
|
|
187 |
break;
|
|
188 |
}
|
|
189 |
TBuf<KMaxNodeValueLength> value;
|
|
190 |
value.Copy( aValue );
|
|
191 |
value.LowerCase();
|
|
192 |
//lint -e{960} No need for else statement here
|
|
193 |
if ( 0 == value.Compare( KNetworkModeInfra ) )
|
|
194 |
{
|
|
195 |
iCurrentIap.iNetworkMode = CMManager::EInfra;
|
|
196 |
}
|
|
197 |
else if ( 0 == value.Compare( KNetworkModeAdhoc ) )
|
|
198 |
{
|
|
199 |
iCurrentIap.iNetworkMode = CMManager::EAdhoc;
|
|
200 |
}
|
|
201 |
break;
|
|
202 |
}
|
|
203 |
case EPreSharedKey:
|
|
204 |
{
|
|
205 |
if ( EWlan == aType && !iCurrentIap.iPreSharedKey )
|
|
206 |
{
|
|
207 |
iCurrentIap.iPreSharedKey = aValue.Alloc();
|
|
208 |
}
|
|
209 |
break;
|
|
210 |
}
|
|
211 |
case EWepAuthMode:
|
|
212 |
{
|
|
213 |
if ( EWlan != aType )
|
|
214 |
{
|
|
215 |
break;
|
|
216 |
}
|
|
217 |
TBuf<KMaxNodeValueLength> value;
|
|
218 |
value.Copy( aValue );
|
|
219 |
value.LowerCase();
|
|
220 |
//lint -e{960} No need for else statement here
|
|
221 |
if ( 0 == value.Compare( KWepAuthModeOpen ) )
|
|
222 |
{
|
|
223 |
iCurrentIap.iWepAuthMode = CWEPSecuritySettings::EAuthOpen;
|
|
224 |
}
|
|
225 |
else if ( 0 == value.Compare( KWepAuthModeShared ) )
|
|
226 |
{
|
|
227 |
iCurrentIap.iWepAuthMode = CWEPSecuritySettings::EAuthShared;
|
|
228 |
}
|
|
229 |
break;
|
|
230 |
}
|
|
231 |
case ELength:
|
|
232 |
{
|
|
233 |
if ( EWepKey == aType &&
|
|
234 |
KErrNone == VoipXmlUtils::DesToInt( aValue, intValue ))
|
|
235 |
{
|
|
236 |
iCurrentIap.iCurrentWepKey.iLength = intValue;
|
|
237 |
}
|
|
238 |
break;
|
|
239 |
}
|
|
240 |
case EData:
|
|
241 |
{
|
|
242 |
if ( EWepKey == aType && KMaxWepKeyDataLength >= aValue.Length() )
|
|
243 |
{
|
|
244 |
iCurrentIap.iCurrentWepKey.iData.Copy( aValue );
|
|
245 |
}
|
|
246 |
break;
|
|
247 |
}
|
|
248 |
case EUsername:
|
|
249 |
{
|
|
250 |
if ( EEap == aType )
|
|
251 |
{
|
|
252 |
iCurrentIap.iEapUsername = aValue.Alloc();
|
|
253 |
}
|
|
254 |
break;
|
|
255 |
}
|
|
256 |
case EPassword:
|
|
257 |
{
|
|
258 |
if ( EEap == aType )
|
|
259 |
{
|
|
260 |
iCurrentIap.iEapPassword = aValue.Alloc();
|
|
261 |
}
|
|
262 |
break;
|
|
263 |
}
|
|
264 |
default:
|
|
265 |
break;
|
|
266 |
}
|
|
267 |
}
|
|
268 |
|
|
269 |
// ---------------------------------------------------------------------------
|
|
270 |
// Stores settings.
|
|
271 |
// ---------------------------------------------------------------------------
|
|
272 |
//
|
|
273 |
TInt CVoipXmlIapHandler::StoreSettings()
|
|
274 |
{
|
|
275 |
if ( !iSettingsSet )
|
|
276 |
{
|
|
277 |
// No settings to be stored => method not supported.
|
|
278 |
return KErrNotSupported;
|
|
279 |
}
|
|
280 |
TRAPD( err, StoreSettingsL() );
|
|
281 |
if ( KErrNone != err )
|
|
282 |
{
|
|
283 |
err = KErrCompletion;
|
|
284 |
}
|
|
285 |
return err;
|
|
286 |
}
|
|
287 |
|
|
288 |
// ---------------------------------------------------------------------------
|
|
289 |
// Returns Destination ID.
|
|
290 |
// ---------------------------------------------------------------------------
|
|
291 |
//
|
|
292 |
TUint32 CVoipXmlIapHandler::SettingsId()
|
|
293 |
{
|
|
294 |
return iDestinationId;
|
|
295 |
}
|
|
296 |
|
|
297 |
// ---------------------------------------------------------------------------
|
|
298 |
// Informs that currently deployed settings have ended.
|
|
299 |
// ---------------------------------------------------------------------------
|
|
300 |
//
|
|
301 |
void CVoipXmlIapHandler::SettingsEnd( TInt aType )
|
|
302 |
{
|
|
303 |
//lint -e{960} No need for else statement here
|
|
304 |
if ( EWepKey == aType && iCurrentIap.iWepKeys.Count() < KMaxWepKeyCount )
|
|
305 |
{
|
|
306 |
TInt keyDataLength = iCurrentIap.iCurrentWepKey.iData.Length();
|
|
307 |
TBool okToAdd( EFalse );
|
|
308 |
switch ( keyDataLength )
|
|
309 |
{
|
|
310 |
case EWepKey64Hex:
|
|
311 |
{
|
|
312 |
iCurrentIap.iCurrentWepKey.iHex = ETrue;
|
|
313 |
okToAdd = ETrue;
|
|
314 |
break;
|
|
315 |
}
|
|
316 |
case EWepKey64Ascii:
|
|
317 |
{
|
|
318 |
iCurrentIap.iCurrentWepKey.iHex = EFalse;
|
|
319 |
okToAdd = ETrue;
|
|
320 |
break;
|
|
321 |
}
|
|
322 |
case EWepKey128Hex:
|
|
323 |
{
|
|
324 |
iCurrentIap.iCurrentWepKey.iHex = ETrue;
|
|
325 |
okToAdd = ETrue;
|
|
326 |
break;
|
|
327 |
}
|
|
328 |
case EWepKey128Ascii:
|
|
329 |
{
|
|
330 |
iCurrentIap.iCurrentWepKey.iHex = EFalse;
|
|
331 |
okToAdd = ETrue;
|
|
332 |
break;
|
|
333 |
}
|
|
334 |
default:
|
|
335 |
break;
|
|
336 |
}
|
|
337 |
if ( okToAdd )
|
|
338 |
{
|
|
339 |
iCurrentIap.iWepKeys.Append( iCurrentIap.iCurrentWepKey );
|
|
340 |
}
|
|
341 |
iCurrentIap.iCurrentWepKey.iLength = 0;
|
|
342 |
iCurrentIap.iCurrentWepKey.iData.Zero();
|
|
343 |
}
|
|
344 |
else if ( EWlan == aType )
|
|
345 |
{
|
|
346 |
TRAP_IGNORE( AddCurrentIapL() );
|
|
347 |
ResetCurrentIap();
|
|
348 |
}
|
|
349 |
}
|
|
350 |
|
|
351 |
// ---------------------------------------------------------------------------
|
|
352 |
// Resets iCurrentIap members.
|
|
353 |
// ---------------------------------------------------------------------------
|
|
354 |
//
|
|
355 |
void CVoipXmlIapHandler::ResetCurrentIap( TBool aCloseArray )
|
|
356 |
{
|
|
357 |
if ( iCurrentIap.iName )
|
|
358 |
{
|
|
359 |
delete iCurrentIap.iName;
|
|
360 |
iCurrentIap.iName = NULL;
|
|
361 |
}
|
|
362 |
if ( iCurrentIap.iPreSharedKey )
|
|
363 |
{
|
|
364 |
delete iCurrentIap.iPreSharedKey;
|
|
365 |
iCurrentIap.iPreSharedKey = NULL;
|
|
366 |
}
|
|
367 |
if ( iCurrentIap.iSsid )
|
|
368 |
{
|
|
369 |
delete iCurrentIap.iSsid;
|
|
370 |
iCurrentIap.iSsid = NULL;
|
|
371 |
}
|
|
372 |
iCurrentIap.iWepKeys.Reset();
|
|
373 |
if ( aCloseArray )
|
|
374 |
{
|
|
375 |
iCurrentIap.iWepKeys.Close();
|
|
376 |
}
|
|
377 |
iCurrentIap.iHidden = EFalse;
|
|
378 |
iCurrentIap.iSecurityType = CMManager::EWlanSecModeOpen;
|
|
379 |
iCurrentIap.iNetworkMode = CMManager::EInfra;
|
|
380 |
iCurrentIap.iWepAuthMode = CWEPSecuritySettings::EAuthOpen;
|
|
381 |
|
|
382 |
iCurrentIap.iEapType = EAPSettings::EEapNone;
|
|
383 |
if ( iCurrentIap.iEapUsername )
|
|
384 |
{
|
|
385 |
delete iCurrentIap.iEapUsername;
|
|
386 |
iCurrentIap.iEapUsername = NULL;
|
|
387 |
}
|
|
388 |
if ( iCurrentIap.iEapPassword )
|
|
389 |
{
|
|
390 |
delete iCurrentIap.iEapPassword;
|
|
391 |
iCurrentIap.iEapPassword = NULL;
|
|
392 |
}
|
|
393 |
}
|
|
394 |
|
|
395 |
// ---------------------------------------------------------------------------
|
|
396 |
// Resets iIaps members.
|
|
397 |
// ---------------------------------------------------------------------------
|
|
398 |
//
|
|
399 |
void CVoipXmlIapHandler::ResetTempIapArray( TBool aCloseArray )
|
|
400 |
{
|
|
401 |
const TInt count = iIaps.Count();
|
|
402 |
for ( TInt counter = 0; counter < count; counter++ )
|
|
403 |
{
|
|
404 |
if ( iIaps[counter]->iName )
|
|
405 |
{
|
|
406 |
delete iIaps[counter]->iName;
|
|
407 |
iIaps[counter]->iName = NULL;
|
|
408 |
}
|
|
409 |
if ( iIaps[counter]->iPreSharedKey )
|
|
410 |
{
|
|
411 |
delete iIaps[counter]->iPreSharedKey;
|
|
412 |
iIaps[counter]->iPreSharedKey = NULL;
|
|
413 |
}
|
|
414 |
if ( iIaps[counter]->iSsid )
|
|
415 |
{
|
|
416 |
delete iIaps[counter]->iSsid;
|
|
417 |
iIaps[counter]->iSsid = NULL;
|
|
418 |
}
|
|
419 |
iIaps[counter]->iWepKeys.Reset();
|
|
420 |
if ( aCloseArray )
|
|
421 |
{
|
|
422 |
iIaps[counter]->iWepKeys.Close();
|
|
423 |
}
|
|
424 |
if ( iIaps[counter]->iEapUsername )
|
|
425 |
{
|
|
426 |
delete iIaps[counter]->iEapUsername;
|
|
427 |
iIaps[counter]->iEapUsername = NULL;
|
|
428 |
}
|
|
429 |
if ( iIaps[counter]->iEapPassword )
|
|
430 |
{
|
|
431 |
delete iIaps[counter]->iEapPassword;
|
|
432 |
iIaps[counter]->iEapPassword = NULL;
|
|
433 |
}
|
|
434 |
}
|
|
435 |
iIaps.ResetAndDestroy();
|
|
436 |
if ( aCloseArray )
|
|
437 |
{
|
|
438 |
iIaps.Close();
|
|
439 |
}
|
|
440 |
}
|
|
441 |
|
|
442 |
// ---------------------------------------------------------------------------
|
|
443 |
// Adds iCurrentIap into iIaps array, i.e. copies its values to a pointer
|
|
444 |
// and appends that one into the array.
|
|
445 |
// ---------------------------------------------------------------------------
|
|
446 |
//
|
|
447 |
void CVoipXmlIapHandler::AddCurrentIapL()
|
|
448 |
{
|
|
449 |
if ( !iCurrentIap.iSsid )
|
|
450 |
{
|
|
451 |
// If there is no SSID, we won't add the IAP to array.
|
|
452 |
return;
|
|
453 |
}
|
|
454 |
TTemporaryIap* iap = new TTemporaryIap;
|
|
455 |
iap->iSsid = HBufC::NewLC( KMaxNodeValueLength ); // CS:1
|
|
456 |
iap->iName = HBufC::NewLC( KMaxNodeValueLength ); // CS:2
|
|
457 |
iap->iPreSharedKey = HBufC::NewLC( KMaxNodeValueLength ); // CS:3
|
|
458 |
iap->iEapUsername = HBufC::NewLC( KMaxNodeValueLength ); // CS:4
|
|
459 |
iap->iEapPassword = HBufC::NewLC( KMaxNodeValueLength ); // CS:5
|
|
460 |
|
|
461 |
iap->iSsid->Des().Copy( iCurrentIap.iSsid->Des() );
|
|
462 |
if ( iCurrentIap.iName )
|
|
463 |
{
|
|
464 |
iap->iName->Des().Copy( iCurrentIap.iName->Des() );
|
|
465 |
}
|
|
466 |
else
|
|
467 |
{
|
|
468 |
iap->iName->Des().Copy( iCurrentIap.iSsid->Des() );
|
|
469 |
}
|
|
470 |
|
|
471 |
if ( iCurrentIap.iPreSharedKey )
|
|
472 |
{
|
|
473 |
iap->iPreSharedKey->Des().Copy( iCurrentIap.iPreSharedKey->Des() );
|
|
474 |
}
|
|
475 |
|
|
476 |
iap->iEapType = iCurrentIap.iEapType;
|
|
477 |
if ( iCurrentIap.iEapUsername )
|
|
478 |
{
|
|
479 |
iap->iEapUsername->Des().Copy( iCurrentIap.iEapUsername->Des() );
|
|
480 |
}
|
|
481 |
if ( iCurrentIap.iEapPassword )
|
|
482 |
{
|
|
483 |
iap->iEapPassword->Des().Copy( iCurrentIap.iEapPassword->Des() );
|
|
484 |
}
|
|
485 |
|
|
486 |
iap->iHidden = iCurrentIap.iHidden;
|
|
487 |
iap->iNetworkMode = iCurrentIap.iNetworkMode;
|
|
488 |
iap->iSecurityType = iCurrentIap.iSecurityType;
|
|
489 |
iap->iWepAuthMode = iCurrentIap.iWepAuthMode;
|
|
490 |
const TInt count = iCurrentIap.iWepKeys.Count();
|
|
491 |
for ( TInt counter = 0; counter < count; counter++ )
|
|
492 |
{
|
|
493 |
iap->iWepKeys.Append( iCurrentIap.iWepKeys[counter] );
|
|
494 |
}
|
|
495 |
iIaps.AppendL( iap );
|
|
496 |
CleanupStack::Pop( 5, iap->iSsid );
|
|
497 |
}
|
|
498 |
|
|
499 |
// ---------------------------------------------------------------------------
|
|
500 |
// Stores settings.
|
|
501 |
// ---------------------------------------------------------------------------
|
|
502 |
//
|
|
503 |
void CVoipXmlIapHandler::StoreSettingsL()
|
|
504 |
{
|
|
505 |
RCmManagerExt cmm;
|
|
506 |
cmm.OpenLC(); // CS:1
|
|
507 |
|
|
508 |
// First create all access points and store their ID's.
|
|
509 |
const TInt iapCount = iIaps.Count();
|
|
510 |
RArray<TUint32> iapIds;
|
|
511 |
CleanupClosePushL( iapIds ); // CS:2
|
|
512 |
for ( TInt counter = 0; counter < iapCount; counter++ )
|
|
513 |
{
|
|
514 |
TUint32 id = CreateIapL( cmm, *iIaps[counter] );
|
|
515 |
iapIds.AppendL( id );
|
|
516 |
}
|
|
517 |
|
|
518 |
// Create a destination if one was configured.
|
|
519 |
if ( iDestinationName->Des().Length() )
|
|
520 |
{
|
|
521 |
RArray<TUint32> destinationIds;
|
|
522 |
// Get destination ID's for checking if name to be set is reserved.
|
|
523 |
CleanupClosePushL( destinationIds ); // CS:3
|
|
524 |
cmm.AllDestinationsL( destinationIds );
|
|
525 |
HBufC* newName = HBufC::NewLC( KMaxDestinationNameLength + KSpaceForParenthesis ); // CS:4
|
|
526 |
if( iDestinationName->Des().Length() >= KMaxDestinationNameLength )
|
|
527 |
{
|
|
528 |
newName->Des().Copy( iDestinationName->Left( KMaxDestinationNameLength ) );
|
|
529 |
}
|
|
530 |
else
|
|
531 |
{
|
|
532 |
newName->Des().Copy( iDestinationName->Des() );
|
|
533 |
}
|
|
534 |
|
|
535 |
// Check that name is unique.
|
|
536 |
const TInt destinationCount = destinationIds.Count();
|
|
537 |
for ( TInt counter = 0; counter < destinationCount; counter++ )
|
|
538 |
{
|
|
539 |
RCmDestinationExt destination = cmm.DestinationL(
|
|
540 |
destinationIds[counter] );
|
|
541 |
CleanupClosePushL( destination ); // CS:5
|
|
542 |
HBufC* settingsName = destination.NameLC(); // CS:6
|
|
543 |
TUint i( 1 ); // Add number to the name if name already in use.
|
|
544 |
if ( 0 == newName->Des().Compare( settingsName->Des() ) )
|
|
545 |
{
|
|
546 |
// If the name is changed we need to begin the comparison
|
|
547 |
// again from the first profile.
|
|
548 |
if ( iDestinationName->Des().Length() >= KMaxDestinationNameLength )
|
|
549 |
{
|
|
550 |
newName->Des().Copy( iDestinationName->Left( KMaxDestinationNameLength ) );
|
|
551 |
}
|
|
552 |
else
|
|
553 |
{
|
|
554 |
newName->Des().Copy( iDestinationName->Des() );
|
|
555 |
}
|
|
556 |
newName->Des().Append( KOpenParenthesis() );
|
|
557 |
newName->Des().AppendNum( i );
|
|
558 |
newName->Des().Append( KClosedParenthesis() );
|
|
559 |
counter = 0;
|
|
560 |
i++;
|
|
561 |
if ( KMaxProfileNames < i )
|
|
562 |
{
|
|
563 |
User::Leave( KErrBadName );
|
|
564 |
}
|
|
565 |
}
|
|
566 |
// settingsName, &destination
|
|
567 |
CleanupStack::PopAndDestroy( 2, &destination ); // CS:4
|
|
568 |
}
|
|
569 |
RCmDestinationExt newDestination = cmm.CreateDestinationL( *newName );
|
|
570 |
CleanupClosePushL( newDestination ); // CS:5
|
|
571 |
// We need to run UpdateL in order to get destination ID.
|
|
572 |
newDestination.UpdateL();
|
|
573 |
iDestinationId = newDestination.Id();
|
|
574 |
const TInt cmCount = iapIds.Count();
|
|
575 |
for ( TInt counter = 0; counter < cmCount; counter++ )
|
|
576 |
{
|
|
577 |
RCmConnectionMethodExt connection = cmm.ConnectionMethodL(
|
|
578 |
iapIds[counter] );
|
|
579 |
CleanupClosePushL( connection );
|
|
580 |
newDestination.AddConnectionMethodL( connection );
|
|
581 |
CleanupStack::PopAndDestroy( &connection );
|
|
582 |
}
|
|
583 |
newDestination.UpdateL();
|
|
584 |
|
|
585 |
// &newDestination, newName, &destinationIds
|
|
586 |
CleanupStack::PopAndDestroy( 3, &destinationIds ); // CS:2
|
|
587 |
}
|
|
588 |
|
|
589 |
// no destination name is defined.
|
|
590 |
else
|
|
591 |
{
|
|
592 |
RArray<TUint32> destinationIds;
|
|
593 |
CleanupClosePushL( destinationIds ); // CS:3
|
|
594 |
cmm.AllDestinationsL( destinationIds );
|
|
595 |
const TInt count = destinationIds.Count();
|
|
596 |
for (TInt counter = 0; counter < count ; counter ++)
|
|
597 |
{
|
|
598 |
RCmDestinationExt destination = cmm.DestinationL( destinationIds[counter] );
|
|
599 |
CleanupClosePushL( destination ); // CS:4
|
|
600 |
if ( destination.MetadataL(
|
|
601 |
CMManager::ESnapMetadataPurpose) == CMManager::ESnapPurposeInternet )
|
|
602 |
{
|
|
603 |
const TInt cmCount = iapIds.Count();
|
|
604 |
for ( TInt i = 0; i < cmCount; i++ )
|
|
605 |
{
|
|
606 |
RCmConnectionMethodExt connection = cmm.ConnectionMethodL(iapIds[i] );
|
|
607 |
CleanupClosePushL( connection );
|
|
608 |
destination.AddConnectionMethodL(connection );
|
|
609 |
CleanupStack::PopAndDestroy( &connection );
|
|
610 |
}
|
|
611 |
}
|
|
612 |
destination.UpdateL();
|
|
613 |
CleanupStack::PopAndDestroy( &destination ); // CS:3
|
|
614 |
CleanupStack::PopAndDestroy( &destinationIds ); // CS:2
|
|
615 |
break;
|
|
616 |
}
|
|
617 |
}
|
|
618 |
|
|
619 |
// &iapIds, &cmm
|
|
620 |
CleanupStack::PopAndDestroy( 2, &cmm ); // CS:0
|
|
621 |
}
|
|
622 |
|
|
623 |
// ---------------------------------------------------------------------------
|
|
624 |
// Creates an actual IAP.
|
|
625 |
// ---------------------------------------------------------------------------
|
|
626 |
//
|
|
627 |
TUint32 CVoipXmlIapHandler::CreateIapL( RCmManagerExt& aCmManager,
|
|
628 |
TTemporaryIap aTempIap )
|
|
629 |
{
|
|
630 |
DBG_PRINT( "CVoipXmlIapHandler::CreateIapL - begin" );
|
|
631 |
RCmConnectionMethodExt newConnMethod =
|
|
632 |
aCmManager.CreateConnectionMethodL( KUidWlanBearerType );
|
|
633 |
CleanupClosePushL( newConnMethod ); // CS:1
|
|
634 |
newConnMethod.SetStringAttributeL( CMManager::ECmName,
|
|
635 |
aTempIap.iName->Des() );
|
|
636 |
newConnMethod.SetStringAttributeL( CMManager::EWlanSSID,
|
|
637 |
aTempIap.iSsid->Des() );
|
|
638 |
newConnMethod.SetIntAttributeL( CMManager::EWlanConnectionMode,
|
|
639 |
aTempIap.iNetworkMode );
|
|
640 |
if ( aTempIap.iHidden )
|
|
641 |
{
|
|
642 |
newConnMethod.SetBoolAttributeL( CMManager::EWlanScanSSID, ETrue );
|
|
643 |
}
|
|
644 |
newConnMethod.SetIntAttributeL( CMManager::EWlanSecurityMode,
|
|
645 |
aTempIap.iSecurityType );
|
|
646 |
newConnMethod.UpdateL();
|
|
647 |
TUint32 wlanId = newConnMethod.GetIntAttributeL(
|
|
648 |
CMManager::EWlanServiceId );
|
|
649 |
TUint32 iapId = newConnMethod.GetIntAttributeL( CMManager::ECmIapId );
|
|
650 |
TUint32 iapServiceId = newConnMethod.GetIntAttributeL(
|
|
651 |
CMManager::ECmIapServiceId );
|
|
652 |
|
|
653 |
if ( aTempIap.iSecurityType == CMManager::EWlanSecModeWep )
|
|
654 |
{
|
|
655 |
DBG_PRINT( " secMode WEP" );
|
|
656 |
CMDBSession* db = CMDBSession::NewLC( CMDBSession::LatestVersion() );
|
|
657 |
// CS:1
|
|
658 |
CWEPSecuritySettings* wepSecSettings =
|
|
659 |
CWEPSecuritySettings::NewL();
|
|
660 |
CleanupStack::PushL( wepSecSettings ); // CS:3
|
|
661 |
const TInt wepKeyCount = aTempIap.iWepKeys.Count();
|
|
662 |
for ( TInt counter = 0; counter < wepKeyCount; counter++ )
|
|
663 |
{
|
|
664 |
User::LeaveIfError( wepSecSettings->SetKeyDataL(
|
|
665 |
counter, aTempIap.iWepKeys[counter].iData,
|
|
666 |
aTempIap.iWepKeys[counter].iHex ) );
|
|
667 |
}
|
|
668 |
wepSecSettings->SaveL( wlanId, *db );
|
|
669 |
// wepSecSettings, db
|
|
670 |
CleanupStack::PopAndDestroy( 2, db ); // CS:1
|
|
671 |
}
|
|
672 |
else if ( CMManager::EWlanSecModeWpa == aTempIap.iSecurityType ||
|
|
673 |
CMManager::EWlanSecModeWpa2 == aTempIap.iSecurityType )
|
|
674 |
{
|
|
675 |
DBG_PRINT( " secMode WPA/WPA2" );
|
|
676 |
CMDBSession* db = CMDBSession::NewLC(
|
|
677 |
CMDBSession::LatestVersion() ); // CS:2
|
|
678 |
CWPASecuritySettings* wpaSecSettings =
|
|
679 |
CWPASecuritySettings::NewL( ESecurityModeWpa );
|
|
680 |
CleanupStack::PushL( wpaSecSettings ); // CS:3
|
|
681 |
|
|
682 |
if ( EAPSettings::EEapNone == aTempIap.iEapType )
|
|
683 |
{
|
|
684 |
DBG_PRINT( " EapType none" );
|
|
685 |
//If error happens then delete newConnMethod and leave
|
|
686 |
TInt error = wpaSecSettings->SetWPAPreSharedKey(
|
|
687 |
aTempIap.iPreSharedKey->Des() );
|
|
688 |
if ( error )
|
|
689 |
{
|
|
690 |
newConnMethod.DeleteL();
|
|
691 |
User::Leave( error );
|
|
692 |
}
|
|
693 |
wpaSecSettings->SaveL( wlanId, *db, ESavingBrandNewAP, 0 );
|
|
694 |
}
|
|
695 |
else if ( EAPSettings::EEapLeap == aTempIap.iEapType )
|
|
696 |
{
|
|
697 |
DBG_PRINT( " eapType Leap" );
|
|
698 |
|
|
699 |
TBuf8<KMaxNodeValueLength> eapId;
|
|
700 |
eapId.Copy( KEapLeapId, KEapChars );
|
|
701 |
|
|
702 |
TInt error = wpaSecSettings->SetWPAEnabledEAPPlugin( eapId );
|
|
703 |
if ( error )
|
|
704 |
{
|
|
705 |
newConnMethod.DeleteL();
|
|
706 |
User::Leave( error );
|
|
707 |
}
|
|
708 |
wpaSecSettings->SaveL( wlanId, *db, ESavingBrandNewAP, 0 );
|
|
709 |
|
|
710 |
CEapType* eapType = CEapType::NewL( eapId, ELan, wlanId );
|
|
711 |
CleanupStack::PushL( eapType ); // CS:4
|
|
712 |
EAPSettings* eapSettings = new (ELeave) EAPSettings();
|
|
713 |
CleanupStack::PushL( eapSettings ); // CS:5
|
|
714 |
eapSettings->iEAPType = EAPSettings::EEapLeap;
|
|
715 |
eapSettings->iUsername.Copy( aTempIap.iEapUsername->Des() );
|
|
716 |
eapSettings->iUsernamePresent = ETrue;
|
|
717 |
eapSettings->iPassword.Copy( aTempIap.iEapPassword->Des() );
|
|
718 |
eapSettings->iPasswordPresent = ETrue;
|
|
719 |
eapType->SetConfigurationL( *eapSettings );
|
|
720 |
CleanupStack::PopAndDestroy( 2, eapType ); // CS:3
|
|
721 |
}
|
|
722 |
// wpaSecSettings, db
|
|
723 |
CleanupStack::PopAndDestroy( 2, db ); // CS:1
|
|
724 |
}
|
|
725 |
else if ( CMManager::EWlanSecMode802_1x == aTempIap.iSecurityType )
|
|
726 |
{
|
|
727 |
DBG_PRINT( " secMode 802.1X" );
|
|
728 |
CMDBSession* db = CMDBSession::NewLC(
|
|
729 |
CMDBSession::LatestVersion() ); // CS:1
|
|
730 |
CWPASecuritySettings* wpaSecSettings =
|
|
731 |
CWPASecuritySettings::NewL( ESecurityMode8021x );
|
|
732 |
CleanupStack::PushL( wpaSecSettings ); // CS:2
|
|
733 |
TInt error = wpaSecSettings->SetWPAPreSharedKey(
|
|
734 |
aTempIap.iPreSharedKey->Des() );
|
|
735 |
if ( error )
|
|
736 |
{
|
|
737 |
newConnMethod.DeleteL();
|
|
738 |
User::Leave( error );
|
|
739 |
}
|
|
740 |
wpaSecSettings->SaveL( wlanId, *db, ESavingBrandNewAP, 0 );
|
|
741 |
// wpaSecSettings, db
|
|
742 |
CleanupStack::PopAndDestroy( 2, db ); // CS:1
|
|
743 |
}
|
|
744 |
CleanupStack::PopAndDestroy( &newConnMethod ); // CS:0
|
|
745 |
|
|
746 |
DBG_PRINT( "CVoipXmlIapHandler::CreateIapL - end" );
|
|
747 |
return iapId;
|
|
748 |
}
|
|
749 |
|
|
750 |
// End of file.
|