eapol/eapol_framework/eapol_symbian/eap_server/src/eap_am_general_settings_symbian.cpp
branchRCL_3
changeset 46 c74b3d9f6b9e
parent 45 bad0cc58d154
child 55 9c2aa05919d9
equal deleted inserted replaced
45:bad0cc58d154 46:c74b3d9f6b9e
     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 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:  EAP general settings configuration.
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 60 %
       
    20 */
       
    21 
       
    22 #include "eap_tools.h"
       
    23 #include "eap_status.h"
       
    24 #include "eap_am_export.h"
       
    25 #include "eap_expanded_type.h"
       
    26 #include "eap_array.h"
       
    27 #include "eap_database_reference_if.h"
       
    28 #include "eap_am_general_settings_symbian.h"
       
    29 #include "abs_eap_am_general_settings.h"
       
    30 #include "eap_automatic_variable.h"
       
    31 #include "EapTraceSymbian.h"
       
    32 #include "EapConversion.h"
       
    33 #include "EapTlsPeapCertFetcher.h"
       
    34 #include "EapPluginTools.h"
       
    35 #include <EapTypePlugin.h>
       
    36 #include "EapAutomatic.h"
       
    37 
       
    38 /** @file */
       
    39 
       
    40 // ----------------------------------------------------------------------
       
    41 
       
    42 EAP_LITERAL_SYMBIAN(KGeneralsettingsDatabaseName, "eap_methods.dat");
       
    43 
       
    44 EAP_LITERAL_SYMBIAN(KGeneralSettingsTableName, "eap_general_settings");
       
    45 
       
    46 _LIT(KEapMethodEnabledValue, "enabled");
       
    47 _LIT(KEapMethodDisabledValue, "disabled");
       
    48 
       
    49 _LIT(KServiceType, "service_type");
       
    50 _LIT(KServiceIndex, "service_index");
       
    51 
       
    52 _LIT(KSQL, "SELECT %S, %S, %S, %S FROM %S WHERE %S=%d AND %S=%d");
       
    53 
       
    54 const TUint KMaxSqlQueryLength = 512;
       
    55 const TInt	KDefaultColumnInView_One = 4; // For DB view.
       
    56 
       
    57 // ----------------------------------------------------------------------
       
    58 
       
    59 eap_am_general_settings_symbian_c::eap_am_general_settings_symbian_c(
       
    60 	abs_eap_am_tools_c * const tools,
       
    61 	abs_eap_am_general_settings_c * const partner)
       
    62 	: m_am_tools(tools)
       
    63 	, m_partner(partner)
       
    64 	, m_is_valid(false)
       
    65 	, m_shutdown_was_called(false)
       
    66 	, iGeneralSettingsDbCreated(EFalse)
       
    67 	, iGeneralSettingsSessionOpened(EFalse)
       
    68 	, iCertificateFetcher(0)
       
    69 	, m_completion_status(eap_status_process_general_error)
       
    70 	, m_EAPType(eap_type_none)
       
    71 	, m_IndexType(0ul)
       
    72 	, m_Index(0ul)
       
    73 {
       
    74 	if (m_am_tools == 0
       
    75 		|| m_am_tools->get_is_valid() == false
       
    76 		|| m_partner == 0)
       
    77 	{
       
    78 		return;
       
    79 	}
       
    80 
       
    81 	m_is_valid = true;
       
    82 
       
    83 	EAP_TRACE_DEBUG(
       
    84 		m_am_tools,
       
    85 		TRACE_FLAGS_DEFAULT,
       
    86 		(EAPL("eap_am_general_settings_symbian_c::eap_am_general_settings_symbian_c(): this=0x%08x.\n"),
       
    87 		this));
       
    88 }
       
    89 
       
    90 // ----------------------------------------------------------------------
       
    91 
       
    92 eap_am_general_settings_symbian_c::eap_am_general_settings_symbian_c(
       
    93 	abs_eap_am_tools_c * const tools)
       
    94 	: m_am_tools(tools)
       
    95 	, m_partner(0)
       
    96 	, m_is_valid(false)
       
    97 	, m_shutdown_was_called(false)
       
    98 	, iGeneralSettingsDbCreated(EFalse)
       
    99 	, iGeneralSettingsSessionOpened(EFalse)
       
   100 	, iCertificateFetcher(0)
       
   101 	, m_completion_status(eap_status_process_general_error)
       
   102 	, m_EAPType(eap_type_none)
       
   103 	, m_IndexType(0ul)
       
   104 	, m_Index(0ul)
       
   105 {
       
   106 	if (m_am_tools == 0
       
   107 		|| m_am_tools->get_is_valid() == false)
       
   108 	{
       
   109 		return;
       
   110 	}
       
   111 
       
   112 	m_is_valid = true;
       
   113 
       
   114 	EAP_TRACE_DEBUG(
       
   115 		m_am_tools,
       
   116 		TRACE_FLAGS_DEFAULT,
       
   117 		(EAPL("eap_am_general_settings_symbian_c::eap_am_general_settings_symbian_c(): this=0x%08x.\n"),
       
   118 		this));
       
   119 }
       
   120 
       
   121 // ----------------------------------------------------------------------
       
   122 
       
   123 eap_am_general_settings_symbian_c::~eap_am_general_settings_symbian_c()
       
   124 {
       
   125 	EAP_TRACE_DEBUG(
       
   126 		m_am_tools,
       
   127 		TRACE_FLAGS_DEFAULT,
       
   128 		(EAPL("eap_am_general_settings_symbian_c::~eap_am_general_settings_symbian_c(): this=0x%08x.\n"),
       
   129 		this));
       
   130 
       
   131 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_general_settings_symbian_c::~eap_am_general_settings_symbian_c()");
       
   132 
       
   133 	EAP_UNREFERENCED_PARAMETER(KGeneralsettingsDatabaseName_8bit);
       
   134 
       
   135 	EAP_UNREFERENCED_PARAMETER(KGeneralSettingsTableName_8bit);
       
   136 
       
   137 	CloseGeneralSettings();
       
   138 
       
   139 	delete iCertificateFetcher;
       
   140 	iCertificateFetcher = 0;
       
   141 
       
   142 	EAP_ASSERT(m_shutdown_was_called == true);
       
   143 }
       
   144 
       
   145 // ----------------------------------------------------------------------
       
   146 
       
   147 bool eap_am_general_settings_symbian_c::get_is_valid()
       
   148 {
       
   149 	EAP_TRACE_DEBUG(
       
   150 		m_am_tools,
       
   151 		TRACE_FLAGS_DEFAULT,
       
   152 		(EAPL("eap_am_general_settings_symbian_c::get_is_valid(): this=0x%08x, m_is_valid=%d.\n"),
       
   153 		this,
       
   154 		m_is_valid));
       
   155 
       
   156 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_general_settings_symbian_c::get_is_valid()");
       
   157 
       
   158 	return m_is_valid;
       
   159 }
       
   160 
       
   161 // ----------------------------------------------------------------------
       
   162 
       
   163 // This is documented in abs_eap_stack_interface_c::configure().
       
   164 eap_status_e eap_am_general_settings_symbian_c::configure()
       
   165 {
       
   166 	EAP_TRACE_DEBUG(
       
   167 		m_am_tools,
       
   168 		TRACE_FLAGS_DEFAULT,
       
   169 		(EAPL("eap_am_general_settings_symbian_c::configure(): this=0x%08x.\n"),
       
   170 		this));
       
   171 
       
   172 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_general_settings_symbian_c::configure()");
       
   173 
       
   174 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   175 }
       
   176 
       
   177 // ----------------------------------------------------------------------
       
   178 
       
   179 // This is documented in abs_eap_stack_interface_c::shutdown().
       
   180 eap_status_e eap_am_general_settings_symbian_c::shutdown()
       
   181 {
       
   182 	EAP_TRACE_DEBUG(
       
   183 		m_am_tools,
       
   184 		TRACE_FLAGS_DEFAULT,
       
   185 		(EAPL("eap_am_general_settings_symbian_c::shutdown(): this=0x%08x.\n"),
       
   186 		this));
       
   187 
       
   188 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_general_settings_symbian_c::shutdown()");
       
   189 
       
   190 	m_shutdown_was_called = true;
       
   191 
       
   192 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   193 }
       
   194 
       
   195 // ----------------------------------------------------------------------
       
   196 
       
   197 void eap_am_general_settings_symbian_c::CloseGeneralSettings()
       
   198 {
       
   199 	EAP_TRACE_DEBUG(
       
   200 		m_am_tools,
       
   201 		TRACE_FLAGS_DEFAULT,
       
   202 		(EAPL("eap_am_general_settings_symbian_c::CloseGeneralSettings(): this=0x%08x.\n"),
       
   203 		this));
       
   204 
       
   205 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_general_settings_symbian_c::CloseGeneralSettings()");
       
   206 
       
   207 	iGeneralSettingsDb.Close();
       
   208 	iGeneralSettingsDbCreated = EFalse;
       
   209 
       
   210 	iGeneralSettingsFileServerSession.Close();
       
   211 	iGeneralSettingsSessionOpened = EFalse;
       
   212 }
       
   213 
       
   214 // ----------------------------------------------------------------------
       
   215 
       
   216 void eap_am_general_settings_symbian_c::OpenGeneralSettingsL()
       
   217 {
       
   218 	EAP_TRACE_DEBUG(
       
   219 		m_am_tools,
       
   220 		TRACE_FLAGS_DEFAULT,
       
   221 		(EAPL("eap_am_general_settings_symbian_c::OpenGeneralSettingsL(): this=0x%08x.\n"),
       
   222 		this));
       
   223 
       
   224 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_general_settings_symbian_c::OpenGeneralSettingsL()");
       
   225 
       
   226 	if(iGeneralSettingsDbCreated == EFalse
       
   227 		|| iGeneralSettingsSessionOpened == EFalse)
       
   228 	{
       
   229 		// The general settings store DB and tables are not created. So create it.
       
   230 		CreateGeneralSettingsL();
       
   231 	}
       
   232 }
       
   233 
       
   234 // ----------------------------------------------------------------------
       
   235 
       
   236 void eap_am_general_settings_symbian_c::CreateGeneralSettingsL()
       
   237 {
       
   238 	EAP_TRACE_DEBUG(
       
   239 		m_am_tools,
       
   240 		TRACE_FLAGS_DEFAULT,
       
   241 		(EAPL("eap_am_general_settings_symbian_c::CreateGeneralSettingsL(): this=0x%08x.\n"),
       
   242 		this));
       
   243 
       
   244 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_general_settings_symbian_c::CreateGeneralSettingsL()");
       
   245 
       
   246 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   247 
       
   248 	// 1. Open/create a database
       
   249 
       
   250 	TInt error(KErrNone);
       
   251 
       
   252 	// Connect to the DBMS server, if not connected already.
       
   253 	if(iGeneralSettingsSessionOpened == EFalse)
       
   254 	{
       
   255 		error = iGeneralSettingsFileServerSession.Connect();
       
   256 		(void)EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(error));
       
   257 		User::LeaveIfError(error);
       
   258 
       
   259 		iGeneralSettingsSessionOpened = ETrue;
       
   260 	}
       
   261 
       
   262 	TFileName aPrivateDatabasePathName;
       
   263 
       
   264 	EapPluginTools::CreateDatabaseLC(
       
   265 		iGeneralSettingsDb,
       
   266 		iGeneralSettingsFileServerSession,
       
   267 		error,
       
   268 		KGeneralsettingsDatabaseName,
       
   269 		aPrivateDatabasePathName);
       
   270 
       
   271 	EAP_TRACE_DEBUG(
       
   272 		m_am_tools,
       
   273 		TRACE_FLAGS_DEFAULT,
       
   274 		(EAPL("eap_am_general_settings_symbian_c::CreateGeneralSettingsL() - Created Secure DB for %S. error=%d (-11=DB already exist)\n"),
       
   275 		&KGeneralsettingsDatabaseName_8bit,
       
   276 		error) );
       
   277 
       
   278 	if(error == KErrNone)
       
   279 	{
       
   280 		// Database is closed if it was created in EapPluginTools::CreateDatabaseLC().
       
   281 		// If database exists it was not opened in EapPluginTools::CreateDatabaseLC().
       
   282 		iGeneralSettingsDb.Close();
       
   283 	}
       
   284 	else if (error != KErrAlreadyExists)
       
   285 	{
       
   286 		(void)EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(error));
       
   287 		User::LeaveIfError(error);
       
   288 	}
       
   289 
       
   290 	error = iGeneralSettingsDb.Open(iGeneralSettingsFileServerSession, aPrivateDatabasePathName);
       
   291 
       
   292 	EAP_TRACE_DEBUG(
       
   293 		m_am_tools,
       
   294 		TRACE_FLAGS_DEFAULT,
       
   295 		(EAPL("eap_am_general_settings_symbian_c::CreateGeneralSettingsL() - Open Secure DB for %S. error=%d (-11=DB already exist)\n"),
       
   296 		&KGeneralsettingsDatabaseName_8bit,
       
   297 		error) );
       
   298 
       
   299 	User::LeaveIfError(error);
       
   300 
       
   301 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   302 
       
   303 	// 2. Create the tables to database (ignore error if tables exist)
       
   304 
       
   305 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
       
   306 	TPtr sqlStatement = buf->Des();
       
   307 
       
   308 	// Create table for enabled and disabled EAP-types.
       
   309 
       
   310 	//// NAME //////////////////// TYPE ///////////// Constant ////////////////////
       
   311 	//| ServiceType				| UNSIGNED INTEGER | KServiceType				|//
       
   312 	//| ServiceIndex			| UNSIGNED INTEGER | KServiceIndex				|//
       
   313 	//| Enabled EAP-methods		| LONG VARBINARY   | KEapMethodEnabledValue		|//
       
   314 	//| Disabled EAP-methods	| LONG VARBINARY   | KEapMethodDisabledValue	|//
       
   315 	///////////////////////////////////////////////////////////////////////////////
       
   316 
       
   317 	_LIT(KSQLCreateTable2, "CREATE TABLE %S (%S UNSIGNED INTEGER, \
       
   318 		%S UNSIGNED INTEGER, \
       
   319 		%S LONG VARBINARY, \
       
   320 		%S LONG VARBINARY)");
       
   321 
       
   322 	sqlStatement.Format(
       
   323 		KSQLCreateTable2,
       
   324 		&KGeneralSettingsTableName,
       
   325 		&KServiceType,
       
   326 		&KServiceIndex,
       
   327 		&KEapMethodEnabledValue,
       
   328 		&KEapMethodDisabledValue);
       
   329 
       
   330 	EAP_TRACE_DEBUG(
       
   331 		m_am_tools,
       
   332 		TRACE_FLAGS_DEFAULT,
       
   333 		(EAPL("eap_am_general_settings_symbian_c::CreateGeneralSettingsL() - SQL query formated OK\n")));
       
   334 
       
   335 	error = iGeneralSettingsDb.Execute(sqlStatement);
       
   336 	if (error != KErrNone
       
   337 		&& error != KErrAlreadyExists)
       
   338 	{
       
   339 		(void)EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(error));
       
   340 		User::Leave(error);
       
   341 	}
       
   342 
       
   343 	EAP_TRACE_DEBUG(
       
   344 		m_am_tools,
       
   345 		TRACE_FLAGS_DEFAULT,
       
   346 		(EAPL("eap_am_general_settings_symbian_c::CreateGeneralSettingsL() Created Groups table\n")));
       
   347 
       
   348 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   349 
       
   350 	CleanupStack::PopAndDestroy( buf );
       
   351 	CleanupStack::Pop(&iGeneralSettingsDb);
       
   352 	CleanupStack::Pop(&iGeneralSettingsFileServerSession);
       
   353 
       
   354 	iGeneralSettingsDbCreated = ETrue;
       
   355 
       
   356 	EAP_TRACE_DEBUG(
       
   357 		m_am_tools,
       
   358 		TRACE_FLAGS_DEFAULT,
       
   359 		(EAPL("eap_am_general_settings_symbian_c::CreateGeneralSettingsL(): End \n")));	
       
   360 
       
   361 } // eap_am_general_settings_symbian_c::CreateGeneralSettingsL()
       
   362 
       
   363 // ----------------------------------------------------------------------
       
   364 
       
   365 void eap_am_general_settings_symbian_c::GetGeneralSettingsLongBinaryL(
       
   366 	RDbView &aViev,
       
   367 	const TDesC &aColName,
       
   368 	HBufC8** const aMethods)
       
   369 {
       
   370 	EAP_TRACE_DEBUG(
       
   371 		m_am_tools,
       
   372 		TRACE_FLAGS_DEFAULT,
       
   373 		(EAPL("eap_am_general_settings_symbian_c::GetGeneralSettingsLongBinaryL(): this=0x%08x.\n"),
       
   374 		this));
       
   375 
       
   376 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_general_settings_symbian_c::GetGeneralSettingsLongBinaryL()");
       
   377 
       
   378 	// Get column set so we get the correct column numbers
       
   379 	CDbColSet* colSet = aViev.ColSetL();
       
   380 	CleanupStack::PushL(colSet);
       
   381 
       
   382 	TDbColNo colNoReference = 0;
       
   383 	colNoReference = colSet->ColNo(aColName);
       
   384 
       
   385 	switch (aViev.ColType(colNoReference))
       
   386 	{
       
   387 		case EDbColLongBinary:
       
   388 		{
       
   389 			EAP_TRACE_DATA_DEBUG(
       
   390 				m_am_tools,
       
   391 				TRACE_FLAGS_DEFAULT,
       
   392 				(EAPL("eap_am_general_settings_symbian_c::GetGeneralSettingsLongBinaryL() - Long Binary column"),
       
   393 				aColName.Ptr(),
       
   394 				aColName.Size()));
       
   395 
       
   396 			// A stream is needed for LONG columns in DB.
       
   397 			RDbColReadStream readStream;
       
   398 
       
   399 			// Get the value from DB.
       
   400 			HBufC8* valueBuf = HBufC8::NewLC(aViev.ColLength(colNoReference)); // Buffer for the data.
       
   401 			TPtr8 value8 = valueBuf->Des();
       
   402 
       
   403 			readStream.OpenLC(aViev, colNoReference);
       
   404 			readStream.ReadL(value8, aViev.ColLength(colNoReference));
       
   405 			readStream.Close();
       
   406 			CleanupStack::PopAndDestroy(&readStream);
       
   407 
       
   408 			EAP_TRACE_DATA_DEBUG(
       
   409 				m_am_tools,
       
   410 				TRACE_FLAGS_DEFAULT,
       
   411 				(EAPL("eap_am_general_settings_symbian_c::GetGeneralSettingsLongBinaryL(): LONG BINARY value from DB"),
       
   412 				value8.Ptr(), 
       
   413 				value8.Size()));
       
   414 
       
   415 			*aMethods = HBufC8::New(value8.Size());
       
   416 
       
   417 			// This to avoid the use of clean up stack for output parameter.
       
   418 			if ((*aMethods) != 0)
       
   419 			{
       
   420 				TPtr8 aDbBinaryColumnValuePtr = (*aMethods)->Des();			
       
   421 
       
   422 				aDbBinaryColumnValuePtr.Copy(value8);
       
   423 
       
   424 				EAP_TRACE_DATA_DEBUG(
       
   425 					m_am_tools,
       
   426 					TRACE_FLAGS_DEFAULT,
       
   427 					(EAPL("eap_am_general_settings_symbian_c::GetGeneralSettingsLongBinaryL(): LONG BINARY value to caller"),
       
   428 					aDbBinaryColumnValuePtr.Ptr(), 
       
   429 					aDbBinaryColumnValuePtr.Size()));
       
   430 			}
       
   431 			else
       
   432 			{
       
   433 				User::Leave(KErrNoMemory);
       
   434 			}
       
   435 
       
   436 			CleanupStack::PopAndDestroy(valueBuf);
       
   437 
       
   438 			break;
       
   439 		}
       
   440 		default:
       
   441 			EAP_TRACE_ERROR(
       
   442 				m_am_tools,
       
   443 				TRACE_FLAGS_ERROR,
       
   444 				(EAPL("ERROR: eap_am_general_settings_symbian_c::GetGeneralSettingsLongBinaryL(): Unsupported DB field:%d = %S\n"),
       
   445 				aViev.ColType(colNoReference),
       
   446 				&aColName));	
       
   447 
       
   448 			User::Leave(KErrNotSupported);
       
   449 			break;
       
   450 	} // End: switch ()
       
   451 
       
   452 	CleanupStack::PopAndDestroy(colSet);
       
   453 }
       
   454 
       
   455 // ----------------------------------------------------------------------
       
   456 
       
   457 void eap_am_general_settings_symbian_c::GetGeneralSettingsDataL(
       
   458 	const TUint indexType,
       
   459 	const TUint index,
       
   460 	HBufC8** const aEnabledEapMethods,
       
   461 	HBufC8** const aDisabledEapMethods)
       
   462 {
       
   463 	EAP_TRACE_DEBUG(
       
   464 		m_am_tools,
       
   465 		TRACE_FLAGS_DEFAULT,
       
   466 		(EAPL("eap_am_general_settings_symbian_c::GetGeneralSettingsDataL(): iGeneralSettingsSessionOpened=%d, iGeneralSettingsDbCreated=%d"),
       
   467 		iGeneralSettingsSessionOpened,
       
   468 		iGeneralSettingsDbCreated));
       
   469 
       
   470 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_general_settings_symbian_c::GetGeneralSettingsDataL()");
       
   471 
       
   472 	*aEnabledEapMethods = 0;
       
   473 	*aDisabledEapMethods = 0;
       
   474 
       
   475 	if(iGeneralSettingsSessionOpened == EFalse)
       
   476 	{
       
   477 		EAP_TRACE_ERROR(
       
   478 			m_am_tools,
       
   479 			TRACE_FLAGS_ERROR,
       
   480 			(EAPL("eap_am_general_settings_symbian_c::GetGeneralSettingsDataL(): ERROR: General settings session not opened!")));
       
   481 
       
   482 		User::Leave(KErrSessionClosed);
       
   483 	}	
       
   484 
       
   485 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
       
   486 	TPtr sqlStatement = buf->Des();
       
   487 
       
   488 	sqlStatement.Format(
       
   489 		KSQL,
       
   490 		&KServiceType,
       
   491 		&KServiceIndex,
       
   492 		&KEapMethodEnabledValue,
       
   493 		&KEapMethodDisabledValue,
       
   494 		&KGeneralSettingsTableName,
       
   495 		&KServiceType,
       
   496 		indexType,
       
   497 		&KServiceIndex,
       
   498 		index);
       
   499 
       
   500 
       
   501 	RDbView view;
       
   502 
       
   503 	User::LeaveIfError(view.Prepare(
       
   504 		iGeneralSettingsDb, 
       
   505 		TDbQuery(sqlStatement), 
       
   506 		TDbWindow::EUnlimited,
       
   507 		RDbView::EReadOnly));
       
   508 
       
   509 	CleanupClosePushL(view);
       
   510 
       
   511 	User::LeaveIfError(view.EvaluateAll());
       
   512 
       
   513 	if (view.IsEmptyL())
       
   514 	{				
       
   515 		EAP_TRACE_DEBUG(
       
   516 			m_am_tools,
       
   517 			TRACE_FLAGS_DEFAULT,
       
   518 			(EAPL("eap_am_general_settings_symbian_c::GetGeneralSettingsDataL(): No entries in this table (%S) RETURN EMPTY VALUE"),
       
   519 			&KGeneralSettingsTableName_8bit));
       
   520 
       
   521 		EAP_TRACE_DATA_DEBUG(
       
   522 			m_am_tools,
       
   523 			TRACE_FLAGS_DEFAULT,
       
   524 			(EAPL("eap_am_general_settings_symbian_c::GetGeneralSettingsDataL():sqlStatement"),
       
   525 			sqlStatement.Ptr(), 
       
   526 			sqlStatement.Size()));
       
   527 
       
   528 		CleanupStack::PopAndDestroy(&view);
       
   529 
       
   530 		CleanupStack::PopAndDestroy(buf);	
       
   531 
       
   532 		return;
       
   533 	}
       
   534 	else
       
   535 	{
       
   536 		EAP_TRACE_DEBUG(
       
   537 			m_am_tools,
       
   538 			TRACE_FLAGS_DEFAULT,
       
   539 			(EAPL("eap_am_general_settings_symbian_c::GetGeneralSettingsDataL(): Number of entries in table %S=%d"),
       
   540 			&KGeneralSettingsTableName_8bit, view.CountL()));
       
   541 	}
       
   542 
       
   543 	EAP_TRACE_DEBUG(
       
   544 		m_am_tools,
       
   545 		TRACE_FLAGS_DEFAULT,
       
   546 		(EAPL("eap_am_general_settings_symbian_c::GetGeneralSettingsDataL() - view evaluated OK\n")));
       
   547 
       
   548 
       
   549 	if (view.FirstL())
       
   550 	{
       
   551 		EAP_TRACE_DEBUG(
       
   552 			m_am_tools,
       
   553 			TRACE_FLAGS_DEFAULT,
       
   554 			(EAPL("eap_am_general_settings_symbian_c::GetGeneralSettingsDataL() - First OK\n")));
       
   555 
       
   556 		view.GetL();
       
   557 
       
   558 		EAP_TRACE_DEBUG(
       
   559 			m_am_tools,
       
   560 			TRACE_FLAGS_DEFAULT,
       
   561 			(EAPL("eap_am_general_settings_symbian_c::GetGeneralSettingsDataL() - First Got\n")));
       
   562 
       
   563 		GetGeneralSettingsLongBinaryL(view, KEapMethodEnabledValue, aEnabledEapMethods);
       
   564 
       
   565 		GetGeneralSettingsLongBinaryL(view, KEapMethodDisabledValue, aDisabledEapMethods);
       
   566 	}
       
   567 
       
   568 	CleanupStack::PopAndDestroy( &view );
       
   569 
       
   570 	CleanupStack::PopAndDestroy(buf); // We don't need buf or sqlStatement any more.
       
   571 
       
   572 	EAP_TRACE_DEBUG(
       
   573 		m_am_tools,
       
   574 		TRACE_FLAGS_DEFAULT,
       
   575 		(EAPL("eap_am_general_settings_symbian_c::GetGeneralSettingsDataL(): End")));	
       
   576 }
       
   577 
       
   578 // ----------------------------------------------------------------------
       
   579 
       
   580 void eap_am_general_settings_symbian_c::SetGeneralSettingsLongBinaryL(
       
   581 	RDbView &aViev,
       
   582 	const TDesC &aColName,
       
   583 	const TDesC8& aMethods)
       
   584 {
       
   585 	EAP_TRACE_DEBUG(
       
   586 		m_am_tools,
       
   587 		TRACE_FLAGS_DEFAULT,
       
   588 		(EAPL("eap_am_general_settings_symbian_c::SetGeneralSettingsLongBinaryL(): iGeneralSettingsSessionOpened=%d, iGeneralSettingsDbCreated=%d"),
       
   589 		iGeneralSettingsSessionOpened,
       
   590 		iGeneralSettingsDbCreated));
       
   591 
       
   592 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_general_settings_symbian_c::SetGeneralSettingsLongBinaryL()");
       
   593 
       
   594 	// Get column set so we get the correct column numbers
       
   595 	CDbColSet* colSet = aViev.ColSetL();
       
   596 	CleanupStack::PushL(colSet);
       
   597 
       
   598 	TDbColNo colNoReference = 0;
       
   599 	colNoReference = colSet->ColNo(aColName);
       
   600 
       
   601 	switch (aViev.ColType(colNoReference))
       
   602 	{
       
   603 		case EDbColLongBinary:
       
   604 		{
       
   605 			EAP_TRACE_DATA_DEBUG(
       
   606 				m_am_tools,
       
   607 				TRACE_FLAGS_DEFAULT,
       
   608 				(EAPL("eap_am_general_settings_symbian_c::SetGeneralSettingsLongBinaryL() - Long Binary column"),
       
   609 				aColName.Ptr(), 
       
   610 				aColName.Size()));
       
   611 
       
   612 			// A stream is needed for LONG columns in DB.
       
   613 			RDbColWriteStream writeStream;					
       
   614 			writeStream.OpenLC( aViev, colNoReference );
       
   615 			writeStream.WriteL( aMethods );
       
   616 			writeStream.Close();
       
   617 			CleanupStack::PopAndDestroy( &writeStream );
       
   618 			break;
       
   619 		}
       
   620 		default:
       
   621 			EAP_TRACE_ERROR(
       
   622 				m_am_tools,
       
   623 				TRACE_FLAGS_ERROR,
       
   624 				(EAPL("eap_am_general_settings_symbian_c::SetGeneralSettingsLongBinaryL(): ERROR: Unsupported DB field:%d = %S\n"),
       
   625 				aViev.ColType(colNoReference),
       
   626 				&aColName));	
       
   627 
       
   628 			User::Leave(KErrNotSupported);
       
   629 			break;
       
   630 
       
   631 	} // End: switch (aViev.ColType(colNoReference))
       
   632 
       
   633 	CleanupStack::PopAndDestroy(colSet);
       
   634 }
       
   635 
       
   636 //-------------------------------------------------------------
       
   637 
       
   638 void eap_am_general_settings_symbian_c::SetGeneralSettingsDataL(
       
   639 	const TUint indexType,
       
   640 	const TUint index,
       
   641 	const TDesC8& aEnabledEapMethods,
       
   642 	const TDesC8& aDisabledEapMethods)
       
   643 {
       
   644 	EAP_TRACE_DEBUG(
       
   645 		m_am_tools,
       
   646 		TRACE_FLAGS_DEFAULT,
       
   647 		(EAPL("eap_am_general_settings_symbian_c::SetGeneralSettingsDataL(): iGeneralSettingsSessionOpened=%d, iGeneralSettingsDbCreated=%d"),
       
   648 		iGeneralSettingsSessionOpened, iGeneralSettingsDbCreated));
       
   649 
       
   650 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_general_settings_symbian_c::SetGeneralSettingsDataL()");
       
   651 
       
   652 	EAP_TRACE_DATA_DEBUG(
       
   653 		m_am_tools,
       
   654 		TRACE_FLAGS_DEFAULT,
       
   655 		(EAPL("eap_am_general_settings_symbian_c::SetGeneralSettingsDataL(): Set this value in general settings DB"),
       
   656 		aEnabledEapMethods.Ptr(),
       
   657 		aEnabledEapMethods.Size()));
       
   658 
       
   659 	if(iGeneralSettingsSessionOpened == EFalse)
       
   660 	{
       
   661 		EAP_TRACE_ERROR(
       
   662 			m_am_tools,
       
   663 			TRACE_FLAGS_ERROR,
       
   664 			(EAPL("eap_am_general_settings_symbian_c::SetGeneralSettingsDataL(): ERROR: General settings session not opened!")));
       
   665 
       
   666 		User::Leave(KErrSessionClosed);
       
   667 	}	
       
   668 
       
   669 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
       
   670 	TPtr sqlStatement = buf->Des();
       
   671 
       
   672 	sqlStatement.Format(
       
   673 		KSQL,
       
   674 		&KServiceType,
       
   675 		&KServiceIndex,
       
   676 		&KEapMethodEnabledValue,
       
   677 		&KEapMethodDisabledValue,
       
   678 		&KGeneralSettingsTableName,
       
   679 		&KServiceType,
       
   680 		indexType,
       
   681 		&KServiceIndex,
       
   682 		index);
       
   683 
       
   684 	EAP_TRACE_DATA_DEBUG(
       
   685 		m_am_tools,
       
   686 		TRACE_FLAGS_DEFAULT,
       
   687 		(EAPL("eap_am_general_settings_symbian_c::SetGeneralSettingsDataL():sqlStatement"),
       
   688 		sqlStatement.Ptr(), 
       
   689 		sqlStatement.Size()));
       
   690 
       
   691 	RDbView view;
       
   692 
       
   693 	User::LeaveIfError(view.Prepare(
       
   694 		iGeneralSettingsDb, 
       
   695 		TDbQuery(sqlStatement), 
       
   696 		TDbWindow::EUnlimited,
       
   697 		RDbView::EUpdatable));
       
   698 
       
   699 	CleanupClosePushL(view);
       
   700 
       
   701 	User::LeaveIfError(view.EvaluateAll());
       
   702 
       
   703 	{	
       
   704 		if(view.ColCount() != KDefaultColumnInView_One)
       
   705 		{
       
   706 			EAP_TRACE_ERROR(
       
   707 				m_am_tools,
       
   708 				TRACE_FLAGS_ERROR,
       
   709 				(EAPL("eap_am_general_settings_symbian_c::SetGeneralSettingsDataL(): ERROR: Problem with rows or columns in DB view, view.IsEmptyL()=%d, row count=%d, col count=%d \n"),
       
   710 				view.IsEmptyL(),
       
   711 				view.CountL(),
       
   712 				view.ColCount()));	
       
   713 
       
   714 			User::Leave(KErrNotFound);				
       
   715 		}	
       
   716 
       
   717 		if (view.FirstL())
       
   718 		{
       
   719 			view.UpdateL(); // Here it is update.
       
   720 		}
       
   721 		else
       
   722 		{
       
   723 			view.InsertL(); // Here it is insert.
       
   724 		}
       
   725 
       
   726 		{
       
   727 			CDbColSet* colSet = view.ColSetL();
       
   728 			CleanupStack::PushL(colSet);		
       
   729 
       
   730 			TDbColNo colNoServiceType = 0;
       
   731 			TDbColNo colNoServiceIndex = 0;
       
   732 
       
   733 			colNoServiceType = colSet->ColNo(KServiceType);
       
   734 			colNoServiceIndex = colSet->ColNo(KServiceIndex);		
       
   735 			
       
   736 			CleanupStack::PopAndDestroy(colSet); // delete colSet.
       
   737 
       
   738 			view.SetColL(colNoServiceType, indexType);
       
   739 			view.SetColL(colNoServiceIndex, index);
       
   740 
       
   741 			SetGeneralSettingsLongBinaryL(view,	KEapMethodEnabledValue, aEnabledEapMethods);
       
   742 
       
   743 			SetGeneralSettingsLongBinaryL(view,	KEapMethodDisabledValue, aDisabledEapMethods);
       
   744 		}
       
   745 	}
       
   746 
       
   747 	// Now it should go to the DB.
       
   748 	view.PutL();	
       
   749 
       
   750 	CleanupStack::PopAndDestroy( &view );
       
   751 
       
   752 	CleanupStack::PopAndDestroy(buf);
       
   753 }
       
   754 
       
   755 //-------------------------------------------------------------
       
   756 
       
   757 void eap_am_general_settings_symbian_c::DeleteGeneralSettingsDataL(
       
   758 	const TUint indexType,
       
   759 	const TUint index)
       
   760 {
       
   761 	EAP_TRACE_DEBUG(
       
   762 		m_am_tools,
       
   763 		TRACE_FLAGS_DEFAULT,
       
   764 		(EAPL("eap_am_general_settings_symbian_c::DeleteGeneralSettingsDataL(): iGeneralSettingsSessionOpened=%d, iGeneralSettingsDbCreated=%d"),
       
   765 		iGeneralSettingsSessionOpened, iGeneralSettingsDbCreated));
       
   766 
       
   767 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_general_settings_symbian_c::DeleteGeneralSettingsDataL()");
       
   768 
       
   769 	if(iGeneralSettingsSessionOpened == EFalse)
       
   770 	{
       
   771 		EAP_TRACE_ERROR(
       
   772 			m_am_tools,
       
   773 			TRACE_FLAGS_ERROR,
       
   774 			(EAPL("eap_am_general_settings_symbian_c::DeleteGeneralSettingsDataL(): ERROR: General settings session not opened!")));
       
   775 
       
   776 		User::Leave(KErrSessionClosed);
       
   777 	}	
       
   778 
       
   779 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
       
   780 	TPtr sqlStatement = buf->Des();
       
   781 
       
   782 	sqlStatement.Format(
       
   783 		KSQL,
       
   784 		&KServiceType,
       
   785 		&KServiceIndex,
       
   786 		&KEapMethodEnabledValue,
       
   787 		&KEapMethodDisabledValue,
       
   788 		&KGeneralSettingsTableName,
       
   789 		&KServiceType,
       
   790 		indexType,
       
   791 		&KServiceIndex,
       
   792 		index);
       
   793 
       
   794 	EAP_TRACE_DATA_DEBUG(
       
   795 		m_am_tools,
       
   796 		TRACE_FLAGS_DEFAULT,
       
   797 		(EAPL("eap_am_general_settings_symbian_c::DeleteGeneralSettingsDataL():sqlStatement"),
       
   798 		sqlStatement.Ptr(), 
       
   799 		sqlStatement.Size()));
       
   800 
       
   801 	RDbView view;
       
   802 
       
   803 	User::LeaveIfError(view.Prepare(
       
   804 		iGeneralSettingsDb, 
       
   805 		TDbQuery(sqlStatement), 
       
   806 		TDbWindow::EUnlimited,
       
   807 		RDbView::EUpdatable));
       
   808 
       
   809 	CleanupClosePushL(view);
       
   810 
       
   811 	User::LeaveIfError(view.EvaluateAll());
       
   812 
       
   813 	{	
       
   814 		// Delete old row and also rows that are for same IAP.
       
   815 		if (view.FirstL())
       
   816 		{
       
   817 			CDbColSet* colSet = view.ColSetL();
       
   818 			CleanupStack::PushL(colSet);
       
   819 
       
   820 			do {
       
   821 				view.GetL();
       
   822 
       
   823 				if (view.ColUint32(colSet->ColNo(KServiceType)) == static_cast<TUint>(indexType)
       
   824 						&& view.ColUint32(colSet->ColNo(KServiceIndex)) == static_cast<TUint>(index))
       
   825 				{
       
   826 					view.DeleteL();
       
   827 				}
       
   828 				
       
   829 			} while (view.NextL() != EFalse);
       
   830 
       
   831 			CleanupStack::PopAndDestroy(colSet); // delete colSet.
       
   832 		}
       
   833 	}
       
   834 
       
   835 	CleanupStack::PopAndDestroy( &view );
       
   836 
       
   837 	CleanupStack::PopAndDestroy(buf);
       
   838 }
       
   839 
       
   840 // ----------------------------------------------------------------------
       
   841 
       
   842 void eap_am_general_settings_symbian_c::CopyGeneralSettingsDataL(
       
   843 	const TUint aSourceIndexType,
       
   844 	const TUint aSourceIndex,
       
   845 	const TUint aDestinationIndexType,
       
   846 	const TUint aDestinationIndex)
       
   847 {
       
   848 	EAP_TRACE_DEBUG(
       
   849 		m_am_tools,
       
   850 		TRACE_FLAGS_DEFAULT,
       
   851 		(EAPL("eap_am_general_settings_symbian_c::CopyGeneralSettingsDataL(): iGeneralSettingsSessionOpened=%d, iGeneralSettingsDbCreated=%d"),
       
   852 		iGeneralSettingsSessionOpened, iGeneralSettingsDbCreated));
       
   853 
       
   854 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_general_settings_symbian_c::CopyGeneralSettingsDataL()");
       
   855 
       
   856 	if(iGeneralSettingsSessionOpened == EFalse)
       
   857 	{
       
   858 		EAP_TRACE_ERROR(
       
   859 			m_am_tools,
       
   860 			TRACE_FLAGS_ERROR,
       
   861 			(EAPL("eap_am_general_settings_symbian_c::CopyGeneralSettingsDataL(): ERROR: General settings session not opened!")));
       
   862 
       
   863 		User::Leave(KErrSessionClosed);
       
   864 	}
       
   865 
       
   866 	if (aSourceIndexType == aDestinationIndexType
       
   867 		&& aSourceIndex == aDestinationIndex)
       
   868 	{
       
   869 		EAP_TRACE_ERROR(
       
   870 			m_am_tools,
       
   871 			TRACE_FLAGS_ERROR,
       
   872 			(EAPL("eap_am_general_settings_symbian_c::CopyGeneralSettingsDataL(): ERROR: aSourceIndexType == aDestinationIndexType && aSourceIndex == aDestinationIndex")));
       
   873 
       
   874 		User::Leave(KErrArgument);
       
   875 	}
       
   876 
       
   877 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
       
   878 	TPtr sqlStatement = buf->Des();
       
   879 
       
   880 	sqlStatement.Format(
       
   881 		KSQL,
       
   882 		&KServiceType,
       
   883 		&KServiceIndex,
       
   884 		&KEapMethodEnabledValue,
       
   885 		&KEapMethodDisabledValue,
       
   886 		&KGeneralSettingsTableName,
       
   887 		&KServiceType,
       
   888 		aDestinationIndexType,
       
   889 		&KServiceIndex,
       
   890 		aDestinationIndex);
       
   891 
       
   892 	EAP_TRACE_DATA_DEBUG(
       
   893 		m_am_tools,
       
   894 		TRACE_FLAGS_DEFAULT,
       
   895 		(EAPL("eap_am_general_settings_symbian_c::CopyGeneralSettingsDataL():sqlStatement"),
       
   896 		sqlStatement.Ptr(), 
       
   897 		sqlStatement.Size()));
       
   898 
       
   899 	RDbView view;
       
   900 
       
   901 	User::LeaveIfError(view.Prepare(
       
   902 		iGeneralSettingsDb, 
       
   903 		TDbQuery(sqlStatement), 
       
   904 		TDbWindow::EUnlimited,
       
   905 		RDbView::EUpdatable));
       
   906 
       
   907 	CleanupClosePushL(view);
       
   908 
       
   909 	User::LeaveIfError(view.EvaluateAll());
       
   910 
       
   911 	{	
       
   912 		// Delete destination old data.
       
   913 		if (view.FirstL())
       
   914 		{
       
   915 			CDbColSet* colSet = view.ColSetL();
       
   916 			CleanupStack::PushL(colSet);
       
   917 
       
   918   			do 
       
   919   			{
       
   920 	  			view.GetL();
       
   921 
       
   922 				if (view.ColUint(colSet->ColNo(KServiceType)) == static_cast<TUint>(aDestinationIndexType)
       
   923 					&& view.ColUint(colSet->ColNo(KServiceIndex)) == static_cast<TUint>(aDestinationIndex))
       
   924 				{  		
       
   925       				EAP_TRACE_DEBUG_SYMBIAN((_L("eap_am_general_settings_symbian_c::CopyGeneralSettingsDataL(): Delete old records\n") ) );
       
   926       				view.DeleteL();
       
   927    				}
       
   928 			}
       
   929 			while (view.NextL() != EFalse);
       
   930 
       
   931 			view.Close();
       
   932 
       
   933 			CleanupStack::PopAndDestroy(colSet); // delete colSet.
       
   934 		}
       
   935 
       
   936 		sqlStatement.Format(
       
   937 			KSQL,
       
   938 			&KServiceType,
       
   939 			&KServiceIndex,
       
   940 			&KEapMethodEnabledValue,
       
   941 			&KEapMethodDisabledValue,
       
   942 			&KGeneralSettingsTableName,
       
   943 			&KServiceType,
       
   944 			aSourceIndexType,
       
   945 			&KServiceIndex,
       
   946 			aSourceIndex);
       
   947 
       
   948 		EAP_TRACE_DATA_DEBUG(
       
   949 			m_am_tools,
       
   950 			TRACE_FLAGS_DEFAULT,
       
   951 			(EAPL("eap_am_general_settings_symbian_c::CopyGeneralSettingsDataL():sqlStatement"),
       
   952 			sqlStatement.Ptr(), 
       
   953 			sqlStatement.Size()));
       
   954 
       
   955 		User::LeaveIfError(view.Prepare(
       
   956 			iGeneralSettingsDb, 
       
   957 			TDbQuery(sqlStatement), 
       
   958 			TDbWindow::EUnlimited,
       
   959 			RDbView::EUpdatable));
       
   960 
       
   961 		User::LeaveIfError(view.EvaluateAll());
       
   962 
       
   963 		// Copy source row to destination.
       
   964 		if (view.FirstL())
       
   965 		{
       
   966 			CDbColSet* colSet = view.ColSetL();
       
   967 			CleanupStack::PushL(colSet);
       
   968 			TDbBookmark bookmark;
       
   969 
       
   970 			do
       
   971 			{
       
   972 				view.GetL();
       
   973 
       
   974 				if (view.ColUint32(colSet->ColNo(KServiceType)) == static_cast<TUint>(aSourceIndexType)
       
   975 						&& view.ColUint32(colSet->ColNo(KServiceIndex)) == static_cast<TUint>(aSourceIndex))
       
   976 				{	
       
   977 					bookmark = view.Bookmark();
       
   978 					
       
   979 					view.InsertCopyL();
       
   980 					
       
   981 					view.SetColL(colSet->ColNo(KServiceType), static_cast<TUint>(aDestinationIndexType));
       
   982 	    			view.SetColL(colSet->ColNo(KServiceIndex), static_cast<TUint>(aDestinationIndex));
       
   983 					
       
   984 					view.PutL();
       
   985 				
       
   986 					view.GotoL(bookmark);
       
   987 				}
       
   988 				
       
   989 			}
       
   990 			while (view.NextL() != EFalse);
       
   991 
       
   992 			CleanupStack::PopAndDestroy(colSet); // delete colSet.
       
   993 		}
       
   994 	}
       
   995 
       
   996 	CleanupStack::PopAndDestroy( &view );
       
   997 
       
   998 	CleanupStack::PopAndDestroy(buf);
       
   999 }
       
  1000 
       
  1001 // ----------------------------------------------------------------------
       
  1002 
       
  1003 eap_status_e eap_am_general_settings_symbian_c::error_complete(
       
  1004 	const eap_status_e completion_status,
       
  1005 	const eap_method_settings_c * const internal_settings,
       
  1006 	const eap_tlv_message_type_function_e error_completion_function)
       
  1007 {
       
  1008 	EAP_TRACE_DEBUG(
       
  1009 		m_am_tools,
       
  1010 		TRACE_FLAGS_DEFAULT,
       
  1011 		(EAPL("eap_am_general_settings_symbian_c::error_complete(): this=0x%08x.\n"),
       
  1012 		this));
       
  1013 
       
  1014 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_general_settings_symbian_c::error_complete()");
       
  1015 
       
  1016 	CloseGeneralSettings();
       
  1017 
       
  1018 	EAP_TRACE_DEBUG(
       
  1019 		m_am_tools,
       
  1020 		TRACE_FLAGS_DEFAULT,
       
  1021 		(EAPL("eap_am_general_settings_symbian_c::error_complete(): this=0x%08x, CloseGeneralSettings()\n"),
       
  1022 		this));
       
  1023 
       
  1024 	if (internal_settings == 0)
       
  1025 	{
       
  1026 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1027 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1028 	}
       
  1029 
       
  1030 	eap_method_settings_c * const complete_settings = new eap_method_settings_c(m_am_tools, internal_settings);
       
  1031 
       
  1032 	eap_automatic_variable_c<eap_method_settings_c> automatic_complete_settings(
       
  1033 		m_am_tools,
       
  1034 		complete_settings);
       
  1035 
       
  1036 	if (complete_settings == 0)
       
  1037 	{
       
  1038 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1039 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1040 	}
       
  1041 
       
  1042 	complete_settings->m_completion_status = completion_status;
       
  1043 
       
  1044 	eap_status_e status(eap_status_not_supported);
       
  1045 
       
  1046 	switch(error_completion_function)
       
  1047 	{
       
  1048 	case eap_tlv_message_type_function_general_settings_complete_get_eap_methods:
       
  1049 		status = m_partner->complete_get_eap_methods(complete_settings);
       
  1050 		break;
       
  1051 	case eap_tlv_message_type_function_general_settings_complete_set_eap_methods:
       
  1052 		status = m_partner->complete_set_eap_methods(complete_settings);
       
  1053 		break;
       
  1054 	case eap_tlv_message_type_function_general_settings_complete_get_certificate_lists:
       
  1055 		status = m_partner->complete_get_certificate_lists(complete_settings);
       
  1056 		break;
       
  1057 	case eap_tlv_message_type_function_general_settings_complete_delete_all_eap_settings:
       
  1058 		status = m_partner->complete_delete_all_eap_settings(complete_settings);
       
  1059 		break;
       
  1060 	case eap_tlv_message_type_function_general_settings_complete_copy_all_eap_settings:
       
  1061 		status = m_partner->complete_copy_all_eap_settings(complete_settings);
       
  1062 		break;
       
  1063 	default:
       
  1064 		EAP_TRACE_ERROR(
       
  1065 			m_am_tools,
       
  1066 			TRACE_FLAGS_ERROR,
       
  1067 			(EAPL("ERROR: eap_am_general_settings_symbian_c::error_complete(): unknown function %d.\n"),
       
  1068 			 error_completion_function));
       
  1069 
       
  1070 		EAP_ASSERT_ANYWAY_TOOLS(m_am_tools);
       
  1071 
       
  1072 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1073 		return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  1074 	}
       
  1075 
       
  1076 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1077 }
       
  1078 
       
  1079 // ----------------------------------------------------------------------
       
  1080 
       
  1081 eap_status_e eap_am_general_settings_symbian_c::filter_eap_methods(
       
  1082 	eap_array_c<eap_type_value_e> * const eap_methods,
       
  1083 	RPointerArray<TEapExpandedType> * const aPlugins)
       
  1084 {
       
  1085 	EAP_TRACE_DEBUG(
       
  1086 		m_am_tools,
       
  1087 		TRACE_FLAGS_DEFAULT,
       
  1088 		(EAPL("eap_am_general_settings_symbian_c::filter_eap_methods(): this=0x%08x.\n"),
       
  1089 		this));
       
  1090 
       
  1091 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_general_settings_symbian_c::filter_eap_methods()");
       
  1092 
       
  1093 	eap_status_e status(eap_status_ok);
       
  1094 
       
  1095 	for (TInt act_ind = 0; act_ind < eap_methods->get_object_count(); ++act_ind)
       
  1096 	{
       
  1097 		const eap_type_value_e * active_type = eap_methods->get_object(act_ind);
       
  1098 		if (active_type == 0)
       
  1099 		{
       
  1100 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1101 		}
       
  1102 
       
  1103 		EAP_TRACE_DEBUG(
       
  1104 			m_am_tools,
       
  1105 			TRACE_FLAGS_DEFAULT,
       
  1106 			(EAPL("eap_am_general_settings_symbian_c::filter_eap_methods(): eap_methods[%d] EAP-type=0xfe%06x%08x\n"),
       
  1107 			act_ind,
       
  1108 			active_type->get_vendor_id(),
       
  1109 			active_type->get_vendor_type()));
       
  1110 
       
  1111 		bool exists(false);
       
  1112 
       
  1113 		for (TInt plugin_ind = 0; plugin_ind < aPlugins->Count(); ++plugin_ind)
       
  1114 		{
       
  1115 			const TEapExpandedType * eap_type = (*aPlugins)[plugin_ind];
       
  1116 			if (eap_type == 0)
       
  1117 			{
       
  1118 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1119 			}
       
  1120 
       
  1121 			EAP_TRACE_DEBUG_SYMBIAN((_L("eap_am_general_settings_symbian_c::filter_eap_methods(): aPlugins[%d] EAP-type=0xfe%06x%08x\n"),
       
  1122 				plugin_ind,
       
  1123 				eap_type->GetVendorId(),
       
  1124 				eap_type->GetVendorType()));
       
  1125 
       
  1126 			const eap_type_value_e common_eap_type(
       
  1127 				static_cast<eap_type_vendor_id_e>(eap_type->GetVendorId()),
       
  1128 				eap_type->GetVendorType());
       
  1129 
       
  1130 			if (common_eap_type == *active_type)
       
  1131 			{
       
  1132 				// OK, this active EAP-method have implementation.
       
  1133 				exists = true;
       
  1134 
       
  1135 				EAP_TRACE_DEBUG(
       
  1136 					m_am_tools,
       
  1137 					TRACE_FLAGS_DEFAULT,
       
  1138 					(EAPL("eap_am_general_settings_symbian_c::filter_eap_methods(): Removes from aPlugins EAP-type=0xfe%06x%08x\n"),
       
  1139 					common_eap_type.get_vendor_id(),
       
  1140 					common_eap_type.get_vendor_type()));
       
  1141 
       
  1142 				// Remove this plugin EAP-method because it is in the list of EAP-methods.
       
  1143 				delete (*aPlugins)[plugin_ind];
       
  1144 				aPlugins->Remove(plugin_ind);
       
  1145 
       
  1146 				break;
       
  1147 			}
       
  1148 		} // for()
       
  1149 
       
  1150 		if (exists == false)
       
  1151 		{
       
  1152 			// Remove this EAP-method because there are no implementation.
       
  1153 
       
  1154 			EAP_TRACE_DEBUG(
       
  1155 				m_am_tools,
       
  1156 				TRACE_FLAGS_DEFAULT,
       
  1157 				(EAPL("eap_am_general_settings_symbian_c::filter_eap_methods(): Removes from eap_methods EAP-type=0xfe%06x%08x\n"),
       
  1158 				active_type->get_vendor_id(),
       
  1159 				active_type->get_vendor_type()));
       
  1160 
       
  1161 			status = eap_methods->remove_object(act_ind);
       
  1162 			if (status != eap_status_ok)
       
  1163 			{
       
  1164 				return EAP_STATUS_RETURN(m_am_tools, status);
       
  1165 			}
       
  1166 
       
  1167 			--act_ind;
       
  1168 		}
       
  1169 	} // for()
       
  1170 
       
  1171 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1172 }
       
  1173 
       
  1174 // ----------------------------------------------------------------------
       
  1175 
       
  1176 eap_status_e eap_am_general_settings_symbian_c::read_eap_methods_synchronously(
       
  1177 	const TUint indexType,
       
  1178 	const TUint index,
       
  1179 	eap_array_c<eap_type_value_e> * const aEnabledEapMethodsArray,
       
  1180 	eap_array_c<eap_type_value_e> * const aDisabledEapMethodsArray)
       
  1181 {
       
  1182 	EAP_TRACE_DEBUG(
       
  1183 		m_am_tools,
       
  1184 		TRACE_FLAGS_DEFAULT,
       
  1185 		(EAPL("eap_am_general_settings_symbian_c::read_eap_methods_synchronously(): this=0x%08x.\n"),
       
  1186 		this));
       
  1187 
       
  1188 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_general_settings_symbian_c::read_eap_methods_synchronously()");
       
  1189 
       
  1190 	TInt error = KErrNone;
       
  1191 
       
  1192 	TRAP(error, (OpenGeneralSettingsL()));
       
  1193 
       
  1194 	if (error != KErrNone)
       
  1195 	{
       
  1196 		EAP_TRACE_ERROR(
       
  1197 			m_am_tools,
       
  1198 			TRACE_FLAGS_ERROR,
       
  1199 			(EAPL("ERROR: eap_am_general_settings_symbian_c::read_eap_methods_synchronously(): OpenGeneralSettingsL() failed, indexType=%d, index=%d, error=%d.\n"),
       
  1200 			indexType,
       
  1201 			index,
       
  1202 			error));
       
  1203 
       
  1204 		CloseGeneralSettings();
       
  1205 
       
  1206 		EAP_TRACE_DEBUG(
       
  1207 			m_am_tools,
       
  1208 			TRACE_FLAGS_DEFAULT,
       
  1209 			(EAPL("eap_am_general_settings_symbian_c::read_eap_methods_synchronously(): this=0x%08x, CloseGeneralSettings()\n"),
       
  1210 			this));
       
  1211 
       
  1212 		return EAP_STATUS_RETURN(
       
  1213 			m_am_tools,
       
  1214 			m_am_tools->convert_am_error_to_eapol_error(error));
       
  1215 	}
       
  1216 
       
  1217 
       
  1218 	HBufC8 *aEnabledEapMethods = 0;
       
  1219 	HBufC8 *aDisabledEapMethods = 0;
       
  1220 
       
  1221 	// The output parameters aEnabledEapMethods and aDisabledEapMethods are NOT in clean up stack.
       
  1222 	TRAP(error, (GetGeneralSettingsDataL(
       
  1223 		indexType,
       
  1224 		index,
       
  1225 		&aEnabledEapMethods,
       
  1226 		&aDisabledEapMethods)));
       
  1227 
       
  1228 	eap_automatic_variable_c<HBufC8> automatic_aEnabledEapMethods(
       
  1229 		m_am_tools,
       
  1230 		aEnabledEapMethods);
       
  1231 
       
  1232 	eap_automatic_variable_c<HBufC8> automatic_aDisabledEapMethods(
       
  1233 		m_am_tools,
       
  1234 		aDisabledEapMethods);
       
  1235 
       
  1236 	if (error != KErrNone)
       
  1237 	{
       
  1238 		EAP_TRACE_ERROR(
       
  1239 			m_am_tools,
       
  1240 			TRACE_FLAGS_ERROR,
       
  1241 			(EAPL("ERROR: eap_am_general_settings_symbian_c::read_eap_methods_synchronously(): GetGeneralSettingsDataL() failed, index_type=%d, index=%d, error=%d.\n"),
       
  1242 			indexType,
       
  1243 			index,
       
  1244 			error));
       
  1245 
       
  1246 		CloseGeneralSettings();
       
  1247 
       
  1248 		EAP_TRACE_DEBUG(
       
  1249 			m_am_tools,
       
  1250 			TRACE_FLAGS_DEFAULT,
       
  1251 			(EAPL("eap_am_general_settings_symbian_c::read_eap_methods_synchronously(): this=0x%08x, CloseGeneralSettings()\n"),
       
  1252 			this));
       
  1253 
       
  1254 		return EAP_STATUS_RETURN(
       
  1255 			m_am_tools,
       
  1256 			m_am_tools->convert_am_error_to_eapol_error(error));
       
  1257 	}
       
  1258 
       
  1259 	if (aEnabledEapMethods != 0)
       
  1260 	{
       
  1261 		error = CEapConversion::ConvertHBufC8ToInternalTypes(
       
  1262 			m_am_tools,
       
  1263 			aEnabledEapMethods,
       
  1264 			aEnabledEapMethodsArray);
       
  1265 
       
  1266 		if (error != KErrNone)
       
  1267 		{
       
  1268 			EAP_TRACE_ERROR(
       
  1269 				m_am_tools,
       
  1270 				TRACE_FLAGS_ERROR,
       
  1271 				(EAPL("ERROR: eap_am_general_settings_symbian_c::read_eap_methods_synchronously(): index_type=%d, index=%d.\n"),
       
  1272 				indexType,
       
  1273 				index));
       
  1274 
       
  1275 			CloseGeneralSettings();
       
  1276 
       
  1277 			EAP_TRACE_DEBUG(
       
  1278 				m_am_tools,
       
  1279 				TRACE_FLAGS_DEFAULT,
       
  1280 				(EAPL("eap_am_general_settings_symbian_c::read_eap_methods_synchronously(): this=0x%08x, CloseGeneralSettings()\n"),
       
  1281 				this));
       
  1282 
       
  1283 			return EAP_STATUS_RETURN(
       
  1284 				m_am_tools,
       
  1285 				m_am_tools->convert_am_error_to_eapol_error(error));
       
  1286 		}
       
  1287 	}
       
  1288 
       
  1289 	if (aDisabledEapMethods != 0)
       
  1290 	{
       
  1291 		error = CEapConversion::ConvertHBufC8ToInternalTypes(
       
  1292 			m_am_tools,
       
  1293 			aDisabledEapMethods,
       
  1294 			aDisabledEapMethodsArray);
       
  1295 
       
  1296 		if (error != KErrNone)
       
  1297 		{
       
  1298 			EAP_TRACE_ERROR(
       
  1299 				m_am_tools,
       
  1300 				TRACE_FLAGS_ERROR,
       
  1301 				(EAPL("ERROR: eap_am_general_settings_symbian_c::read_eap_methods_synchronously(): index_type=%d, index=%d.\n"),
       
  1302 				indexType,
       
  1303 				index));
       
  1304 
       
  1305 			CloseGeneralSettings();
       
  1306 
       
  1307 			EAP_TRACE_DEBUG(
       
  1308 				m_am_tools,
       
  1309 				TRACE_FLAGS_DEFAULT,
       
  1310 				(EAPL("eap_am_general_settings_symbian_c::read_eap_methods_synchronously(): this=0x%08x, CloseGeneralSettings()\n"),
       
  1311 				this));
       
  1312 
       
  1313 			return EAP_STATUS_RETURN(
       
  1314 				m_am_tools,
       
  1315 				m_am_tools->convert_am_error_to_eapol_error(error));
       
  1316 		}
       
  1317 	}
       
  1318 
       
  1319 	iGeneralSettingsDb.Compact();
       
  1320 
       
  1321 	CloseGeneralSettings();
       
  1322 
       
  1323 	EAP_TRACE_DEBUG(
       
  1324 		m_am_tools,
       
  1325 		TRACE_FLAGS_DEFAULT,
       
  1326 		(EAPL("eap_am_general_settings_symbian_c::read_eap_methods_synchronously(): this=0x%08x, CloseGeneralSettings()\n"),
       
  1327 		this));
       
  1328 
       
  1329 	return EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(error));
       
  1330 }
       
  1331 
       
  1332 // ----------------------------------------------------------------------
       
  1333 
       
  1334 eap_status_e eap_am_general_settings_symbian_c::get_eap_methods(const eap_method_settings_c * const internal_settings)
       
  1335 {
       
  1336 	EAP_TRACE_DEBUG(
       
  1337 		m_am_tools,
       
  1338 		TRACE_FLAGS_DEFAULT,
       
  1339 		(EAPL("eap_am_general_settings_symbian_c::get_eap_methods(): this=0x%08x.\n"),
       
  1340 		this));
       
  1341 
       
  1342 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_general_settings_symbian_c::get_eap_methods()");
       
  1343 
       
  1344 	const eap_tlv_message_type_function_e error_completion_function(eap_tlv_message_type_function_general_settings_complete_get_eap_methods);
       
  1345 
       
  1346 	HBufC8 *aEnabledEapMethods = 0;
       
  1347 	HBufC8 *aDisabledEapMethods = 0;
       
  1348 
       
  1349 	TInt error(KErrNone);
       
  1350 	eap_status_e status(eap_status_ok);
       
  1351 
       
  1352 	TRAP(error, (OpenGeneralSettingsL()));
       
  1353 
       
  1354 	if (error != KErrNone)
       
  1355 	{
       
  1356 		EAP_TRACE_ERROR(
       
  1357 			m_am_tools,
       
  1358 			TRACE_FLAGS_ERROR,
       
  1359 			(EAPL("ERROR: eap_am_general_settings_symbian_c::get_eap_methods(): OpenGeneralSettingsL() failed, EAP-type=0xfe%06x%08x, index_type=%d, index=%d, error=%d.\n"),
       
  1360 			internal_settings->m_EAPType.get_vendor_id(),
       
  1361 			internal_settings->m_EAPType.get_vendor_type(),
       
  1362 			internal_settings->m_IndexType,
       
  1363 			internal_settings->m_Index,
       
  1364 			error));
       
  1365 
       
  1366 		return EAP_STATUS_RETURN(
       
  1367 			m_am_tools,
       
  1368 			error_complete(
       
  1369 				m_am_tools->convert_am_error_to_eapol_error(error),
       
  1370 				internal_settings,
       
  1371 				error_completion_function));
       
  1372 	}
       
  1373 
       
  1374 
       
  1375 	// The output parameters aEnabledEapMethods and aDisabledEapMethods are NOT in clean up stack.
       
  1376 	TRAP(error, (GetGeneralSettingsDataL(
       
  1377 		internal_settings->m_IndexType,
       
  1378 		internal_settings->m_Index,
       
  1379 		&aEnabledEapMethods,
       
  1380 		&aDisabledEapMethods)));
       
  1381 
       
  1382 	eap_automatic_variable_c<HBufC8> automatic_aEnabledEapMethods(
       
  1383 		m_am_tools,
       
  1384 		aEnabledEapMethods);
       
  1385 
       
  1386 	eap_automatic_variable_c<HBufC8> automatic_aDisabledEapMethods(
       
  1387 		m_am_tools,
       
  1388 		aDisabledEapMethods);
       
  1389 
       
  1390 	if (error != KErrNone)
       
  1391 	{
       
  1392 		EAP_TRACE_ERROR(
       
  1393 			m_am_tools,
       
  1394 			TRACE_FLAGS_ERROR,
       
  1395 			(EAPL("ERROR: eap_am_general_settings_symbian_c::get_eap_methods(): GetGeneralSettingsDataL() failed, EAP-type=0xfe%06x%08x, index_type=%d, index=%d, error=%d.\n"),
       
  1396 			internal_settings->m_EAPType.get_vendor_id(),
       
  1397 			internal_settings->m_EAPType.get_vendor_type(),
       
  1398 			internal_settings->m_IndexType,
       
  1399 			internal_settings->m_Index,
       
  1400 			error));
       
  1401 
       
  1402 		return EAP_STATUS_RETURN(
       
  1403 			m_am_tools,
       
  1404 			error_complete(
       
  1405 				m_am_tools->convert_am_error_to_eapol_error(error),
       
  1406 				internal_settings,
       
  1407 				error_completion_function));
       
  1408 	}
       
  1409 
       
  1410 
       
  1411 	RPointerArray<TEapExpandedType> plugins_array;
       
  1412 
       
  1413 	PointerArrayResetAndDestroy<TEapExpandedType> aAutomaticPlugins(&plugins_array, EFalse);
       
  1414 
       
  1415 	EapPluginTools aPluginTool;
       
  1416 
       
  1417 	TEapExpandedType aTunnelingType(*EapExpandedTypeNone.GetType());
       
  1418 
       
  1419 	TRAP(error, (aPluginTool.ListAllEapPluginsL(static_cast<TIndexType>(internal_settings->m_IndexType), aTunnelingType, plugins_array)));
       
  1420 	if (error != KErrNone)
       
  1421 	{
       
  1422 		EAP_TRACE_ERROR(
       
  1423 			m_am_tools,
       
  1424 			TRACE_FLAGS_ERROR,
       
  1425 			(EAPL("ERROR: eap_am_general_settings_symbian_c::get_eap_methods(): aPluginTool.ListAllEapPluginsL() failed, EAP-type=0xfe%06x%08x, index_type=%d, index=%d, error=%d.\n"),
       
  1426 			internal_settings->m_EAPType.get_vendor_id(),
       
  1427 			internal_settings->m_EAPType.get_vendor_type(),
       
  1428 			internal_settings->m_IndexType,
       
  1429 			internal_settings->m_Index,
       
  1430 			error));
       
  1431 
       
  1432 		return EAP_STATUS_RETURN(
       
  1433 			m_am_tools,
       
  1434 			error_complete(
       
  1435 				m_am_tools->convert_am_error_to_eapol_error(error),
       
  1436 				internal_settings,
       
  1437 				error_completion_function));
       
  1438 	}
       
  1439 
       
  1440 	eap_method_settings_c * const complete_settings = new eap_method_settings_c(m_am_tools);
       
  1441 
       
  1442 	eap_automatic_variable_c<eap_method_settings_c> automatic_complete_settings(
       
  1443 		m_am_tools,
       
  1444 		complete_settings);
       
  1445 
       
  1446 	if (complete_settings == 0)
       
  1447 	{
       
  1448 		return EAP_STATUS_RETURN(
       
  1449 			m_am_tools,
       
  1450 			error_complete(
       
  1451 				eap_status_allocation_error,
       
  1452 				internal_settings,
       
  1453 				error_completion_function));
       
  1454 	}
       
  1455 
       
  1456 	if (aEnabledEapMethods != 0)
       
  1457 	{
       
  1458 		error = CEapConversion::ConvertHBufC8ToInternalTypes(
       
  1459 			m_am_tools,
       
  1460 			aEnabledEapMethods,
       
  1461 			&(complete_settings->m_active_eap_methods));
       
  1462 
       
  1463 		if (error != KErrNone)
       
  1464 		{
       
  1465 			EAP_TRACE_ERROR(
       
  1466 				m_am_tools,
       
  1467 				TRACE_FLAGS_ERROR,
       
  1468 				(EAPL("ERROR: eap_am_general_settings_symbian_c::get_eap_methods(): EAP-type=0xfe%06x%08x, index_type=%d, index=%d.\n"),
       
  1469 				internal_settings->m_EAPType.get_vendor_id(),
       
  1470 				internal_settings->m_EAPType.get_vendor_type(),
       
  1471 				internal_settings->m_IndexType,
       
  1472 				internal_settings->m_Index));
       
  1473 			return EAP_STATUS_RETURN(
       
  1474 				m_am_tools,
       
  1475 				error_complete(
       
  1476 					m_am_tools->convert_am_error_to_eapol_error(error),
       
  1477 					internal_settings,
       
  1478 					error_completion_function));
       
  1479 		}
       
  1480 	}
       
  1481 
       
  1482 	if (aDisabledEapMethods != 0)
       
  1483 	{
       
  1484 		error = CEapConversion::ConvertHBufC8ToInternalTypes(
       
  1485 			m_am_tools,
       
  1486 			aDisabledEapMethods,
       
  1487 			&(complete_settings->m_disabled_eap_methods));
       
  1488 
       
  1489 		if (error != KErrNone)
       
  1490 		{
       
  1491 			EAP_TRACE_ERROR(
       
  1492 				m_am_tools,
       
  1493 				TRACE_FLAGS_ERROR,
       
  1494 				(EAPL("ERROR: eap_am_general_settings_symbian_c::get_eap_methods(): EAP-type=0xfe%06x%08x, index_type=%d, index=%d.\n"),
       
  1495 				internal_settings->m_EAPType.get_vendor_id(),
       
  1496 				internal_settings->m_EAPType.get_vendor_type(),
       
  1497 				internal_settings->m_IndexType,
       
  1498 				internal_settings->m_Index));
       
  1499 			return EAP_STATUS_RETURN(
       
  1500 				m_am_tools,
       
  1501 				error_complete(
       
  1502 					m_am_tools->convert_am_error_to_eapol_error(error),
       
  1503 					internal_settings,
       
  1504 					error_completion_function));
       
  1505 		}
       
  1506 	}
       
  1507 
       
  1508 	// Next filter out unimplemented EAP-methods.
       
  1509 	status = filter_eap_methods(
       
  1510 		&(complete_settings->m_active_eap_methods),
       
  1511 		&plugins_array);
       
  1512 	if (status != eap_status_ok)
       
  1513 	{
       
  1514 		return EAP_STATUS_RETURN(
       
  1515 			m_am_tools,
       
  1516 			error_complete(
       
  1517 				status,
       
  1518 				internal_settings,
       
  1519 				error_completion_function));
       
  1520 	}
       
  1521 
       
  1522 	// Check the disabled EAP-method have implementation.
       
  1523 	status = filter_eap_methods(
       
  1524 		&(complete_settings->m_disabled_eap_methods),
       
  1525 		&plugins_array);
       
  1526 	if (status != eap_status_ok)
       
  1527 	{
       
  1528 		return EAP_STATUS_RETURN(
       
  1529 			m_am_tools,
       
  1530 			error_complete(
       
  1531 				status,
       
  1532 				internal_settings,
       
  1533 				error_completion_function));
       
  1534 	}
       
  1535 
       
  1536 	// Add the rest of the implemented EAP-methods to the disabled EAP-methods.
       
  1537 	for (TInt plugin_ind = 0; plugin_ind < plugins_array.Count(); ++plugin_ind)
       
  1538 	{
       
  1539 		const TEapExpandedType * eap_type = plugins_array[plugin_ind];
       
  1540 		if (eap_type == 0)
       
  1541 		{
       
  1542 			return EAP_STATUS_RETURN(
       
  1543 				m_am_tools,
       
  1544 				error_complete(
       
  1545 					eap_status_allocation_error,
       
  1546 					internal_settings,
       
  1547 					error_completion_function));
       
  1548 		}
       
  1549 
       
  1550 		const eap_type_value_e common_eap_type(
       
  1551 			static_cast<eap_type_vendor_id_e>(eap_type->GetVendorId()),
       
  1552 			eap_type->GetVendorType());
       
  1553 
       
  1554 		EAP_TRACE_DEBUG(
       
  1555 			m_am_tools,
       
  1556 			TRACE_FLAGS_DEFAULT,
       
  1557 			(EAPL("eap_am_general_settings_symbian_c::get_eap_methods(): Adds disabled EAP-type=0xfe%06x%08x\n"),
       
  1558 			eap_type->GetVendorId(),
       
  1559 			eap_type->GetVendorType()));
       
  1560 
       
  1561 		status = complete_settings->m_disabled_eap_methods.add_object(common_eap_type.copy(), true);
       
  1562 		if (status != eap_status_ok)
       
  1563 		{
       
  1564 			return EAP_STATUS_RETURN(
       
  1565 				m_am_tools,
       
  1566 				error_complete(
       
  1567 					status,
       
  1568 					internal_settings,
       
  1569 					error_completion_function));
       
  1570 		}
       
  1571 	} // for()
       
  1572 
       
  1573 	complete_settings->m_SelectedEAPTypesPresent = true;
       
  1574 
       
  1575 	complete_settings->m_completion_status = eap_status_ok;
       
  1576 	complete_settings->m_EAPType = internal_settings->m_EAPType;
       
  1577 	complete_settings->m_IndexType = internal_settings->m_IndexType;
       
  1578 	complete_settings->m_Index = internal_settings->m_Index;
       
  1579 
       
  1580 	status = m_partner->complete_get_eap_methods(complete_settings);
       
  1581 
       
  1582 
       
  1583 	iGeneralSettingsDb.Compact();
       
  1584 
       
  1585 	CloseGeneralSettings();
       
  1586 
       
  1587 	EAP_TRACE_DEBUG(
       
  1588 		m_am_tools,
       
  1589 		TRACE_FLAGS_DEFAULT,
       
  1590 		(EAPL("eap_am_general_settings_symbian_c::get_eap_methods(): this=0x%08x, CloseGeneralSettings()\n"),
       
  1591 		this));
       
  1592 
       
  1593 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1594 }
       
  1595 
       
  1596 // ----------------------------------------------------------------------
       
  1597 
       
  1598 eap_status_e eap_am_general_settings_symbian_c::set_eap_methods(const eap_method_settings_c * const internal_settings)
       
  1599 {
       
  1600 	EAP_TRACE_DEBUG(
       
  1601 		m_am_tools,
       
  1602 		TRACE_FLAGS_DEFAULT,
       
  1603 		(EAPL("eap_am_general_settings_symbian_c::set_eap_methods(): this=0x%08x.\n"),
       
  1604 		this));
       
  1605 
       
  1606 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_general_settings_symbian_c::set_eap_methods()");
       
  1607 
       
  1608 	const eap_tlv_message_type_function_e error_completion_function(eap_tlv_message_type_function_general_settings_complete_set_eap_methods);
       
  1609 
       
  1610 	TInt error = KErrNone;
       
  1611 
       
  1612 	TRAP(error, (OpenGeneralSettingsL()));
       
  1613 
       
  1614 	if (error != KErrNone)
       
  1615 	{
       
  1616 		EAP_TRACE_ERROR(
       
  1617 			m_am_tools,
       
  1618 			TRACE_FLAGS_ERROR,
       
  1619 			(EAPL("ERROR: eap_am_general_settings_symbian_c::set_eap_methods(): OpenGeneralSettingsL() failed, EAP-type=0xfe%06x%08x, index_type=%d, index=%d, error=%d.\n"),
       
  1620 			internal_settings->m_EAPType.get_vendor_id(),
       
  1621 			internal_settings->m_EAPType.get_vendor_type(),
       
  1622 			internal_settings->m_IndexType,
       
  1623 			internal_settings->m_Index,
       
  1624 			error));
       
  1625 
       
  1626 		return EAP_STATUS_RETURN(
       
  1627 			m_am_tools,
       
  1628 			error_complete(
       
  1629 				m_am_tools->convert_am_error_to_eapol_error(error),
       
  1630 				internal_settings,
       
  1631 				error_completion_function));
       
  1632 	}
       
  1633 
       
  1634 
       
  1635 	HBufC8 *aEnabledEapMethods = 0;
       
  1636 	HBufC8 *aDisabledEapMethods = 0;
       
  1637 
       
  1638 	error = CEapConversion::ConvertInternalTypesToHBufC8(
       
  1639 		m_am_tools,
       
  1640 		&(internal_settings->m_active_eap_methods),
       
  1641 		&aEnabledEapMethods);
       
  1642 
       
  1643 	eap_automatic_variable_c<HBufC8> automatic_aEnabledEapMethods(
       
  1644 		m_am_tools,
       
  1645 		aEnabledEapMethods);
       
  1646 
       
  1647 	if (error != KErrNone)
       
  1648 	{
       
  1649 		EAP_TRACE_ERROR(
       
  1650 			m_am_tools,
       
  1651 			TRACE_FLAGS_ERROR,
       
  1652 			(EAPL("ERROR: eap_am_general_settings_symbian_c::set_eap_methods(): EAP-type=0xfe%06x%08x, index_type=%d, index=%d.\n"),
       
  1653 			internal_settings->m_EAPType.get_vendor_id(),
       
  1654 			internal_settings->m_EAPType.get_vendor_type(),
       
  1655 			internal_settings->m_IndexType,
       
  1656 			internal_settings->m_Index));
       
  1657 		return EAP_STATUS_RETURN(
       
  1658 			m_am_tools,
       
  1659 			error_complete(
       
  1660 				m_am_tools->convert_am_error_to_eapol_error(error),
       
  1661 				internal_settings,
       
  1662 				error_completion_function));
       
  1663 	}
       
  1664 
       
  1665 	error = CEapConversion::ConvertInternalTypesToHBufC8(
       
  1666 		m_am_tools,
       
  1667 		&(internal_settings->m_disabled_eap_methods),
       
  1668 		&aDisabledEapMethods);
       
  1669 
       
  1670 	eap_automatic_variable_c<HBufC8> automatic_aDisabledEapMethods(
       
  1671 		m_am_tools,
       
  1672 		aDisabledEapMethods);
       
  1673 
       
  1674 	if (error != KErrNone)
       
  1675 	{
       
  1676 		EAP_TRACE_ERROR(
       
  1677 			m_am_tools,
       
  1678 			TRACE_FLAGS_ERROR,
       
  1679 			(EAPL("ERROR: eap_am_general_settings_symbian_c::set_eap_methods(): EAP-type=0xfe%06x%08x, index_type=%d, index=%d.\n"),
       
  1680 			internal_settings->m_EAPType.get_vendor_id(),
       
  1681 			internal_settings->m_EAPType.get_vendor_type(),
       
  1682 			internal_settings->m_IndexType,
       
  1683 			internal_settings->m_Index));
       
  1684 		return EAP_STATUS_RETURN(
       
  1685 			m_am_tools,
       
  1686 			error_complete(
       
  1687 				m_am_tools->convert_am_error_to_eapol_error(error),
       
  1688 				internal_settings,
       
  1689 				error_completion_function));
       
  1690 	}
       
  1691 
       
  1692 	TRAP(error, (SetGeneralSettingsDataL(
       
  1693 		internal_settings->m_IndexType,
       
  1694 		internal_settings->m_Index,
       
  1695 		*aEnabledEapMethods,
       
  1696 		*aDisabledEapMethods)));
       
  1697 	if (error != KErrNone)
       
  1698 	{
       
  1699 		EAP_TRACE_ERROR(
       
  1700 			m_am_tools,
       
  1701 			TRACE_FLAGS_ERROR,
       
  1702 			(EAPL("ERROR: eap_am_general_settings_symbian_c::set_eap_methods(): EAP-type=0xfe%06x%08x, index_type=%d, index=%d.\n"),
       
  1703 			internal_settings->m_EAPType.get_vendor_id(),
       
  1704 			internal_settings->m_EAPType.get_vendor_type(),
       
  1705 			internal_settings->m_IndexType,
       
  1706 			internal_settings->m_Index));
       
  1707 		return EAP_STATUS_RETURN(
       
  1708 			m_am_tools,
       
  1709 			error_complete(
       
  1710 				m_am_tools->convert_am_error_to_eapol_error(error),
       
  1711 				internal_settings,
       
  1712 				error_completion_function));
       
  1713 	}
       
  1714 
       
  1715 	eap_method_settings_c * const complete_settings = new eap_method_settings_c(m_am_tools);
       
  1716 
       
  1717 	eap_automatic_variable_c<eap_method_settings_c> automatic_complete_settings(
       
  1718 		m_am_tools,
       
  1719 		complete_settings);
       
  1720 
       
  1721 	if (complete_settings == 0)
       
  1722 	{
       
  1723 		return EAP_STATUS_RETURN(
       
  1724 			m_am_tools,
       
  1725 			error_complete(
       
  1726 				eap_status_allocation_error,
       
  1727 				internal_settings,
       
  1728 				error_completion_function));
       
  1729 	}
       
  1730 
       
  1731 	complete_settings->m_completion_status = eap_status_ok;
       
  1732 	complete_settings->m_EAPType = internal_settings->m_EAPType;
       
  1733 	complete_settings->m_IndexType = internal_settings->m_IndexType;
       
  1734 	complete_settings->m_Index = internal_settings->m_Index;
       
  1735 
       
  1736 	eap_status_e status = m_partner->complete_set_eap_methods(complete_settings);
       
  1737 
       
  1738 	iGeneralSettingsDb.Compact();
       
  1739 
       
  1740 	CloseGeneralSettings();
       
  1741 
       
  1742 	EAP_TRACE_DEBUG(
       
  1743 		m_am_tools,
       
  1744 		TRACE_FLAGS_DEFAULT,
       
  1745 		(EAPL("eap_am_general_settings_symbian_c::set_eap_methods(): this=0x%08x, CloseGeneralSettings()\n"),
       
  1746 		this));
       
  1747 
       
  1748 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1749 }
       
  1750 
       
  1751 // ----------------------------------------------------------------------
       
  1752 
       
  1753 eap_status_e eap_am_general_settings_symbian_c::get_certificate_lists(const eap_method_settings_c * const internal_settings)
       
  1754 {
       
  1755 	EAP_TRACE_DEBUG(
       
  1756 		m_am_tools,
       
  1757 		TRACE_FLAGS_DEFAULT,
       
  1758 		(EAPL("eap_am_general_settings_symbian_c::get_certificate_lists(): this=0x%08x.\n"),
       
  1759 		this));
       
  1760 
       
  1761 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_general_settings_symbian_c::get_certificate_lists()");
       
  1762 
       
  1763 	TInt error(KErrNone);
       
  1764 
       
  1765 	const eap_tlv_message_type_function_e error_completion_function(eap_tlv_message_type_function_general_settings_complete_get_certificate_lists);
       
  1766 
       
  1767 	if (iCertificateFetcher == 0)
       
  1768 	{
       
  1769 		TRAP(error, iCertificateFetcher = CEapTlsPeapCertFetcher::NewL(this));
       
  1770 		if (error != KErrNone)
       
  1771 		{
       
  1772 			EAP_TRACE_ERROR(
       
  1773 				m_am_tools,
       
  1774 				TRACE_FLAGS_ERROR,
       
  1775 				(EAPL("ERROR: eap_am_general_settings_symbian_c::get_certificate_lists(): this=0x%08x: CEapTlsPeapCertFetcher::NewL() failed=%d\n"),
       
  1776 				this,
       
  1777 				error));
       
  1778 
       
  1779 			eap_method_settings_c * const complete_settings = new eap_method_settings_c(m_am_tools);
       
  1780 
       
  1781 			eap_automatic_variable_c<eap_method_settings_c> automatic_complete_settings(
       
  1782 				m_am_tools,
       
  1783 				complete_settings);
       
  1784 
       
  1785 			return EAP_STATUS_RETURN(
       
  1786 				m_am_tools,
       
  1787 				error_complete(
       
  1788 					m_am_tools->convert_am_error_to_eapol_error(error),
       
  1789 					complete_settings,
       
  1790 					error_completion_function));
       
  1791 		}
       
  1792 	}
       
  1793 
       
  1794 	m_completion_status = internal_settings->m_completion_status;
       
  1795 	m_EAPType = internal_settings->m_EAPType;
       
  1796 	m_IndexType = internal_settings->m_IndexType;
       
  1797 	m_Index = internal_settings->m_Index;
       
  1798 
       
  1799 	TRAP(error, (iCertificateFetcher->GetCertificatesL()));
       
  1800 	if (error != KErrNone)
       
  1801 	{
       
  1802 		EAP_TRACE_ERROR(
       
  1803 			m_am_tools,
       
  1804 			TRACE_FLAGS_ERROR,
       
  1805 			(EAPL("ERROR: eap_am_general_settings_symbian_c::get_certificate_lists(): iCertificateFetcher->GetCertificatesL(), error=%d\n"),
       
  1806 			error));
       
  1807 		return EAP_STATUS_RETURN(
       
  1808 			m_am_tools,
       
  1809 			error_complete(
       
  1810 				m_am_tools->convert_am_error_to_eapol_error(error),
       
  1811 				internal_settings,
       
  1812 				error_completion_function));
       
  1813 	}
       
  1814 
       
  1815 	CloseGeneralSettings();
       
  1816 
       
  1817 	EAP_TRACE_DEBUG(
       
  1818 		m_am_tools,
       
  1819 		TRACE_FLAGS_DEFAULT,
       
  1820 		(EAPL("eap_am_general_settings_symbian_c::get_certificate_lists(): this=0x%08x, CloseGeneralSettings()\n"),
       
  1821 		this));
       
  1822 
       
  1823 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
  1824 }
       
  1825 
       
  1826 // ----------------------------------------------------------
       
  1827 
       
  1828 void eap_am_general_settings_symbian_c::CompleteReadCertificatesL(
       
  1829 		const RPointerArray<EapCertificateEntry>& aAvailableUserCerts, 
       
  1830 		const RPointerArray<EapCertificateEntry>& aAvailableCACerts)
       
  1831 {
       
  1832 	EAP_TRACE_DEBUG(
       
  1833 		m_am_tools,
       
  1834 		TRACE_FLAGS_DEFAULT,
       
  1835 		(EAPL("eap_am_general_settings_symbian_c::CompleteReadCertificatesL(): - Available cert count in device - USER=%d, CA=%d \n"),
       
  1836 		aAvailableUserCerts.Count(),
       
  1837 		aAvailableCACerts.Count()));
       
  1838 
       
  1839 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_general_settings_symbian_c::CompleteReadCertificatesL()");
       
  1840 
       
  1841 	// Now all available certificates have been read.
       
  1842 
       
  1843 	const eap_tlv_message_type_function_e error_completion_function(eap_tlv_message_type_function_general_settings_complete_get_certificate_lists);
       
  1844 
       
  1845 	eap_method_settings_c * const complete_settings = new eap_method_settings_c(m_am_tools);
       
  1846 
       
  1847 	eap_automatic_variable_c<eap_method_settings_c> automatic_complete_settings(
       
  1848 		m_am_tools,
       
  1849 		complete_settings);
       
  1850 
       
  1851 	if (complete_settings == 0)
       
  1852 	{
       
  1853 		(void) EAP_STATUS_RETURN(m_am_tools, error_complete(
       
  1854 			eap_status_allocation_error,
       
  1855 			complete_settings,
       
  1856 			error_completion_function));
       
  1857 	}
       
  1858 
       
  1859 	TInt error = CEapConversion::ConvertCertificatesToInternalType(
       
  1860 		m_am_tools,
       
  1861 		&aAvailableUserCerts,
       
  1862 		&(complete_settings->m_Certificates));
       
  1863 	if (error != KErrNone)
       
  1864 	{
       
  1865 		(void) EAP_STATUS_RETURN(m_am_tools, error_complete(
       
  1866 			m_am_tools->convert_am_error_to_eapol_error(error),
       
  1867 			complete_settings,
       
  1868 			error_completion_function));
       
  1869 	}
       
  1870 
       
  1871 	error = CEapConversion::ConvertCertificatesToInternalType(
       
  1872 		m_am_tools,
       
  1873 		&aAvailableCACerts,
       
  1874 		&(complete_settings->m_Certificates));
       
  1875 	if (error != KErrNone)
       
  1876 	{
       
  1877 		(void) EAP_STATUS_RETURN(m_am_tools, error_complete(
       
  1878 			m_am_tools->convert_am_error_to_eapol_error(error),
       
  1879 			complete_settings,
       
  1880 			error_completion_function));
       
  1881 	}
       
  1882 
       
  1883 	complete_settings->m_CertificatesPresent = true;
       
  1884 
       
  1885 	complete_settings->m_completion_status = eap_status_ok;
       
  1886 	complete_settings->m_EAPType = m_EAPType;
       
  1887 	complete_settings->m_IndexType = m_IndexType;
       
  1888 	complete_settings->m_Index = m_Index;
       
  1889 
       
  1890 	eap_status_e status = m_partner->complete_get_certificate_lists(complete_settings);
       
  1891 
       
  1892 	(void) EAP_STATUS_RETURN(m_am_tools, status);
       
  1893 	EAP_UNREFERENCED_PARAMETER(status);
       
  1894 }
       
  1895 
       
  1896 // ----------------------------------------------------------------------
       
  1897 
       
  1898 eap_status_e eap_am_general_settings_symbian_c::delete_all_eap_settings(const eap_method_settings_c * const internal_settings)
       
  1899 {
       
  1900 	EAP_TRACE_DEBUG(
       
  1901 		m_am_tools,
       
  1902 		TRACE_FLAGS_DEFAULT,
       
  1903 		(EAPL("eap_am_general_settings_symbian_c::delete_all_eap_settings(): this=0x%08x.\n"),
       
  1904 		this));
       
  1905 
       
  1906 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_general_settings_symbian_c::delete_all_eap_settings()");
       
  1907 
       
  1908 	const eap_tlv_message_type_function_e error_completion_function(eap_tlv_message_type_function_general_settings_complete_delete_all_eap_settings);
       
  1909 
       
  1910 	TInt error(KErrNone);
       
  1911 
       
  1912 	TRAP(error, (OpenGeneralSettingsL()));
       
  1913 
       
  1914 	if (error != KErrNone)
       
  1915 	{
       
  1916 		EAP_TRACE_ERROR(
       
  1917 			m_am_tools,
       
  1918 			TRACE_FLAGS_ERROR,
       
  1919 			(EAPL("ERROR: eap_am_general_settings_symbian_c::delete_all_eap_settings(): OpenGeneralSettingsL() failed, EAP-type=0xfe%06x%08x, index_type=%d, index=%d, error=%d.\n"),
       
  1920 			internal_settings->m_EAPType.get_vendor_id(),
       
  1921 			internal_settings->m_EAPType.get_vendor_type(),
       
  1922 			internal_settings->m_IndexType,
       
  1923 			internal_settings->m_Index,
       
  1924 			error));
       
  1925 
       
  1926 		return EAP_STATUS_RETURN(
       
  1927 			m_am_tools,
       
  1928 			error_complete(
       
  1929 				m_am_tools->convert_am_error_to_eapol_error(error),
       
  1930 				internal_settings,
       
  1931 				error_completion_function));
       
  1932 	}
       
  1933 
       
  1934 	eap_method_settings_c * const complete_settings = new eap_method_settings_c(m_am_tools);
       
  1935 
       
  1936 	eap_automatic_variable_c<eap_method_settings_c> automatic_complete_settings(
       
  1937 		m_am_tools,
       
  1938 		complete_settings);
       
  1939 
       
  1940 	if (complete_settings == 0)
       
  1941 	{
       
  1942 		return EAP_STATUS_RETURN(
       
  1943 			m_am_tools,
       
  1944 			error_complete(
       
  1945 				eap_status_allocation_error,
       
  1946 				internal_settings,
       
  1947 				error_completion_function));
       
  1948 	}
       
  1949 
       
  1950 	EAP_TRACE_DEBUG(
       
  1951 		m_am_tools,
       
  1952 		TRACE_FLAGS_DEFAULT,
       
  1953 		(EAPL("eap_am_general_settings_symbian_c::delete_all_eap_settings(): this=0x%08x: DeleteGeneralSettingsDataL(): EAP-type=0xfe%06x%08x, index_type=%d, index=%d\n"),
       
  1954 		this,
       
  1955 		internal_settings->m_EAPType.get_vendor_id(),
       
  1956 		internal_settings->m_EAPType.get_vendor_type(),
       
  1957 		internal_settings->m_IndexType,
       
  1958 		internal_settings->m_Index));
       
  1959 
       
  1960 	TRAP(error, (DeleteGeneralSettingsDataL(
       
  1961 		internal_settings->m_IndexType,
       
  1962 		internal_settings->m_Index)));
       
  1963 	if (error != KErrNone)
       
  1964 	{
       
  1965 		EAP_TRACE_ERROR(
       
  1966 			m_am_tools,
       
  1967 			TRACE_FLAGS_ERROR,
       
  1968 			(EAPL("ERROR: eap_am_general_settings_symbian_c::delete_all_eap_settings(): EAP-type=0xfe%06x%08x, index_type=%d, index=%d.\n"),
       
  1969 			internal_settings->m_EAPType.get_vendor_id(),
       
  1970 			internal_settings->m_EAPType.get_vendor_type(),
       
  1971 			internal_settings->m_IndexType,
       
  1972 			internal_settings->m_Index));
       
  1973 		return EAP_STATUS_RETURN(
       
  1974 			m_am_tools,
       
  1975 			error_complete(
       
  1976 				m_am_tools->convert_am_error_to_eapol_error(error),
       
  1977 				internal_settings,
       
  1978 				error_completion_function));
       
  1979 	}
       
  1980 
       
  1981 	{
       
  1982 		RPointerArray<TEapExpandedType> plugins_array;
       
  1983 
       
  1984 		PointerArrayResetAndDestroy<TEapExpandedType> aAutomaticPlugins(&plugins_array, EFalse);
       
  1985 
       
  1986 		EapPluginTools aPluginTool;
       
  1987 
       
  1988 		TEapExpandedType aTunnelingType(*EapExpandedTypeNone.GetType());
       
  1989 
       
  1990 		EAP_TRACE_DEBUG(
       
  1991 			m_am_tools,
       
  1992 			TRACE_FLAGS_DEFAULT,
       
  1993 			(EAPL("eap_am_general_settings_symbian_c::delete_all_eap_settings(): this=0x%08x: aPluginTool.ListAllEapPluginsL(): tunneling EAP-type=0xfe%06x%08x, index_type=%d, index=%d\n"),
       
  1994 			this,
       
  1995 			aTunnelingType.GetVendorId(),
       
  1996 			aTunnelingType.GetVendorType(),
       
  1997 			internal_settings->m_IndexType,
       
  1998 			internal_settings->m_Index));
       
  1999 
       
  2000 		// This will list all outer EAP-methods because aTunnelingType = None.
       
  2001 		TRAP(error, (aPluginTool.ListAllEapPluginsL(static_cast<TIndexType>(internal_settings->m_IndexType), aTunnelingType, plugins_array)));
       
  2002 		if (error != KErrNone)
       
  2003 		{
       
  2004 			EAP_TRACE_ERROR(
       
  2005 				m_am_tools,
       
  2006 				TRACE_FLAGS_ERROR,
       
  2007 				(EAPL("ERROR: eap_am_general_settings_symbian_c::delete_all_eap_settings(): aPluginTool.ListAllEapPluginsL() failed, tunneling EAP-type=0xfe%06x%08x, index_type=%d, index=%d, error=%d.\n"),
       
  2008 				aTunnelingType.GetVendorId(),
       
  2009 				aTunnelingType.GetVendorType(),
       
  2010 				internal_settings->m_IndexType,
       
  2011 				internal_settings->m_Index,
       
  2012 				error));
       
  2013 
       
  2014 			return EAP_STATUS_RETURN(
       
  2015 				m_am_tools,
       
  2016 				error_complete(
       
  2017 					m_am_tools->convert_am_error_to_eapol_error(error),
       
  2018 					internal_settings,
       
  2019 					error_completion_function));
       
  2020 		}
       
  2021 
       
  2022 		TUint ind_outer(0ul);
       
  2023 
       
  2024 		for (ind_outer = 0ul; ind_outer < plugins_array.Count(); ++ind_outer)
       
  2025 		{
       
  2026 
       
  2027 			// List all plugins that could be used inside the each outer EAP-method on each plugin.
       
  2028 
       
  2029 			RPointerArray<TEapExpandedType> tunneled_plugins;
       
  2030 
       
  2031 			PointerArrayResetAndDestroy<TEapExpandedType> aAutomaticTunneledPlugins(&tunneled_plugins, EFalse);
       
  2032 
       
  2033 			EAP_TRACE_DEBUG(
       
  2034 				m_am_tools,
       
  2035 				TRACE_FLAGS_DEFAULT,
       
  2036 				(EAPL("eap_am_general_settings_symbian_c::delete_all_eap_settings(): this=0x%08x: aPluginTool.ListAllEapPluginsL(): tunneling EAP-type=0xfe%06x%08x, index_type=%d, index=%d\n"),
       
  2037 				this,
       
  2038 				plugins_array[ind_outer]->GetVendorId(),
       
  2039 				plugins_array[ind_outer]->GetVendorType(),
       
  2040 				internal_settings->m_IndexType,
       
  2041 				internal_settings->m_Index));
       
  2042 
       
  2043 			// This will list all inner EAP-methods of EAP-type.
       
  2044 			TRAP(error, (aPluginTool.ListAllEapPluginsL(static_cast<TIndexType>(internal_settings->m_IndexType), plugins_array[ind_outer], tunneled_plugins)));
       
  2045 			if (error != KErrNone)
       
  2046 			{
       
  2047 				EAP_TRACE_ERROR(
       
  2048 					m_am_tools,
       
  2049 					TRACE_FLAGS_ERROR,
       
  2050 					(EAPL("ERROR: eap_am_general_settings_symbian_c::delete_all_eap_settings(): aPluginTool.ListAllEapPluginsL() failed, tunneling EAP-type=0xfe%06x%08x, index_type=%d, index=%d, error=%d.\n"),
       
  2051 					plugins_array[ind_outer]->GetVendorId(),
       
  2052 					plugins_array[ind_outer]->GetVendorType(),
       
  2053 					internal_settings->m_IndexType,
       
  2054 					internal_settings->m_Index,
       
  2055 					error));
       
  2056 
       
  2057 				return EAP_STATUS_RETURN(
       
  2058 					m_am_tools,
       
  2059 					error_complete(
       
  2060 						m_am_tools->convert_am_error_to_eapol_error(error),
       
  2061 						internal_settings,
       
  2062 						error_completion_function));
       
  2063 			}
       
  2064 
       
  2065 
       
  2066 			// Delete possible configuration of each inner EAP-method that could be configured inside of outer EAP-method.
       
  2067 
       
  2068 			TUint ind_inner(0ul);
       
  2069 
       
  2070 			for (ind_inner = 0ul; ind_inner < tunneled_plugins.Count(); ++ind_inner)
       
  2071 			{
       
  2072 				CEapTypePlugin * eapType = NULL;
       
  2073 
       
  2074 				EAP_TRACE_DEBUG(
       
  2075 					m_am_tools,
       
  2076 					TRACE_FLAGS_DEFAULT,
       
  2077 					(EAPL("eap_am_general_settings_symbian_c::delete_all_eap_settings(): this=0x%08x: CEapTypePlugin::NewL(): EAP-type=0xfe%06x%08x, index_type=%d, index=%d\n"),
       
  2078 					this,
       
  2079 					tunneled_plugins[ind_inner]->GetVendorId(),
       
  2080 					tunneled_plugins[ind_inner]->GetVendorType(),
       
  2081 					internal_settings->m_IndexType,
       
  2082 					internal_settings->m_Index));
       
  2083 
       
  2084 				TRAP(error, (eapType = CEapTypePlugin::NewL(
       
  2085 					tunneled_plugins[ind_inner]->GetValue(),
       
  2086 					static_cast<TIndexType>(internal_settings->m_IndexType),
       
  2087 					internal_settings->m_Index)));
       
  2088 
       
  2089 				// This will automatically delete eapType.
       
  2090 				eap_automatic_variable_c<CEapTypePlugin> automatic_eap_type(
       
  2091 					m_am_tools,
       
  2092 					eapType);
       
  2093 
       
  2094 				if(error != KErrNone
       
  2095 					|| eapType == NULL)
       
  2096 				{
       
  2097 					EAP_TRACE_ERROR(
       
  2098 						m_am_tools,
       
  2099 						TRACE_FLAGS_ERROR,
       
  2100 						(EAPL("ERROR: eap_am_general_settings_symbian_c::delete_all_eap_settings(): CEapTypePlugin::NewL() failed, EAP-type=0xfe%06x%08x, index_type=%d, index=%d, error=%d.\n"),
       
  2101 						tunneled_plugins[ind_inner]->GetVendorId(),
       
  2102 						tunneled_plugins[ind_inner]->GetVendorType(),
       
  2103 						internal_settings->m_IndexType,
       
  2104 						internal_settings->m_Index,
       
  2105 						error));
       
  2106 
       
  2107 					return EAP_STATUS_RETURN(
       
  2108 						m_am_tools,
       
  2109 						error_complete(
       
  2110 							m_am_tools->convert_am_error_to_eapol_error(error),
       
  2111 							internal_settings,
       
  2112 							error_completion_function));
       
  2113 				}
       
  2114 				
       
  2115 			    eapType->SetTunnelingType(plugins_array[ind_outer]);
       
  2116 
       
  2117 				EAP_TRACE_DEBUG(
       
  2118 					m_am_tools,
       
  2119 					TRACE_FLAGS_DEFAULT,
       
  2120 					(EAPL("eap_am_general_settings_symbian_c::delete_all_eap_settings(): this=0x%08x: eapType->DeleteConfigurationL(): EAP-type=0xfe%06x%08x, index_type=%d, index=%d\n"),
       
  2121 					this,
       
  2122 					tunneled_plugins[ind_inner]->GetVendorId(),
       
  2123 					tunneled_plugins[ind_inner]->GetVendorType(),
       
  2124 					internal_settings->m_IndexType,
       
  2125 					internal_settings->m_Index));
       
  2126 
       
  2127 				TRAP(error, (eapType->DeleteConfigurationL()));
       
  2128 				if(error != KErrNone)
       
  2129 				{
       
  2130 					EAP_TRACE_ERROR(
       
  2131 						m_am_tools,
       
  2132 						TRACE_FLAGS_ERROR,
       
  2133 						(EAPL("ERROR: eap_am_general_settings_symbian_c::delete_all_eap_settings(): eapType->DeleteConfigurationL() failed, EAP-type=0xfe%06x%08x, index_type=%d, index=%d, error=%d.\n"),
       
  2134 						tunneled_plugins[ind_inner]->GetVendorId(),
       
  2135 						tunneled_plugins[ind_inner]->GetVendorType(),
       
  2136 						internal_settings->m_IndexType,
       
  2137 						internal_settings->m_Index,
       
  2138 						error));
       
  2139 
       
  2140 					return EAP_STATUS_RETURN(
       
  2141 						m_am_tools,
       
  2142 						error_complete(
       
  2143 							m_am_tools->convert_am_error_to_eapol_error(error),
       
  2144 							internal_settings,
       
  2145 							error_completion_function));
       
  2146 				}
       
  2147 
       
  2148 			} // for()
       
  2149 
       
  2150 
       
  2151 			{
       
  2152 
       
  2153 				// Delete possible configuration of each outer EAP-method on each plugin.
       
  2154 
       
  2155 				EAP_TRACE_DEBUG(
       
  2156 					m_am_tools,
       
  2157 					TRACE_FLAGS_DEFAULT,
       
  2158 					(EAPL("eap_am_general_settings_symbian_c::delete_all_eap_settings(): this=0x%08x: CEapTypePlugin::NewL(): outer EAP-type=0xfe%06x%08x, index_type=%d, index=%d\n"),
       
  2159 					this,
       
  2160 					plugins_array[ind_outer]->GetVendorId(),
       
  2161 					plugins_array[ind_outer]->GetVendorType(),
       
  2162 					internal_settings->m_IndexType,
       
  2163 					internal_settings->m_Index));
       
  2164 
       
  2165 				CEapTypePlugin * eapType = NULL;
       
  2166 
       
  2167 				TRAP(error, (eapType = CEapTypePlugin::NewL(
       
  2168 					plugins_array[ind_outer]->GetValue(),
       
  2169 					static_cast<TIndexType>(internal_settings->m_IndexType),
       
  2170 					internal_settings->m_Index)));
       
  2171 
       
  2172 				// This will automatically delete eapType.
       
  2173 				eap_automatic_variable_c<CEapTypePlugin> automatic_eap_type(
       
  2174 					m_am_tools,
       
  2175 					eapType);
       
  2176 				
       
  2177 				if(error != KErrNone
       
  2178 					|| eapType == NULL)
       
  2179 				{
       
  2180 					EAP_TRACE_ERROR(
       
  2181 						m_am_tools,
       
  2182 						TRACE_FLAGS_ERROR,
       
  2183 						(EAPL("ERROR: eap_am_general_settings_symbian_c::delete_all_eap_settings(): CEapTypePlugin::NewL() failed, outer EAP-type=0xfe%06x%08x, index_type=%d, index=%d, error=%d.\n"),
       
  2184 						plugins_array[ind_outer]->GetVendorId(),
       
  2185 						plugins_array[ind_outer]->GetVendorType(),
       
  2186 						internal_settings->m_IndexType,
       
  2187 						internal_settings->m_Index,
       
  2188 						error));
       
  2189 
       
  2190 					return EAP_STATUS_RETURN(
       
  2191 						m_am_tools,
       
  2192 						error_complete(
       
  2193 							m_am_tools->convert_am_error_to_eapol_error(error),
       
  2194 							internal_settings,
       
  2195 							error_completion_function));
       
  2196 				}
       
  2197 				
       
  2198 				EAP_TRACE_DEBUG(
       
  2199 					m_am_tools,
       
  2200 					TRACE_FLAGS_DEFAULT,
       
  2201 					(EAPL("eap_am_general_settings_symbian_c::delete_all_eap_settings(): this=0x%08x: eapType->DeleteConfigurationL(): outer EAP-type=0xfe%06x%08x, index_type=%d, index=%d\n"),
       
  2202 					this,
       
  2203 					plugins_array[ind_outer]->GetVendorId(),
       
  2204 					plugins_array[ind_outer]->GetVendorType(),
       
  2205 					internal_settings->m_IndexType,
       
  2206 					internal_settings->m_Index));
       
  2207 
       
  2208 				TRAP(error, (eapType->DeleteConfigurationL()));
       
  2209 				if(error != KErrNone)
       
  2210 				{
       
  2211 					EAP_TRACE_ERROR(
       
  2212 						m_am_tools,
       
  2213 						TRACE_FLAGS_ERROR,
       
  2214 						(EAPL("ERROR: eap_am_general_settings_symbian_c::delete_all_eap_settings(): eapType->DeleteConfigurationL() failed, outer EAP-type=0xfe%06x%08x, index_type=%d, index=%d, error=%d.\n"),
       
  2215 						plugins_array[ind_outer]->GetVendorId(),
       
  2216 						plugins_array[ind_outer]->GetVendorType(),
       
  2217 						internal_settings->m_IndexType,
       
  2218 						internal_settings->m_Index,
       
  2219 						error));
       
  2220 
       
  2221 					return EAP_STATUS_RETURN(
       
  2222 						m_am_tools,
       
  2223 						error_complete(
       
  2224 							m_am_tools->convert_am_error_to_eapol_error(error),
       
  2225 							internal_settings,
       
  2226 							error_completion_function));
       
  2227 				}
       
  2228 			}
       
  2229 
       
  2230 		} // for()
       
  2231 
       
  2232 	}
       
  2233 
       
  2234 	complete_settings->m_completion_status = eap_status_ok;
       
  2235 	complete_settings->m_EAPType = internal_settings->m_EAPType;
       
  2236 	complete_settings->m_IndexType = internal_settings->m_IndexType;
       
  2237 	complete_settings->m_Index = internal_settings->m_Index;
       
  2238 
       
  2239 	eap_status_e status = m_partner->complete_delete_all_eap_settings(complete_settings);
       
  2240 
       
  2241 	iGeneralSettingsDb.Compact();
       
  2242 
       
  2243 	CloseGeneralSettings();
       
  2244 
       
  2245 	EAP_TRACE_DEBUG(
       
  2246 		m_am_tools,
       
  2247 		TRACE_FLAGS_DEFAULT,
       
  2248 		(EAPL("eap_am_general_settings_symbian_c::delete_all_eap_settings(): this=0x%08x, CloseGeneralSettings()\n"),
       
  2249 		this));
       
  2250 
       
  2251 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  2252 }
       
  2253 
       
  2254 // ----------------------------------------------------------------------
       
  2255 
       
  2256 eap_status_e eap_am_general_settings_symbian_c::copy_all_eap_settings(const eap_method_settings_c * const internal_settings)
       
  2257 {
       
  2258 	EAP_TRACE_DEBUG(
       
  2259 		m_am_tools,
       
  2260 		TRACE_FLAGS_DEFAULT,
       
  2261 		(EAPL("eap_am_general_settings_symbian_c::copy_all_eap_settings(): this=0x%08x.\n"),
       
  2262 		this));
       
  2263 
       
  2264 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_general_settings_symbian_c::copy_all_eap_settings()");
       
  2265 
       
  2266 	const eap_tlv_message_type_function_e error_completion_function(eap_tlv_message_type_function_general_settings_complete_copy_all_eap_settings);
       
  2267 
       
  2268 	TInt error(KErrNone);
       
  2269 
       
  2270 	TRAP(error, (OpenGeneralSettingsL()));
       
  2271 
       
  2272 	if (error != KErrNone)
       
  2273 	{
       
  2274 		EAP_TRACE_ERROR(
       
  2275 			m_am_tools,
       
  2276 			TRACE_FLAGS_ERROR,
       
  2277 			(EAPL("ERROR: eap_am_general_settings_symbian_c::copy_all_eap_settings(): OpenGeneralSettingsL() failed, EAP-type=0xfe%06x%08x, index_type=%d, index=%d, error=%d.\n"),
       
  2278 			internal_settings->m_EAPType.get_vendor_id(),
       
  2279 			internal_settings->m_EAPType.get_vendor_type(),
       
  2280 			internal_settings->m_IndexType,
       
  2281 			internal_settings->m_Index,
       
  2282 			error));
       
  2283 
       
  2284 		return EAP_STATUS_RETURN(
       
  2285 			m_am_tools,
       
  2286 			error_complete(
       
  2287 				m_am_tools->convert_am_error_to_eapol_error(error),
       
  2288 				internal_settings,
       
  2289 				error_completion_function));
       
  2290 	}
       
  2291 
       
  2292 	eap_method_settings_c * const complete_settings = new eap_method_settings_c(m_am_tools);
       
  2293 
       
  2294 	eap_automatic_variable_c<eap_method_settings_c> automatic_complete_settings(
       
  2295 		m_am_tools,
       
  2296 		complete_settings);
       
  2297 
       
  2298 	if (complete_settings == 0)
       
  2299 	{
       
  2300 		return EAP_STATUS_RETURN(
       
  2301 			m_am_tools,
       
  2302 			error_complete(
       
  2303 				eap_status_allocation_error,
       
  2304 				internal_settings,
       
  2305 				error_completion_function));
       
  2306 	}
       
  2307 
       
  2308 	if (internal_settings == 0
       
  2309 		|| internal_settings->m_DestinationIndexAndTypePresent == false)
       
  2310 	{
       
  2311 		// Cannot copy without destination.
       
  2312 		return EAP_STATUS_RETURN(
       
  2313 			m_am_tools,
       
  2314 			error_complete(
       
  2315 				eap_status_illegal_parameter,
       
  2316 				internal_settings,
       
  2317 				error_completion_function));
       
  2318 	}
       
  2319 
       
  2320 	EAP_TRACE_DEBUG(
       
  2321 		m_am_tools,
       
  2322 		TRACE_FLAGS_DEFAULT,
       
  2323 		(EAPL("eap_am_general_settings_symbian_c::copy_all_eap_settings(): this=0x%08x: DeleteGeneralSettingsDataL(): EAP-type=0xfe%06x%08x, m_IndexType=%d, m_Index=%d, m_DestinationIndexType=%d, m_DestinationIndex=%d\n"),
       
  2324 		this,
       
  2325 		internal_settings->m_EAPType.get_vendor_id(),
       
  2326 		internal_settings->m_EAPType.get_vendor_type(),
       
  2327 		internal_settings->m_IndexType,
       
  2328 		internal_settings->m_Index,
       
  2329 		internal_settings->m_DestinationIndexType,
       
  2330 		internal_settings->m_DestinationIndex));
       
  2331 
       
  2332 	TRAP(error, (CopyGeneralSettingsDataL(
       
  2333 		internal_settings->m_IndexType,
       
  2334 		internal_settings->m_Index,
       
  2335 		internal_settings->m_DestinationIndexType,
       
  2336 		internal_settings->m_DestinationIndex)));
       
  2337 	if (error != KErrNone)
       
  2338 	{
       
  2339 		EAP_TRACE_ERROR(
       
  2340 			m_am_tools,
       
  2341 			TRACE_FLAGS_ERROR,
       
  2342 			(EAPL("ERROR: eap_am_general_settings_symbian_c::copy_all_eap_settings(): EAP-type=0xfe%06x%08x, m_IndexType=%d, m_Index=%d, m_DestinationIndexType=%d, m_DestinationIndex=%d, error=%d.\n"),
       
  2343 			internal_settings->m_EAPType.get_vendor_id(),
       
  2344 			internal_settings->m_EAPType.get_vendor_type(),
       
  2345 			internal_settings->m_IndexType,
       
  2346 			internal_settings->m_Index,
       
  2347 			internal_settings->m_DestinationIndexType,
       
  2348 			internal_settings->m_DestinationIndex,
       
  2349 			error));
       
  2350 		return EAP_STATUS_RETURN(
       
  2351 			m_am_tools,
       
  2352 			error_complete(
       
  2353 				m_am_tools->convert_am_error_to_eapol_error(error),
       
  2354 				internal_settings,
       
  2355 				error_completion_function));
       
  2356 	}
       
  2357 
       
  2358 	{
       
  2359 		RPointerArray<TEapExpandedType> plugins;
       
  2360 
       
  2361 		PointerArrayResetAndDestroy<TEapExpandedType> aAutomaticPlugins(&plugins, EFalse);
       
  2362 
       
  2363 		EapPluginTools aPluginTool;
       
  2364 
       
  2365 		TEapExpandedType aTunnelingType(*EapExpandedTypeNone.GetType());
       
  2366 
       
  2367 		EAP_TRACE_DEBUG(
       
  2368 			m_am_tools,
       
  2369 			TRACE_FLAGS_DEFAULT,
       
  2370 			(EAPL("eap_am_general_settings_symbian_c::copy_all_eap_settings(): this=0x%08x: aPluginTool.ListAllEapPluginsL(): tunneling EAP-type=0xfe%06x%08x, m_IndexType=%d, m_Index=%d, m_DestinationIndexType=%d, m_DestinationIndex=%d\n"),
       
  2371 			this,
       
  2372 			aTunnelingType.GetVendorId(),
       
  2373 			aTunnelingType.GetVendorType(),
       
  2374 			internal_settings->m_IndexType,
       
  2375 			internal_settings->m_Index,
       
  2376 			internal_settings->m_DestinationIndexType,
       
  2377 			internal_settings->m_DestinationIndex));
       
  2378 
       
  2379 		// This will list all outer EAP-methods because aTunnelingType = None.
       
  2380 		TRAP(error, (aPluginTool.ListAllEapPluginsL(static_cast<TIndexType>(internal_settings->m_IndexType), aTunnelingType, plugins)));
       
  2381 		if (error != KErrNone)
       
  2382 		{
       
  2383 			EAP_TRACE_ERROR(
       
  2384 				m_am_tools,
       
  2385 				TRACE_FLAGS_ERROR,
       
  2386 				(EAPL("ERROR: eap_am_general_settings_symbian_c::copy_all_eap_settings(): aPluginTool.ListAllEapPluginsL() failed, tunneling EAP-type=0xfe%06x%08x, m_IndexType=%d, m_Index=%d, m_DestinationIndexType=%d, m_DestinationIndex=%d, error=%d.\n"),
       
  2387 				aTunnelingType.GetVendorId(),
       
  2388 				aTunnelingType.GetVendorType(),
       
  2389 				internal_settings->m_IndexType,
       
  2390 				internal_settings->m_Index,
       
  2391 				internal_settings->m_DestinationIndexType,
       
  2392 				internal_settings->m_DestinationIndex,
       
  2393 				error));
       
  2394 
       
  2395 			return EAP_STATUS_RETURN(
       
  2396 				m_am_tools,
       
  2397 				error_complete(
       
  2398 					m_am_tools->convert_am_error_to_eapol_error(error),
       
  2399 					internal_settings,
       
  2400 					error_completion_function));
       
  2401 		}
       
  2402 
       
  2403 		TUint ind_outer(0ul);
       
  2404 
       
  2405 		for (ind_outer = 0ul; ind_outer < plugins.Count(); ++ind_outer)
       
  2406 		{
       
  2407 
       
  2408 			// List all plugins that could be used inside the each outer EAP-method on each plugin.
       
  2409 
       
  2410 			RPointerArray<TEapExpandedType> tunneled_plugins;
       
  2411 
       
  2412 			PointerArrayResetAndDestroy<TEapExpandedType> aAutomaticTunneledPlugins(&tunneled_plugins, EFalse);
       
  2413 
       
  2414 			EAP_TRACE_DEBUG(
       
  2415 				m_am_tools,
       
  2416 				TRACE_FLAGS_DEFAULT,
       
  2417 				(EAPL("eap_am_general_settings_symbian_c::copy_all_eap_settings(): this=0x%08x: aPluginTool.ListAllEapPluginsL(): tunneling EAP-type=0xfe%06x%08x, m_IndexType=%d, m_Index=%d, m_DestinationIndexType=%d, m_DestinationIndex=%d\n"),
       
  2418 				this,
       
  2419 				plugins[ind_outer]->GetVendorId(),
       
  2420 				plugins[ind_outer]->GetVendorType(),
       
  2421 				internal_settings->m_IndexType,
       
  2422 				internal_settings->m_Index,
       
  2423 				internal_settings->m_DestinationIndexType,
       
  2424 				internal_settings->m_DestinationIndex));
       
  2425 
       
  2426 			// This will list all inner EAP-methods of EAP-type.
       
  2427 			TRAP(error, (aPluginTool.ListAllEapPluginsL(static_cast<TIndexType>(internal_settings->m_IndexType), plugins[ind_outer], tunneled_plugins)));
       
  2428 			if (error != KErrNone)
       
  2429 			{
       
  2430 				EAP_TRACE_ERROR(
       
  2431 					m_am_tools,
       
  2432 					TRACE_FLAGS_ERROR,
       
  2433 					(EAPL("ERROR: eap_am_general_settings_symbian_c::copy_all_eap_settings(): aPluginTool.ListAllEapPluginsL() failed, tunneling EAP-type=0xfe%06x%08x, m_IndexType=%d, m_Index=%d, m_DestinationIndexType=%d, m_DestinationIndex=%d, error=%d.\n"),
       
  2434 					plugins[ind_outer]->GetVendorId(),
       
  2435 					plugins[ind_outer]->GetVendorType(),
       
  2436 					internal_settings->m_IndexType,
       
  2437 					internal_settings->m_Index,
       
  2438 					internal_settings->m_DestinationIndexType,
       
  2439 					internal_settings->m_DestinationIndex,
       
  2440 					error));
       
  2441 
       
  2442 				return EAP_STATUS_RETURN(
       
  2443 					m_am_tools,
       
  2444 					error_complete(
       
  2445 						m_am_tools->convert_am_error_to_eapol_error(error),
       
  2446 						internal_settings,
       
  2447 						error_completion_function));
       
  2448 			}
       
  2449 
       
  2450 
       
  2451 			// Copy possible configuration of each inner EAP-method that could be configured inside of outer EAP-method.
       
  2452 
       
  2453 			TUint ind_inner(0ul);
       
  2454 
       
  2455 			for (ind_inner = 0ul; ind_inner < tunneled_plugins.Count(); ++ind_inner)
       
  2456 			{
       
  2457 				CEapTypePlugin * eapType = NULL;
       
  2458 
       
  2459 				EAP_TRACE_DEBUG(
       
  2460 					m_am_tools,
       
  2461 					TRACE_FLAGS_DEFAULT,
       
  2462 					(EAPL("eap_am_general_settings_symbian_c::copy_all_eap_settings(): this=0x%08x: CEapTypePlugin::NewL(): EAP-type=0xfe%06x%08x, m_IndexType=%d, m_Index=%d, m_DestinationIndexType=%d, m_DestinationIndex=%d\n"),
       
  2463 					this,
       
  2464 					tunneled_plugins[ind_inner]->GetVendorId(),
       
  2465 					tunneled_plugins[ind_inner]->GetVendorType(),
       
  2466 					internal_settings->m_IndexType,
       
  2467 					internal_settings->m_Index,
       
  2468 					internal_settings->m_DestinationIndexType,
       
  2469 					internal_settings->m_DestinationIndex));
       
  2470 
       
  2471 				TRAP(error, (eapType = CEapTypePlugin::NewL(
       
  2472 					tunneled_plugins[ind_inner]->GetValue(),
       
  2473 					static_cast<TIndexType>(internal_settings->m_IndexType),
       
  2474 					internal_settings->m_Index)));
       
  2475 
       
  2476 				// This will automatically delete eapType.
       
  2477 				eap_automatic_variable_c<CEapTypePlugin> automatic_eap_type(
       
  2478 					m_am_tools,
       
  2479 					eapType);
       
  2480 
       
  2481 				if(error != KErrNone
       
  2482 					|| eapType == NULL)
       
  2483 				{
       
  2484 					EAP_TRACE_ERROR(
       
  2485 						m_am_tools,
       
  2486 						TRACE_FLAGS_ERROR,
       
  2487 						(EAPL("ERROR: eap_am_general_settings_symbian_c::copy_all_eap_settings(): CEapTypePlugin::NewL() failed, EAP-type=0xfe%06x%08x, m_IndexType=%d, m_Index=%d, m_DestinationIndexType=%d, m_DestinationIndex=%d, error=%d.\n"),
       
  2488 						tunneled_plugins[ind_inner]->GetVendorId(),
       
  2489 						tunneled_plugins[ind_inner]->GetVendorType(),
       
  2490 						internal_settings->m_IndexType,
       
  2491 						internal_settings->m_Index,
       
  2492 						internal_settings->m_DestinationIndexType,
       
  2493 						internal_settings->m_DestinationIndex,
       
  2494 						error));
       
  2495 
       
  2496 					return EAP_STATUS_RETURN(
       
  2497 						m_am_tools,
       
  2498 						error_complete(
       
  2499 							m_am_tools->convert_am_error_to_eapol_error(error),
       
  2500 							internal_settings,
       
  2501 							error_completion_function));
       
  2502 				}
       
  2503 				
       
  2504 			    eapType->SetTunnelingType(plugins[ind_outer]);
       
  2505 
       
  2506 				EAP_TRACE_DEBUG(
       
  2507 					m_am_tools,
       
  2508 					TRACE_FLAGS_DEFAULT,
       
  2509 					(EAPL("eap_am_general_settings_symbian_c::copy_all_eap_settings(): this=0x%08x: eapType->CopySettingsL(): EAP-type=0xfe%06x%08x, m_IndexType=%d, m_Index=%d, m_DestinationIndexType=%d, m_DestinationIndex=%d\n"),
       
  2510 					this,
       
  2511 					tunneled_plugins[ind_inner]->GetVendorId(),
       
  2512 					tunneled_plugins[ind_inner]->GetVendorType(),
       
  2513 					internal_settings->m_IndexType,
       
  2514 					internal_settings->m_Index,
       
  2515 					internal_settings->m_DestinationIndexType,
       
  2516 					internal_settings->m_DestinationIndex));
       
  2517 
       
  2518 				TRAP(error, (eapType->CopySettingsL(
       
  2519 					static_cast<TIndexType>(internal_settings->m_DestinationIndexType),
       
  2520 					internal_settings->m_DestinationIndex)));
       
  2521 				if(error != KErrNone)
       
  2522 				{
       
  2523 					EAP_TRACE_ERROR(
       
  2524 						m_am_tools,
       
  2525 						TRACE_FLAGS_ERROR,
       
  2526 						(EAPL("ERROR: eap_am_general_settings_symbian_c::copy_all_eap_settings(): eapType->CopySettingsL() failed, EAP-type=0xfe%06x%08x, m_IndexType=%d, m_Index=%d, m_DestinationIndexType=%d, m_DestinationIndex=%d, error=%d.\n"),
       
  2527 						tunneled_plugins[ind_inner]->GetVendorId(),
       
  2528 						tunneled_plugins[ind_inner]->GetVendorType(),
       
  2529 						internal_settings->m_IndexType,
       
  2530 						internal_settings->m_Index,
       
  2531 						internal_settings->m_DestinationIndexType,
       
  2532 						internal_settings->m_DestinationIndex,
       
  2533 						error));
       
  2534 
       
  2535 					return EAP_STATUS_RETURN(
       
  2536 						m_am_tools,
       
  2537 						error_complete(
       
  2538 							m_am_tools->convert_am_error_to_eapol_error(error),
       
  2539 							internal_settings,
       
  2540 							error_completion_function));
       
  2541 				}
       
  2542 
       
  2543 			} // for()
       
  2544 
       
  2545 
       
  2546 			{
       
  2547 
       
  2548 				// Copy possible configuration of each outer EAP-method on each plugin.
       
  2549 
       
  2550 				EAP_TRACE_DEBUG(
       
  2551 					m_am_tools,
       
  2552 					TRACE_FLAGS_DEFAULT,
       
  2553 					(EAPL("eap_am_general_settings_symbian_c::copy_all_eap_settings(): this=0x%08x: CEapTypePlugin::NewL(): outer EAP-type=0xfe%06x%08x, m_IndexType=%d, m_Index=%d, m_DestinationIndexType=%d, m_DestinationIndex=%d\n"),
       
  2554 					this,
       
  2555 					plugins[ind_outer]->GetVendorId(),
       
  2556 					plugins[ind_outer]->GetVendorType(),
       
  2557 					internal_settings->m_IndexType,
       
  2558 					internal_settings->m_Index,
       
  2559 					internal_settings->m_DestinationIndexType,
       
  2560 					internal_settings->m_DestinationIndex));
       
  2561 
       
  2562 				CEapTypePlugin * eapType = NULL;
       
  2563 
       
  2564 				TRAP(error, (eapType = CEapTypePlugin::NewL(
       
  2565 					plugins[ind_outer]->GetValue(),
       
  2566 					static_cast<TIndexType>(internal_settings->m_IndexType),
       
  2567 					internal_settings->m_Index)));
       
  2568 
       
  2569 				// This will automatically delete eapType.
       
  2570 				eap_automatic_variable_c<CEapTypePlugin> automatic_eap_type(
       
  2571 					m_am_tools,
       
  2572 					eapType);
       
  2573 				
       
  2574 				if(error != KErrNone
       
  2575 					|| eapType == NULL)
       
  2576 				{
       
  2577 					EAP_TRACE_ERROR(
       
  2578 						m_am_tools,
       
  2579 						TRACE_FLAGS_ERROR,
       
  2580 						(EAPL("ERROR: eap_am_general_settings_symbian_c::copy_all_eap_settings(): CEapTypePlugin::NewL() failed, outer EAP-type=0xfe%06x%08x, m_IndexType=%d, m_Index=%d, m_DestinationIndexType=%d, m_DestinationIndex=%d, error=%d.\n"),
       
  2581 						plugins[ind_outer]->GetVendorId(),
       
  2582 						plugins[ind_outer]->GetVendorType(),
       
  2583 						internal_settings->m_IndexType,
       
  2584 						internal_settings->m_Index,
       
  2585 						internal_settings->m_DestinationIndexType,
       
  2586 						internal_settings->m_DestinationIndex,
       
  2587 						error));
       
  2588 
       
  2589 					return EAP_STATUS_RETURN(
       
  2590 						m_am_tools,
       
  2591 						error_complete(
       
  2592 							m_am_tools->convert_am_error_to_eapol_error(error),
       
  2593 							internal_settings,
       
  2594 							error_completion_function));
       
  2595 				}
       
  2596 				
       
  2597 				EAP_TRACE_DEBUG(
       
  2598 					m_am_tools,
       
  2599 					TRACE_FLAGS_DEFAULT,
       
  2600 					(EAPL("eap_am_general_settings_symbian_c::copy_all_eap_settings(): this=0x%08x: eapType->CopySettingsL(): outer EAP-type=0xfe%06x%08x, m_IndexType=%d, m_Index=%d, m_DestinationIndexType=%d, m_DestinationIndex=%d\n"),
       
  2601 					this,
       
  2602 					plugins[ind_outer]->GetVendorId(),
       
  2603 					plugins[ind_outer]->GetVendorType(),
       
  2604 					internal_settings->m_IndexType,
       
  2605 					internal_settings->m_Index,
       
  2606 					internal_settings->m_DestinationIndexType,
       
  2607 					internal_settings->m_DestinationIndex));
       
  2608 
       
  2609 				TRAP(error, (eapType->CopySettingsL(
       
  2610 					static_cast<TIndexType>(internal_settings->m_DestinationIndexType),
       
  2611 					internal_settings->m_DestinationIndex)));
       
  2612 				if(error != KErrNone)
       
  2613 				{
       
  2614 					EAP_TRACE_ERROR(
       
  2615 						m_am_tools,
       
  2616 						TRACE_FLAGS_ERROR,
       
  2617 						(EAPL("ERROR: eap_am_general_settings_symbian_c::copy_all_eap_settings(): eapType->CopySettingsL() failed, outer EAP-type=0xfe%06x%08x, m_IndexType=%d, m_Index=%d, m_DestinationIndexType=%d, m_DestinationIndex=%d, error=%d.\n"),
       
  2618 						plugins[ind_outer]->GetVendorId(),
       
  2619 						plugins[ind_outer]->GetVendorType(),
       
  2620 						internal_settings->m_IndexType,
       
  2621 						internal_settings->m_Index,
       
  2622 						internal_settings->m_DestinationIndexType,
       
  2623 						internal_settings->m_DestinationIndex,
       
  2624 						error));
       
  2625 
       
  2626 					return EAP_STATUS_RETURN(
       
  2627 						m_am_tools,
       
  2628 						error_complete(
       
  2629 							m_am_tools->convert_am_error_to_eapol_error(error),
       
  2630 							internal_settings,
       
  2631 							error_completion_function));
       
  2632 				}
       
  2633 			}
       
  2634 
       
  2635 		} // for()
       
  2636 
       
  2637 	}
       
  2638 
       
  2639 	complete_settings->m_completion_status = eap_status_ok;
       
  2640 	complete_settings->m_EAPType = internal_settings->m_EAPType;
       
  2641 	complete_settings->m_IndexType = internal_settings->m_IndexType;
       
  2642 	complete_settings->m_Index = internal_settings->m_Index;
       
  2643 
       
  2644 	eap_status_e status = m_partner->complete_copy_all_eap_settings(complete_settings);
       
  2645 
       
  2646 	iGeneralSettingsDb.Compact();
       
  2647 
       
  2648 	CloseGeneralSettings();
       
  2649 
       
  2650 	EAP_TRACE_DEBUG(
       
  2651 		m_am_tools,
       
  2652 		TRACE_FLAGS_DEFAULT,
       
  2653 		(EAPL("eap_am_general_settings_symbian_c::get_eap_methods(): this=0x%08x, CloseGeneralSettings()\n"),
       
  2654 		this));
       
  2655 
       
  2656 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  2657 }
       
  2658 
       
  2659 // ----------------------------------------------------------------------
       
  2660 // End