46
|
1 |
/*
|
|
2 |
* Copyright (c) 2001-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 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: Implementation of EAP Plugin Configuration
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
/*
|
|
19 |
* %version: 24 %
|
|
20 |
*/
|
|
21 |
|
|
22 |
// INCLUDE FILES
|
|
23 |
#include "EAPPluginConfiguration.h"
|
|
24 |
#include "EAPPlugInConfigurationDlg.h"
|
|
25 |
#include "EAPPluginConfigurationModel.h"
|
|
26 |
#include <bautils.h>
|
|
27 |
#include <EapType.h>
|
|
28 |
#include "EAPPluginList.h"
|
|
29 |
|
|
30 |
#include <ecom/ecom.h>
|
|
31 |
#include <data_caging_path_literals.hrh>
|
|
32 |
#include <eappluginconfigres.rsg>
|
|
33 |
|
|
34 |
// CONSTANTS
|
|
35 |
_LIT( KDriveZ, "z:" ); // ROM folder
|
|
36 |
_LIT( KResourceFileName, "EAPPluginConfigRes.rsc" ); // RSC file name.
|
|
37 |
_LIT( KSpace, " " );
|
|
38 |
_LIT( KPlusSign, "+" );
|
|
39 |
_LIT( KMinusSign, "-" );
|
|
40 |
_LIT( KComma, "," );
|
|
41 |
|
|
42 |
|
|
43 |
// Length of the UID
|
|
44 |
static const TInt KLengthOfImplUid = 3;
|
|
45 |
|
|
46 |
// Length of expanded EAP type (RFC 3748)
|
|
47 |
static const TInt KLengthOfExpEapType = 8;
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
52 |
|
|
53 |
// -----------------------------------------------------------------------------
|
|
54 |
// CEAPPluginConfiguration::CEAPPluginConfiguration
|
|
55 |
// -----------------------------------------------------------------------------
|
|
56 |
//
|
|
57 |
CEAPPluginConfiguration::CEAPPluginConfiguration()
|
|
58 |
: iIapId( 0 )
|
|
59 |
{
|
|
60 |
}
|
|
61 |
|
|
62 |
|
|
63 |
// -----------------------------------------------------------------------------
|
|
64 |
// CEAPPluginConfiguration::NewL
|
|
65 |
// -----------------------------------------------------------------------------
|
|
66 |
//
|
|
67 |
CEAPPluginConfiguration* CEAPPluginConfiguration::NewL()
|
|
68 |
{
|
|
69 |
CEAPPluginConfiguration* self = NewLC();
|
|
70 |
CleanupStack::Pop( self );
|
|
71 |
return self;
|
|
72 |
}
|
|
73 |
|
|
74 |
|
|
75 |
// -----------------------------------------------------------------------------
|
|
76 |
// CEAPPluginConfiguration::NewLC
|
|
77 |
// -----------------------------------------------------------------------------
|
|
78 |
//
|
|
79 |
CEAPPluginConfiguration* CEAPPluginConfiguration::NewLC()
|
|
80 |
{
|
|
81 |
CEAPPluginConfiguration* self = new( ELeave )CEAPPluginConfiguration();
|
|
82 |
CleanupStack::PushL(self);
|
|
83 |
self->ConstructL();
|
|
84 |
return self;
|
|
85 |
}
|
|
86 |
|
|
87 |
|
|
88 |
// -----------------------------------------------------------------------------
|
|
89 |
// CEAPPluginConfiguration::ConstructL
|
|
90 |
// -----------------------------------------------------------------------------
|
|
91 |
//
|
|
92 |
void CEAPPluginConfiguration::ConstructL()
|
|
93 |
{
|
|
94 |
}
|
|
95 |
|
|
96 |
|
|
97 |
// -----------------------------------------------------------------------------
|
|
98 |
// CEAPPluginConfiguration::~CEAPPluginConfiguration
|
|
99 |
// -----------------------------------------------------------------------------
|
|
100 |
//
|
|
101 |
CEAPPluginConfiguration::~CEAPPluginConfiguration()
|
|
102 |
{
|
|
103 |
iEapArray.ResetAndDestroy();
|
|
104 |
CCoeEnv::Static()->DeleteResourceFile( iResOffset );
|
|
105 |
}
|
|
106 |
|
|
107 |
|
|
108 |
// ---------------------------------------------------------
|
|
109 |
// CEAPPluginConfiguration::EAPPluginConfigurationL
|
|
110 |
// ---------------------------------------------------------
|
|
111 |
//
|
|
112 |
TInt CEAPPluginConfiguration::EAPPluginConfigurationL( TDes& aWPAEAPPlugin,
|
|
113 |
const TUint32 aIapId,
|
|
114 |
const TDes& aConnectionName )
|
|
115 |
{
|
|
116 |
// Adding the resource file to the CoeEnv.
|
|
117 |
if( !iResOffset )
|
|
118 |
{
|
|
119 |
TFileName fileName;
|
|
120 |
|
|
121 |
fileName.Append( KDriveZ );
|
|
122 |
fileName.Append( KDC_RESOURCE_FILES_DIR );
|
|
123 |
fileName.Append( KResourceFileName );
|
|
124 |
|
|
125 |
BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(),
|
|
126 |
fileName );
|
|
127 |
|
|
128 |
TRAP_IGNORE( iResOffset =
|
|
129 |
CCoeEnv::Static()->AddResourceFileL( fileName ); );
|
|
130 |
}
|
|
131 |
|
|
132 |
TInt buttonId;
|
|
133 |
|
|
134 |
REAPPluginList plugins; ///< Plug-in infos.
|
|
135 |
|
|
136 |
LoadPluginInfoL( aWPAEAPPlugin, plugins );
|
|
137 |
CEAPPluginConfigurationModel* model = new( ELeave )
|
|
138 |
CEAPPluginConfigurationModel( plugins );
|
|
139 |
CleanupStack::PushL( model );
|
|
140 |
|
|
141 |
CEAPPluginConfigurationDlg* pluginDlg = new( ELeave )
|
|
142 |
CEAPPluginConfigurationDlg( buttonId, *model, aIapId );
|
|
143 |
|
|
144 |
pluginDlg->ConstructAndRunLD( plugins, aConnectionName );
|
|
145 |
|
|
146 |
SavePluginInfoL( aWPAEAPPlugin, plugins );
|
|
147 |
|
|
148 |
CleanupStack::PopAndDestroy( model );
|
|
149 |
plugins.Close();
|
|
150 |
|
|
151 |
iIapId = aIapId;
|
|
152 |
|
|
153 |
return buttonId;
|
|
154 |
}
|
|
155 |
|
|
156 |
|
|
157 |
// ---------------------------------------------------------
|
|
158 |
// CEAPPluginConfiguration::EAPPluginConfigurationL
|
|
159 |
// ---------------------------------------------------------
|
|
160 |
//
|
|
161 |
TInt CEAPPluginConfiguration::EAPPluginConfigurationL(
|
|
162 |
TDes8& aWPAEnabledEAPPlugin,
|
|
163 |
TDes8& aWPADisabledEAPPlugin,
|
|
164 |
const TUint32 aIapId,
|
|
165 |
const TDes& aConnectionName )
|
|
166 |
{
|
|
167 |
// Adding the resource file to the CoeEnv.
|
|
168 |
if( !iResOffset )
|
|
169 |
{
|
|
170 |
TFileName fileName;
|
|
171 |
|
|
172 |
fileName.Append( KDriveZ );
|
|
173 |
fileName.Append( KDC_RESOURCE_FILES_DIR );
|
|
174 |
fileName.Append( KResourceFileName );
|
|
175 |
|
|
176 |
BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(),
|
|
177 |
fileName );
|
|
178 |
|
|
179 |
TRAP_IGNORE( iResOffset =
|
|
180 |
CCoeEnv::Static()->AddResourceFileL( fileName ); );
|
|
181 |
}
|
|
182 |
|
|
183 |
|
|
184 |
TInt buttonId;
|
|
185 |
|
|
186 |
REAPPluginList plugins; ///< Plug-in infos.
|
|
187 |
|
|
188 |
LoadPluginInfoL( aWPAEnabledEAPPlugin, aWPADisabledEAPPlugin, plugins );
|
|
189 |
CEAPPluginConfigurationModel* model = new( ELeave )
|
|
190 |
CEAPPluginConfigurationModel( plugins );
|
|
191 |
CleanupStack::PushL( model );
|
|
192 |
|
|
193 |
CEAPPluginConfigurationDlg* pluginDlg = new( ELeave )
|
|
194 |
CEAPPluginConfigurationDlg( buttonId, *model, aIapId );
|
|
195 |
|
|
196 |
pluginDlg->ConstructAndRunLD( plugins, aConnectionName );
|
|
197 |
|
|
198 |
SavePluginInfoL( aWPAEnabledEAPPlugin, aWPADisabledEAPPlugin, plugins );
|
|
199 |
|
|
200 |
CleanupStack::PopAndDestroy( model );
|
|
201 |
plugins.Close();
|
|
202 |
|
|
203 |
iIapId = aIapId;
|
|
204 |
|
|
205 |
return buttonId;
|
|
206 |
}
|
|
207 |
|
|
208 |
|
|
209 |
// ---------------------------------------------------------
|
|
210 |
// CEAPPluginConfiguration::LoadPluginInfoL
|
|
211 |
// ---------------------------------------------------------
|
|
212 |
//
|
|
213 |
void CEAPPluginConfiguration::LoadPluginInfoL( TDes& aWPAEAPPlugin,
|
|
214 |
REAPPluginList& aPlugins )
|
|
215 |
{
|
|
216 |
TInt posComma = aWPAEAPPlugin.Locate( ',' );
|
|
217 |
while ( posComma != KErrNotFound ) // Extract the parameters
|
|
218 |
{
|
|
219 |
aWPAEAPPlugin.Replace( posComma, 1, KSpace );
|
|
220 |
posComma = aWPAEAPPlugin.Locate( ',' );
|
|
221 |
}
|
|
222 |
|
|
223 |
TLex lex( aWPAEAPPlugin );
|
|
224 |
|
|
225 |
CArrayFixFlat<TPtrC>* params; // array of parameters
|
|
226 |
params = new( ELeave ) CArrayFixFlat<TPtrC>( sizeof( TPtrC ) );
|
|
227 |
CleanupStack::PushL( params );
|
|
228 |
|
|
229 |
while ( !lex.Eos() ) // Extract the parameters
|
|
230 |
{
|
|
231 |
params->AppendL( lex.NextToken() );
|
|
232 |
}
|
|
233 |
|
|
234 |
aPlugins.Reset(); // Reset this first: dependent on iEapArray.
|
|
235 |
iEapArray.ResetAndDestroy();
|
|
236 |
REComSession::ListImplementationsL( KEapTypeInterfaceUid, iEapArray );
|
|
237 |
|
|
238 |
// EAP plugin interface dialog should show only the EAP types that allowed
|
|
239 |
// outside PEAP.
|
|
240 |
|
|
241 |
for( TInt count = 0; count < iEapArray.Count(); count++ )
|
|
242 |
{
|
|
243 |
// Filter out the EAP types which are NOT allowed outside PEAP.
|
|
244 |
if( CEapType::IsDisallowedOutsidePEAP( *iEapArray[count] ) )
|
|
245 |
{
|
|
246 |
// Delete the EAP type, which isn't allowed outside PEAP,
|
|
247 |
// from the array.
|
|
248 |
delete iEapArray[count];
|
|
249 |
iEapArray.Remove( count );
|
|
250 |
|
|
251 |
// One item removed from the array. So reduce the item count.
|
|
252 |
count--;
|
|
253 |
}
|
|
254 |
}
|
|
255 |
|
|
256 |
TInt numParams = params->Count();
|
|
257 |
TBool foundDefaultEAPTypes = EFalse;
|
|
258 |
|
|
259 |
// Rearrange the array so that EAP-SIM and EAP-AKA are on top, in that order.
|
|
260 |
|
|
261 |
// The rearrange is needed only for the first time creation.
|
|
262 |
if ( numParams == 0 )
|
|
263 |
{
|
|
264 |
TInt topPos = 0; // position in the beginning of arrary.
|
|
265 |
TInt error( KErrNone );
|
|
266 |
|
|
267 |
// First move EAP-AKA to top, if it is present in the array.
|
|
268 |
error = MoveEAPType( EAPSettings::EEapAka, topPos );
|
|
269 |
|
|
270 |
if ( error != KErrNotFound )
|
|
271 |
{
|
|
272 |
// Found EAP-AKA in the array.
|
|
273 |
// Doesn't matter if the move was a success or not.
|
|
274 |
foundDefaultEAPTypes = ETrue;
|
|
275 |
}
|
|
276 |
|
|
277 |
// Now move EAP-SIM to top.
|
|
278 |
// EAP-SIM will be always the top most if it is present in the array.
|
|
279 |
// Otherwise EAP-AKA stays in the top, if it is present.
|
|
280 |
// The order doesn't matter if these two are not present.
|
|
281 |
MoveEAPType( EAPSettings::EEapSim, topPos );
|
|
282 |
|
|
283 |
if( error != KErrNotFound)
|
|
284 |
{
|
|
285 |
// Found EAP-SIM in the array.
|
|
286 |
// Doesn't matter if the move was a success.
|
|
287 |
foundDefaultEAPTypes = ETrue;
|
|
288 |
}
|
|
289 |
}
|
|
290 |
|
|
291 |
TInt i;
|
|
292 |
TInt j;
|
|
293 |
TInt numInfoStore = iEapArray.Count();
|
|
294 |
TInt eapUid;
|
|
295 |
|
|
296 |
// just to make sure we are not given a non-empty but fully disabled list
|
|
297 |
TBool gotEnabled = EFalse;
|
|
298 |
|
|
299 |
CArrayFix<TInt>* usedImplInfo = new( ELeave ) CArrayFixFlat<TInt>( 4 );
|
|
300 |
CleanupStack::PushL( usedImplInfo );
|
|
301 |
usedImplInfo->AppendL( 0, numInfoStore );
|
|
302 |
|
|
303 |
for ( j = 0; j < numParams; j++ )
|
|
304 |
{
|
|
305 |
TLex lexUid( params->At( j ) );
|
|
306 |
if ( lexUid.Val( eapUid ) == KErrNone )
|
|
307 |
{
|
|
308 |
for ( i = 0; i < numInfoStore; i++ )
|
|
309 |
{
|
|
310 |
TLex8 lexDataType( iEapArray[i]->DataType() );
|
|
311 |
TInt implUID;
|
|
312 |
|
|
313 |
if ( lexDataType.Val( implUID ) == KErrNone )
|
|
314 |
{
|
|
315 |
if ( implUID == Abs( eapUid ) )
|
|
316 |
{
|
|
317 |
usedImplInfo->InsertL( i, 1 );
|
|
318 |
if ( i+1 < usedImplInfo->Count() )
|
|
319 |
{
|
|
320 |
usedImplInfo->Delete( i+1 );
|
|
321 |
}
|
|
322 |
|
|
323 |
TEAPPluginInfo plugin;
|
|
324 |
plugin.iInfo = iEapArray[i];
|
|
325 |
|
|
326 |
plugin.iEnabled = ( eapUid > 0 ||
|
|
327 |
( eapUid == 0 &&
|
|
328 |
params->At( j ).Left( 1 ) == KPlusSign ) );
|
|
329 |
User::LeaveIfError( aPlugins.Append( plugin ) );
|
|
330 |
gotEnabled = gotEnabled || plugin.iEnabled;
|
|
331 |
i = numInfoStore; // to exit from cycle
|
|
332 |
}
|
|
333 |
}
|
|
334 |
}
|
|
335 |
}
|
|
336 |
}
|
|
337 |
|
|
338 |
for ( i = 0; i < numInfoStore; i++ )
|
|
339 |
{
|
|
340 |
if ( !usedImplInfo->At( i ) )
|
|
341 |
{
|
|
342 |
TEAPPluginInfo plugin;
|
|
343 |
plugin.iInfo = iEapArray[i];
|
|
344 |
|
|
345 |
// Default is enabled.
|
|
346 |
// There should not be a case of all EAP types disabled.
|
|
347 |
TBool defaultEnableValue( ETrue );
|
|
348 |
|
|
349 |
if ( numParams > 0 && gotEnabled)
|
|
350 |
{
|
|
351 |
// If there some EAP types which are already enabled/disabled,
|
|
352 |
// we make the new EAP types disabled.
|
|
353 |
defaultEnableValue = EFalse;
|
|
354 |
}
|
|
355 |
else
|
|
356 |
{
|
|
357 |
// Nothing in the string or all disabled.
|
|
358 |
// Should be the first time execution (creating new IAP).
|
|
359 |
// Only EAP-SIM and EAP-AKA are enabled in this case.
|
|
360 |
TLex8 lexDataType( iEapArray[i]->DataType() );
|
|
361 |
TInt implDataType;
|
|
362 |
|
|
363 |
if ( lexDataType.Val( implDataType ) == KErrNone )
|
|
364 |
{
|
|
365 |
if( foundDefaultEAPTypes )
|
|
366 |
{
|
|
367 |
defaultEnableValue =
|
|
368 |
( implDataType == EAPSettings::EEapSim ||
|
|
369 |
implDataType == EAPSettings::EEapAka );
|
|
370 |
}
|
|
371 |
else
|
|
372 |
{
|
|
373 |
// No default EAPs (No EAP-SIM and EAP-AKA).
|
|
374 |
// So all EAP types are enabled by default.
|
|
375 |
defaultEnableValue = ETrue;
|
|
376 |
}
|
|
377 |
}
|
|
378 |
}
|
|
379 |
|
|
380 |
plugin.iEnabled = defaultEnableValue;
|
|
381 |
User::LeaveIfError( aPlugins.Append( plugin ) );
|
|
382 |
}
|
|
383 |
}
|
|
384 |
|
|
385 |
CleanupStack::PopAndDestroy( 2, params ); // usedImplInfo, params
|
|
386 |
}
|
|
387 |
|
|
388 |
|
|
389 |
// ---------------------------------------------------------
|
|
390 |
// CEAPPluginConfiguration::LoadPluginInfoL
|
|
391 |
// ---------------------------------------------------------
|
|
392 |
//
|
|
393 |
void CEAPPluginConfiguration::LoadPluginInfoL( TDes8& aWPAEnabledEAPPlugin,
|
|
394 |
TDes8& aWPADisabledEAPPlugin,
|
|
395 |
REAPPluginList& aPlugins )
|
|
396 |
{
|
|
397 |
// size of aWPAEnabledEAPPlugin and aWPADisabledEAPPlugin must be
|
|
398 |
// divisible by KLengthOfExpEapType
|
|
399 |
__ASSERT_DEBUG( ( aWPAEnabledEAPPlugin.Size() % KLengthOfExpEapType == 0 ),
|
|
400 |
User::Panic( _L( "aWPAEnabledEAPPlugin is corrupted!" ), KErrCorrupt ) );
|
|
401 |
|
|
402 |
__ASSERT_DEBUG( ( aWPADisabledEAPPlugin.Size() % KLengthOfExpEapType == 0 ),
|
|
403 |
User::Panic( _L( "aWPADisabledEAPPlugin is corrupted!" ), KErrCorrupt ) );
|
|
404 |
|
|
405 |
|
|
406 |
aPlugins.Reset(); // Reset this first: dependent on iEapArray.
|
|
407 |
iEapArray.ResetAndDestroy();
|
|
408 |
REComSession::ListImplementationsL( KEapTypeInterfaceUid, iEapArray );
|
|
409 |
|
|
410 |
// EAP plugin interface dialog should show only the EAP types that allowed
|
|
411 |
// outside PEAP.
|
|
412 |
|
|
413 |
for( TInt count = 0; count < iEapArray.Count(); count++ )
|
|
414 |
{
|
|
415 |
// Filter out the EAP types which are NOT allowed outside PEAP.
|
|
416 |
if( CEapType::IsDisallowedOutsidePEAP( *iEapArray[count] ) )
|
|
417 |
{
|
|
418 |
// Delete the EAP type, which isn't allowed outside PEAP,
|
|
419 |
// from the array.
|
|
420 |
delete iEapArray[count];
|
|
421 |
iEapArray.Remove( count );
|
|
422 |
|
|
423 |
// One item removed from the array. So reduce the item count.
|
|
424 |
count--;
|
|
425 |
}
|
|
426 |
}
|
|
427 |
|
|
428 |
TInt numEnabled = aWPAEnabledEAPPlugin.Size() / KLengthOfExpEapType;
|
|
429 |
TInt numDisabled = aWPADisabledEAPPlugin.Size() / KLengthOfExpEapType;
|
|
430 |
TBool foundDefaultEAPTypes = EFalse;
|
|
431 |
|
|
432 |
// Rearrange the array so that EAP-SIM and EAP-AKA are on top, in that order.
|
|
433 |
|
|
434 |
// The rearrange is needed only for the first time creation.
|
|
435 |
if ( !( numEnabled || numDisabled ) )
|
|
436 |
{
|
|
437 |
TInt topPos = 0; // position in the beginning of array.
|
|
438 |
TInt error( KErrNone );
|
|
439 |
|
|
440 |
// First move EAP-AKA to top, if it is present in the array.
|
|
441 |
_LIT8( KExpEapTypeFormat, "\xFE\0\0\0%c%c%c%c" );
|
|
442 |
TBuf8<KLengthOfExpEapType> tmpEap;
|
|
443 |
|
|
444 |
// BigEndian::Put32( const_cast<TUint8*>( tmpEap.Ptr() ) + 4,
|
|
445 |
// EAPSettings::EEapAka );
|
|
446 |
tmpEap.Format( KExpEapTypeFormat, ( EAPSettings::EEapAka >> 24 ) & 0xff,
|
|
447 |
( EAPSettings::EEapAka >> 16 ) & 0xff,
|
|
448 |
( EAPSettings::EEapAka >> 8 ) & 0xff,
|
|
449 |
EAPSettings::EEapAka & 0xff );
|
|
450 |
|
|
451 |
error = MoveEAPType( tmpEap, topPos );
|
|
452 |
|
|
453 |
if ( error != KErrNotFound )
|
|
454 |
{
|
|
455 |
// Found EAP-AKA in the array.
|
|
456 |
// Doesn't matter if the move was a success or not.
|
|
457 |
foundDefaultEAPTypes = ETrue;
|
|
458 |
}
|
|
459 |
|
|
460 |
// Now move EAP-SIM to top.
|
|
461 |
// EAP-SIM will be always the top most if it is present in the array.
|
|
462 |
// Otherwise EAP-AKA stays in the top, if it is present.
|
|
463 |
// The order doesn't matter if these two are not present.
|
|
464 |
// BigEndian::Put32( const_cast<TUint8*>( tmpEap.Ptr() ) + 4,
|
|
465 |
// EAPSettings::EEapSim );
|
|
466 |
tmpEap.Format( KExpEapTypeFormat, ( EAPSettings::EEapSim >> 24 ) & 0xff,
|
|
467 |
( EAPSettings::EEapSim >> 16 ) & 0xff,
|
|
468 |
( EAPSettings::EEapSim >> 8 ) & 0xff,
|
|
469 |
EAPSettings::EEapSim & 0xff );
|
|
470 |
|
|
471 |
error = MoveEAPType( tmpEap, topPos );
|
|
472 |
|
|
473 |
if( error != KErrNotFound)
|
|
474 |
{
|
|
475 |
// Found EAP-SIM in the array.
|
|
476 |
// Doesn't matter if the move was a success.
|
|
477 |
foundDefaultEAPTypes = ETrue;
|
|
478 |
}
|
|
479 |
}
|
|
480 |
|
|
481 |
TInt i;
|
|
482 |
TInt j;
|
|
483 |
TInt numInfoStore = iEapArray.Count();
|
|
484 |
|
|
485 |
CArrayFix<TInt>* usedImplInfo = new( ELeave ) CArrayFixFlat<TInt>( 4 );
|
|
486 |
CleanupStack::PushL( usedImplInfo );
|
|
487 |
|
|
488 |
usedImplInfo->AppendL( 0, numInfoStore );
|
|
489 |
|
|
490 |
// deal with the enabled first
|
|
491 |
for ( j = 0; j < numEnabled; j++ )
|
|
492 |
{
|
|
493 |
TPtrC8 param( aWPAEnabledEAPPlugin.Ptr() + KLengthOfExpEapType * j,
|
|
494 |
KLengthOfExpEapType );
|
|
495 |
|
|
496 |
for ( i = 0; i < numInfoStore; i++ )
|
|
497 |
{
|
|
498 |
if ( !param.Compare( iEapArray[i]->DataType() ) )
|
|
499 |
{
|
|
500 |
usedImplInfo->InsertL( i, 1 );
|
|
501 |
if ( i+1 < usedImplInfo->Count() )
|
|
502 |
{
|
|
503 |
usedImplInfo->Delete( i+1 );
|
|
504 |
}
|
|
505 |
|
|
506 |
TEAPPluginInfo plugin;
|
|
507 |
plugin.iInfo = iEapArray[i];
|
|
508 |
plugin.iEnabled = ETrue;
|
|
509 |
|
|
510 |
User::LeaveIfError( aPlugins.Append( plugin ) );
|
|
511 |
i = numInfoStore; // to exit from cycle
|
|
512 |
}
|
|
513 |
}
|
|
514 |
}
|
|
515 |
|
|
516 |
|
|
517 |
// now come the disabled
|
|
518 |
for ( j = 0; j < numDisabled; j++ )
|
|
519 |
{
|
|
520 |
TPtrC8 param( aWPADisabledEAPPlugin.Ptr() + KLengthOfExpEapType * j,
|
|
521 |
KLengthOfExpEapType );
|
|
522 |
|
|
523 |
for ( i = 0; i < numInfoStore; i++ )
|
|
524 |
{
|
|
525 |
if ( !param.Compare( iEapArray[i]->DataType() ) )
|
|
526 |
{
|
|
527 |
usedImplInfo->InsertL( i, 1 );
|
|
528 |
if ( i+1 < usedImplInfo->Count() )
|
|
529 |
{
|
|
530 |
usedImplInfo->Delete( i+1 );
|
|
531 |
}
|
|
532 |
|
|
533 |
TEAPPluginInfo plugin;
|
|
534 |
plugin.iInfo = iEapArray[i];
|
|
535 |
plugin.iEnabled = EFalse;
|
|
536 |
|
|
537 |
User::LeaveIfError( aPlugins.Append( plugin ) );
|
|
538 |
i = numInfoStore; // to exit from cycle
|
|
539 |
}
|
|
540 |
}
|
|
541 |
}
|
|
542 |
|
|
543 |
|
|
544 |
for ( i = 0; i < numInfoStore; i++ )
|
|
545 |
{
|
|
546 |
if ( !usedImplInfo->At( i ) )
|
|
547 |
{
|
|
548 |
TEAPPluginInfo plugin;
|
|
549 |
plugin.iInfo = iEapArray[i];
|
|
550 |
|
|
551 |
// Default is enabled.
|
|
552 |
// There should not be a case of all EAP types disabled.
|
|
553 |
TBool defaultEnableValue( ETrue );
|
|
554 |
|
|
555 |
if ( numEnabled > 0 )
|
|
556 |
{
|
|
557 |
// If there some EAP types which are already enabled/disabled,
|
|
558 |
// we make the new EAP types disabled.
|
|
559 |
defaultEnableValue = EFalse;
|
|
560 |
}
|
|
561 |
else
|
|
562 |
{
|
|
563 |
// No EAP types enabled.
|
|
564 |
// Should be the first time execution (creating new IAP).
|
|
565 |
// Only EAP-SIM and EAP-AKA are enabled in this case.
|
|
566 |
|
|
567 |
// [FE] [00 00 00] [TEapType_bigendian]
|
|
568 |
const TDesC8& cue = iEapArray[i]->DataType();
|
|
569 |
|
|
570 |
TPtrC8 eapType( cue.Ptr() + 4, 4 );
|
|
571 |
TUint32 implDataType = ( eapType[0] << 24 ) |
|
|
572 |
( eapType[1] << 16 ) |
|
|
573 |
( eapType[2] << 8 ) |
|
|
574 |
eapType[3];
|
|
575 |
|
|
576 |
if( foundDefaultEAPTypes )
|
|
577 |
{
|
|
578 |
_LIT8( KExpEapFirstQuad, "\xFE\0\0\0" );
|
|
579 |
TPtrC8 firstQuad( cue.Ptr(), 4 );
|
|
580 |
|
|
581 |
defaultEnableValue =
|
|
582 |
( !firstQuad.Compare ( KExpEapFirstQuad ) &&
|
|
583 |
( implDataType == EAPSettings::EEapSim ||
|
|
584 |
implDataType == EAPSettings::EEapAka ) );
|
|
585 |
}
|
|
586 |
else
|
|
587 |
{
|
|
588 |
// No default EAPs (No EAP-SIM and EAP-AKA).
|
|
589 |
// So all EAP types are enabled by default.
|
|
590 |
defaultEnableValue = ETrue;
|
|
591 |
}
|
|
592 |
}
|
|
593 |
|
|
594 |
plugin.iEnabled = defaultEnableValue;
|
|
595 |
User::LeaveIfError( aPlugins.Append( plugin ) );
|
|
596 |
}
|
|
597 |
}
|
|
598 |
CleanupStack::PopAndDestroy( usedImplInfo );
|
|
599 |
|
|
600 |
}
|
|
601 |
|
|
602 |
|
|
603 |
// ---------------------------------------------------------
|
|
604 |
// CEAPPluginConfiguration::SavePluginInfoL
|
|
605 |
// ---------------------------------------------------------
|
|
606 |
//
|
|
607 |
void CEAPPluginConfiguration::SavePluginInfoL( TDes& aWPAEAPPlugin,
|
|
608 |
REAPPluginList& aPlugins )
|
|
609 |
{
|
|
610 |
aWPAEAPPlugin.Zero();
|
|
611 |
for ( TInt index = 0; index < aPlugins.Count(); index++ )
|
|
612 |
{
|
|
613 |
TBuf8<KLengthOfImplUid> cue = aPlugins[index].iInfo->DataType();
|
|
614 |
|
|
615 |
TLex8 lexDataType( cue );
|
|
616 |
TInt implUID;
|
|
617 |
if ( lexDataType.Val( implUID ) == KErrNone )
|
|
618 |
{
|
|
619 |
if ( aPlugins[index].iEnabled )
|
|
620 |
{
|
|
621 |
aWPAEAPPlugin.Append( KPlusSign );
|
|
622 |
}
|
|
623 |
else
|
|
624 |
{
|
|
625 |
aWPAEAPPlugin.Append( KMinusSign );
|
|
626 |
}
|
|
627 |
|
|
628 |
aWPAEAPPlugin.AppendNumFixedWidth( implUID, EDecimal,
|
|
629 |
KLengthOfImplUid );
|
|
630 |
|
|
631 |
if ( index != aPlugins.Count()-1 )
|
|
632 |
{
|
|
633 |
aWPAEAPPlugin.Append( KComma );
|
|
634 |
}
|
|
635 |
}
|
|
636 |
}
|
|
637 |
}
|
|
638 |
|
|
639 |
|
|
640 |
// ---------------------------------------------------------
|
|
641 |
// CEAPPluginConfiguration::SavePluginInfoL
|
|
642 |
// ---------------------------------------------------------
|
|
643 |
//
|
|
644 |
void CEAPPluginConfiguration::SavePluginInfoL( TDes8& aWPAEnabledEAPPlugin,
|
|
645 |
TDes8& aWPADisabledEAPPlugin,
|
|
646 |
REAPPluginList& aPlugins )
|
|
647 |
{
|
|
648 |
aWPAEnabledEAPPlugin.Zero();
|
|
649 |
aWPADisabledEAPPlugin.Zero();
|
|
650 |
|
|
651 |
for ( TInt index = 0; index < aPlugins.Count(); index++ )
|
|
652 |
{
|
|
653 |
if ( aPlugins[index].iEnabled )
|
|
654 |
{
|
|
655 |
aWPAEnabledEAPPlugin.Append( aPlugins[index].iInfo->DataType() );
|
|
656 |
}
|
|
657 |
else
|
|
658 |
{
|
|
659 |
aWPADisabledEAPPlugin.Append( aPlugins[index].iInfo->DataType() );
|
|
660 |
}
|
|
661 |
}
|
|
662 |
|
|
663 |
}
|
|
664 |
|
|
665 |
|
|
666 |
// ---------------------------------------------------------
|
|
667 |
// CEAPPluginConfiguration::ShowEAPTypeInfo
|
|
668 |
// ---------------------------------------------------------
|
|
669 |
//
|
|
670 |
void CEAPPluginConfiguration::ShowEAPTypeInfo()
|
|
671 |
{
|
|
672 |
|
|
673 |
}
|
|
674 |
|
|
675 |
|
|
676 |
// ---------------------------------------------------------
|
|
677 |
// CEAPPluginConfiguration::DeleteSettingsL
|
|
678 |
// ---------------------------------------------------------
|
|
679 |
//
|
|
680 |
void CEAPPluginConfiguration::DeleteSettingsL( const TUint32 aIapID )
|
|
681 |
{
|
|
682 |
iEapArray.ResetAndDestroy();
|
|
683 |
REComSession::ListImplementationsL( KEapTypeInterfaceUid, iEapArray );
|
|
684 |
|
|
685 |
for ( TInt i = 0; i < iEapArray.Count(); i++ )
|
|
686 |
{
|
|
687 |
if ( !CEapType::IsDisallowedOutsidePEAP( *iEapArray[i] ) )
|
|
688 |
{
|
|
689 |
CEapType* eapType = CEapType::NewL( iEapArray[i]->DataType(),
|
|
690 |
ELan,
|
|
691 |
aIapID );
|
|
692 |
CleanupStack::PushL( eapType );
|
|
693 |
|
|
694 |
eapType->DeleteConfigurationL();
|
|
695 |
CleanupStack::PopAndDestroy( eapType );
|
|
696 |
}
|
|
697 |
}
|
|
698 |
}
|
|
699 |
|
|
700 |
|
|
701 |
// ---------------------------------------------------------
|
|
702 |
// CEAPPluginConfiguration::ChangeIapIDL
|
|
703 |
// ---------------------------------------------------------
|
|
704 |
//
|
|
705 |
void CEAPPluginConfiguration::ChangeIapIDL( const TUint32 aOldIapID,
|
|
706 |
const TUint32 aNewIapID )
|
|
707 |
{
|
|
708 |
iEapArray.ResetAndDestroy();
|
|
709 |
REComSession::ListImplementationsL( KEapTypeInterfaceUid, iEapArray );
|
|
710 |
|
|
711 |
for ( TInt i = 0; i < iEapArray.Count(); i++ )
|
|
712 |
{
|
|
713 |
if ( !CEapType::IsDisallowedOutsidePEAP( *iEapArray[i] ) )
|
|
714 |
{
|
|
715 |
CEapType* eapType = CEapType::NewL( iEapArray[i]->DataType(),
|
|
716 |
ELan,
|
|
717 |
aOldIapID );
|
|
718 |
CleanupStack::PushL( eapType );
|
|
719 |
|
|
720 |
eapType->SetIndexL( ELan, aNewIapID );
|
|
721 |
CleanupStack::PopAndDestroy( eapType );
|
|
722 |
}
|
|
723 |
}
|
|
724 |
}
|
|
725 |
|
|
726 |
// ---------------------------------------------------------
|
|
727 |
// CEAPPluginConfiguration::CopySettingsL
|
|
728 |
// ---------------------------------------------------------
|
|
729 |
//
|
|
730 |
void CEAPPluginConfiguration::CopySettingsL( const TUint32 aSourceIapID,
|
|
731 |
const TUint32 aDestinationIapID )
|
|
732 |
{
|
|
733 |
iEapArray.ResetAndDestroy();
|
|
734 |
REComSession::ListImplementationsL( KEapTypeInterfaceUid, iEapArray );
|
|
735 |
|
|
736 |
for ( TInt i = 0; i < iEapArray.Count(); i++ )
|
|
737 |
{
|
|
738 |
if ( !CEapType::IsDisallowedOutsidePEAP( *iEapArray[i] ) )
|
|
739 |
{
|
|
740 |
CEapType* eapType = CEapType::NewL( iEapArray[i]->DataType(),
|
|
741 |
ELan,
|
|
742 |
aSourceIapID );
|
|
743 |
CleanupStack::PushL( eapType );
|
|
744 |
|
|
745 |
eapType->CopySettingsL( ELan, aDestinationIapID );
|
|
746 |
CleanupStack::PopAndDestroy( eapType );
|
|
747 |
}
|
|
748 |
}
|
|
749 |
}
|
|
750 |
|
|
751 |
|
|
752 |
// ---------------------------------------------------------
|
|
753 |
// CEAPPluginConfiguration::MoveEAPType
|
|
754 |
// ---------------------------------------------------------
|
|
755 |
//
|
|
756 |
TInt CEAPPluginConfiguration::MoveEAPType( EAPSettings::TEapType aEapType,
|
|
757 |
TInt aPos )
|
|
758 |
{
|
|
759 |
TInt error( KErrNotFound );
|
|
760 |
|
|
761 |
// Parse the array to find out the desired EAP type.
|
|
762 |
for( TInt count = 0; count < iEapArray.Count(); count++ )
|
|
763 |
{
|
|
764 |
TLex8 lexDataType( iEapArray[count]->DataType() );
|
|
765 |
TInt implDataType;
|
|
766 |
|
|
767 |
if ( lexDataType.Val( implDataType ) == KErrNone )
|
|
768 |
{
|
|
769 |
if ( implDataType == aEapType )
|
|
770 |
{
|
|
771 |
// Move this to the required destination.
|
|
772 |
error = iEapArray.Insert( iEapArray[count], aPos );
|
|
773 |
|
|
774 |
if( KErrNone == error )
|
|
775 |
{
|
|
776 |
// Delete the old entry. It should be one count up now.
|
|
777 |
iEapArray.Remove( count+1 );
|
|
778 |
}
|
|
779 |
else
|
|
780 |
{
|
|
781 |
// Some problem. Couldn't move.
|
|
782 |
error = KErrUnknown;
|
|
783 |
}
|
|
784 |
|
|
785 |
// No need to parse further in the array.
|
|
786 |
// We found the needed EAP type.
|
|
787 |
break;
|
|
788 |
}
|
|
789 |
}
|
|
790 |
else
|
|
791 |
{
|
|
792 |
error = KErrGeneral;
|
|
793 |
}
|
|
794 |
}
|
|
795 |
|
|
796 |
return error;
|
|
797 |
}
|
|
798 |
|
|
799 |
|
|
800 |
// ---------------------------------------------------------
|
|
801 |
// CEAPPluginConfiguration::MoveEAPType
|
|
802 |
// ---------------------------------------------------------
|
|
803 |
//
|
|
804 |
TInt CEAPPluginConfiguration::MoveEAPType( const TDesC8& aEapType, TInt aPos )
|
|
805 |
{
|
|
806 |
TInt error( KErrNotFound );
|
|
807 |
|
|
808 |
// Parse the array to find out the desired EAP type.
|
|
809 |
for( TInt count = 0; count < iEapArray.Count(); count++ )
|
|
810 |
{
|
|
811 |
if ( !iEapArray[count]->DataType().Compare( aEapType ) )
|
|
812 |
{
|
|
813 |
// Move this to the required destination.
|
|
814 |
error = iEapArray.Insert( iEapArray[count], aPos );
|
|
815 |
|
|
816 |
if( KErrNone == error )
|
|
817 |
{
|
|
818 |
// Delete the old entry. It should be one count up now.
|
|
819 |
iEapArray.Remove( count+1 );
|
|
820 |
}
|
|
821 |
else
|
|
822 |
{
|
|
823 |
// Some problem. Couldn't move.
|
|
824 |
error = KErrUnknown;
|
|
825 |
}
|
|
826 |
|
|
827 |
// No need to parse further in the array.
|
|
828 |
// We found the needed EAP type.
|
|
829 |
break;
|
|
830 |
}
|
|
831 |
}
|
|
832 |
|
|
833 |
return error;
|
|
834 |
}
|
|
835 |
|
|
836 |
// End of file.
|