eapol/eapol_framework/eapol_symbian/eap_server/src/eap_am_plugin_symbian.cpp
changeset 26 9abfd4f00d37
child 34 ad1f037f1ac2
equal deleted inserted replaced
25:e03a3db4489e 26:9abfd4f00d37
       
     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-plugin adaptation.
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 28 %
       
    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_plugin_symbian.h"
       
    29 #include "eap_automatic_variable.h"
       
    30 #include <EapTypePlugin.h>
       
    31 #include <EapSettings.h>
       
    32 #include <EapTypeInfo.h>
       
    33 #include "EapConversion.h"
       
    34 #include "abs_eap_am_plugin.h"
       
    35 
       
    36 /** @file */
       
    37 
       
    38 // ----------------------------------------------------------------------
       
    39 
       
    40 eap_am_plugin_symbian_c::eap_am_plugin_symbian_c(
       
    41 	abs_eap_am_tools_c * const tools,
       
    42 	abs_eap_am_plugin_c * const partner)
       
    43 	: m_am_tools(tools)
       
    44 	, m_partner(partner)
       
    45 	, m_loaded_types(tools)
       
    46 	, m_is_valid(false)
       
    47 	, m_shutdown_was_called(false)
       
    48 {
       
    49 	if (m_am_tools == 0
       
    50 		|| m_am_tools->get_is_valid() == false
       
    51 		|| m_partner == 0)
       
    52 	{
       
    53 		return;
       
    54 	}
       
    55 
       
    56 	m_is_valid = true;
       
    57 
       
    58 	EAP_TRACE_DEBUG(
       
    59 		m_am_tools,
       
    60 		TRACE_FLAGS_DEFAULT,
       
    61 		(EAPL("eap_am_plugin_symbian_c::eap_am_plugin_symbian_c(): this=0x%08x.\n"),
       
    62 		this));
       
    63 }
       
    64 
       
    65 // ----------------------------------------------------------------------
       
    66 
       
    67 eap_am_plugin_symbian_c::~eap_am_plugin_symbian_c()
       
    68 {
       
    69 	EAP_TRACE_DEBUG(
       
    70 		m_am_tools,
       
    71 		TRACE_FLAGS_DEFAULT,
       
    72 		(EAPL("eap_am_plugin_symbian_c::~eap_am_plugin_symbian_c(): this=0x%08x.\n"),
       
    73 		this));
       
    74 
       
    75 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_plugin_symbian_c::~eap_am_plugin_symbian_c()");
       
    76 
       
    77 	EAP_ASSERT(m_shutdown_was_called == true);
       
    78 }
       
    79 
       
    80 // ----------------------------------------------------------------------
       
    81 
       
    82 bool eap_am_plugin_symbian_c::get_is_valid()
       
    83 {
       
    84 	EAP_TRACE_DEBUG(
       
    85 		m_am_tools,
       
    86 		TRACE_FLAGS_DEFAULT,
       
    87 		(EAPL("eap_am_plugin_symbian_c::get_is_valid(): this=0x%08x, m_is_valid=%d.\n"),
       
    88 		this,
       
    89 		m_is_valid));
       
    90 
       
    91 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_plugin_symbian_c::get_is_valid()");
       
    92 
       
    93 	return m_is_valid;
       
    94 }
       
    95 
       
    96 // ----------------------------------------------------------------------
       
    97 
       
    98 // This is documented in abs_eap_stack_interface_c::configure().
       
    99 eap_status_e eap_am_plugin_symbian_c::configure()
       
   100 {
       
   101 	EAP_TRACE_DEBUG(
       
   102 		m_am_tools,
       
   103 		TRACE_FLAGS_DEFAULT,
       
   104 		(EAPL("eap_am_plugin_symbian_c::configure(): this=0x%08x.\n"),
       
   105 		this));
       
   106 
       
   107 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_plugin_symbian_c::configure()");
       
   108 
       
   109 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   110 }
       
   111 
       
   112 // ----------------------------------------------------------------------
       
   113 
       
   114 // This is documented in abs_eap_stack_interface_c::shutdown().
       
   115 eap_status_e eap_am_plugin_symbian_c::shutdown()
       
   116 {
       
   117 	EAP_TRACE_DEBUG(
       
   118 		m_am_tools,
       
   119 		TRACE_FLAGS_DEFAULT,
       
   120 		(EAPL("eap_am_plugin_symbian_c::shutdown(): this=0x%08x.\n"),
       
   121 		this));
       
   122 
       
   123 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_plugin_symbian_c::shutdown()");
       
   124 
       
   125 	m_shutdown_was_called = true;
       
   126 
       
   127 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   128 }
       
   129 
       
   130 // ----------------------------------------------------------------------
       
   131 
       
   132 eap_status_e eap_am_plugin_symbian_c::error_complete(
       
   133 	const eap_status_e completion_status,
       
   134 	const eap_method_settings_c * const internal_settings,
       
   135 	const eap_tlv_message_type_function_e error_completion_function)
       
   136 {
       
   137 	EAP_TRACE_DEBUG(
       
   138 		m_am_tools,
       
   139 		TRACE_FLAGS_DEFAULT,
       
   140 		(EAPL("eap_am_plugin_symbian_c::error_complete(): this=0x%08x.\n"),
       
   141 		this));
       
   142 
       
   143 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_plugin_symbian_c::error_complete()");
       
   144 
       
   145 	eap_method_settings_c * const complete_settings = new eap_method_settings_c(m_am_tools, internal_settings);
       
   146 
       
   147 	eap_automatic_variable_c<eap_method_settings_c> automatic_complete_settings(
       
   148 		m_am_tools,
       
   149 		complete_settings);
       
   150 
       
   151 	if (complete_settings == 0)
       
   152 	{
       
   153 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   154 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   155 	}
       
   156 
       
   157 	complete_settings->m_completion_status = completion_status;
       
   158 
       
   159 	eap_status_e status(eap_status_not_supported);
       
   160 
       
   161 	switch(error_completion_function)
       
   162 	{
       
   163 	case eap_tlv_message_type_function_plugin_complete_get_configuration:
       
   164 		status = m_partner->complete_get_configuration(complete_settings);
       
   165 		break;
       
   166 	case eap_tlv_message_type_function_plugin_complete_set_configuration:
       
   167 		status = m_partner->complete_set_configuration(complete_settings);
       
   168 		break;
       
   169 	case eap_tlv_message_type_function_plugin_complete_copy_configuration:
       
   170 		status = m_partner->complete_copy_configuration(complete_settings);
       
   171 		break;
       
   172 	case eap_tlv_message_type_function_plugin_complete_delete_configuration:
       
   173 		status = m_partner->complete_delete_configuration(complete_settings);
       
   174 		break;
       
   175 	case eap_tlv_message_type_function_plugin_complete_set_index:
       
   176 		status = m_partner->complete_set_index(complete_settings);
       
   177 		break;
       
   178 	case eap_tlv_message_type_function_plugin_complete_get_type_info:
       
   179 		status = m_partner->complete_get_type_info(complete_settings);
       
   180 		break;
       
   181 
       
   182 	default:
       
   183 		EAP_TRACE_ERROR(
       
   184 			m_am_tools,
       
   185 			TRACE_FLAGS_DEFAULT,
       
   186 			(EAPL("ERROR: eap_am_plugin_symbian_c::error_complete(): unknown function %d.\n"),
       
   187 			 error_completion_function));
       
   188 
       
   189 		EAP_ASSERT_ANYWAY_TOOLS(m_am_tools);
       
   190 
       
   191 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   192 		return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
   193 	}
       
   194 
       
   195 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   196 }
       
   197 
       
   198 // ----------------------------------------------------------------------
       
   199 
       
   200 CEapTypePlugin * eap_am_plugin_symbian_c::get_eap_type(
       
   201 	const eap_type_value_e eap_type,
       
   202 	u32_t index_type,
       
   203 	u32_t index)
       
   204 {
       
   205 	EAP_TRACE_DEBUG(
       
   206 		m_am_tools,
       
   207 		TRACE_FLAGS_DEFAULT,
       
   208 		(EAPL("eap_am_plugin_symbian_c::get_eap_type(): this=0x%08x, index_type=%d, index=%d, EAP-type=0xfe%06x%08x.\n"),
       
   209 		this,
       
   210 		index_type,
       
   211 		index,
       
   212 		eap_type.get_vendor_id(),
       
   213 		eap_type.get_vendor_type()));
       
   214 
       
   215 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_plugin_symbian_c::get_eap_type()");
       
   216 
       
   217 	CEapTypePlugin *eap_plugin = 0;
       
   218 
       
   219 	eap_loaded_type_c search(
       
   220 		m_am_tools,
       
   221 		0,
       
   222 		eap_type,
       
   223 		index_type,
       
   224 		index);
       
   225 
       
   226 	i32_t found_index = find<eap_loaded_type_c>(&m_loaded_types, &search, m_am_tools);
       
   227 
       
   228 	EAP_TRACE_DEBUG(
       
   229 		m_am_tools,
       
   230 		TRACE_FLAGS_DEFAULT,
       
   231 		(EAPL("eap_am_plugin_symbian_c::get_eap_type(): this=0x%08x, found_index=%d.\n"),
       
   232 		this,
       
   233 		found_index));
       
   234 
       
   235 	if (found_index >= 0)
       
   236 	{
       
   237 		// OK, EAP-type for index_type and index is already loaded.
       
   238 		eap_loaded_type_c * const loaded_type = m_loaded_types.get_object(found_index);
       
   239 		if (loaded_type == 0)
       
   240 		{
       
   241 			(void) EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   242 			return 0;
       
   243 		}
       
   244 
       
   245 		eap_plugin = loaded_type->get_type_plugin();
       
   246 
       
   247 		return eap_plugin;
       
   248 	}
       
   249 	else
       
   250 	{
       
   251 		// Load a new instance of EAP-type.
       
   252 
       
   253 		TEapExpandedType expanded_type;
       
   254 
       
   255 		eap_variable_data_c eap_data(m_am_tools);
       
   256 
       
   257 		eap_status_e status = eap_type.get_expanded_type_data(
       
   258 			m_am_tools,
       
   259 			&eap_data);
       
   260 		if (status != eap_status_ok)
       
   261 		{
       
   262 			(void) EAP_STATUS_RETURN(m_am_tools, status);
       
   263 			return 0;
       
   264 		}
       
   265 
       
   266 		EAP_TRACE_DATA_DEBUG(
       
   267 			m_am_tools,
       
   268 			TRACE_FLAGS_DEFAULT,
       
   269 			(EAPL("eap_data"),
       
   270 			eap_data.get_data(),
       
   271 			eap_data.get_data_length()));
       
   272 
       
   273 		TInt error = expanded_type.SetValue(
       
   274 			eap_data.get_data(),
       
   275 			eap_data.get_data_length());
       
   276 		if (error != KErrNone)
       
   277 		{
       
   278 			(void) EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(error));
       
   279 			return 0;
       
   280 		}
       
   281 
       
   282 		EAP_TRACE_DATA_DEBUG(
       
   283 			m_am_tools,
       
   284 			TRACE_FLAGS_DEFAULT,
       
   285 			(EAPL("expanded_type.GetValue()"),
       
   286 			expanded_type.GetValue().Ptr(),
       
   287 			expanded_type.GetValue().Length()));
       
   288 
       
   289 		TIndexType IndexType(static_cast<TIndexType>(index_type));
       
   290 		TUint Index(static_cast<TUint>(index));
       
   291 
       
   292 		TRAP(error, (eap_plugin = CEapTypePlugin::NewL(
       
   293 			expanded_type.GetValue(),
       
   294 			IndexType,
       
   295 			Index)));
       
   296 		if (error != KErrNone
       
   297 			|| eap_plugin == 0)
       
   298 		{
       
   299 			// Interface not found or implementation creation function failed
       
   300 			EAP_TRACE_DEBUG(
       
   301 				m_am_tools,
       
   302 				TRACE_FLAGS_DEFAULT,
       
   303 				(EAPL("ERROR: ECom could not find/initiate implementation for EAP-type=0xfe%06x%08x, index_type=%d, index=%d, error = %d.\n"),
       
   304 				eap_type.get_vendor_id(),
       
   305 				eap_type.get_vendor_type(),
       
   306 				index_type,
       
   307 				index,
       
   308 				error));
       
   309 			(void) EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   310 			return 0;
       
   311 		}
       
   312 
       
   313 		eap_loaded_type_c * const new_eap_plugin = new eap_loaded_type_c(
       
   314 			m_am_tools,
       
   315 			eap_plugin,
       
   316 			eap_type,
       
   317 			index_type,
       
   318 			index);
       
   319 		if (new_eap_plugin == 0)
       
   320 		{
       
   321 			EAP_TRACE_DEBUG(
       
   322 				m_am_tools,
       
   323 				TRACE_FLAGS_DEFAULT,
       
   324 				(EAPL("ERROR: Could not allocate EAP-type=0xfe%06x%08x, index_type=%d, index=%d.\n"),
       
   325 				eap_type.get_vendor_id(),
       
   326 				eap_type.get_vendor_type(),
       
   327 				index_type,
       
   328 				index));
       
   329 			(void) EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   330 			delete eap_plugin;
       
   331 			return 0;
       
   332 		}
       
   333 
       
   334 		status = m_loaded_types.add_object(
       
   335 			new_eap_plugin,
       
   336 			true);
       
   337 		if (status != eap_status_ok)
       
   338 		{
       
   339 			EAP_TRACE_DEBUG(
       
   340 				m_am_tools,
       
   341 				TRACE_FLAGS_DEFAULT,
       
   342 				(EAPL("ERROR: Could not add EAP-type=0xfe%06x%08x, index_type=%d, index=%d to array.\n"),
       
   343 				eap_type.get_vendor_id(),
       
   344 				eap_type.get_vendor_type(),
       
   345 				index_type,
       
   346 				index));
       
   347 			(void) EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   348 			return 0;
       
   349 		}
       
   350 
       
   351 		return eap_plugin;
       
   352 	}
       
   353 }
       
   354 
       
   355 // ----------------------------------------------------------------------
       
   356 
       
   357 eap_status_e eap_am_plugin_symbian_c::get_configuration(const eap_method_settings_c * const internal_settings)
       
   358 {
       
   359 	EAP_TRACE_DEBUG(
       
   360 		m_am_tools,
       
   361 		TRACE_FLAGS_DEFAULT,
       
   362 		(EAPL("eap_am_plugin_symbian_c::get_configuration(): this=0x%08x.\n"),
       
   363 		this));
       
   364 
       
   365 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_plugin_symbian_c::get_configuration()");
       
   366 
       
   367 	const eap_tlv_message_type_function_e error_completion_function(eap_tlv_message_type_function_plugin_complete_get_configuration);
       
   368 
       
   369 	CEapTypePlugin* const eapType = get_eap_type(internal_settings->m_EAPType, internal_settings->m_IndexType, internal_settings->m_Index);
       
   370 	if (eapType == 0)
       
   371 	{
       
   372 		return EAP_STATUS_RETURN(
       
   373 			m_am_tools,
       
   374 			error_complete(
       
   375 				eap_status_allocation_error,
       
   376 				internal_settings,
       
   377 				error_completion_function));
       
   378 	}
       
   379 
       
   380 	if (internal_settings->m_TunnelingTypePresent == true)
       
   381 	{
       
   382 		TEapExpandedType aExpandedType;
       
   383     
       
   384 		TInt err = CEapConversion::ConvertInternalTypeToExpandedEAPType(
       
   385 				&(internal_settings->m_TunnelingType),
       
   386 				&aExpandedType);
       
   387 
       
   388 		eapType->SetTunnelingType(aExpandedType);
       
   389 	}
       
   390 
       
   391 	EAPSettings * local_settings = new EAPSettings;
       
   392 
       
   393 	eap_automatic_variable_c<EAPSettings> automatic_aSettings(
       
   394 		m_am_tools,
       
   395 		local_settings);
       
   396 
       
   397 	if (local_settings == 0)
       
   398 	{
       
   399 		return EAP_STATUS_RETURN(
       
   400 			m_am_tools,
       
   401 			error_complete(
       
   402 				eap_status_allocation_error,
       
   403 				internal_settings,
       
   404 				error_completion_function));
       
   405 	}
       
   406 
       
   407 	TInt error(KErrNone);
       
   408 
       
   409 	TRAP(error, (eapType->GetConfigurationL(*local_settings)));
       
   410 	if (error != KErrNone)
       
   411 	{
       
   412 		EAP_TRACE_DEBUG(
       
   413 			m_am_tools,
       
   414 			TRACE_FLAGS_DEFAULT,
       
   415 			(EAPL("ERROR: Cannot read configuration from EAP-type=0xfe%06x%08x, index_type=%d, index=%d.\n"),
       
   416 			internal_settings->m_EAPType.get_vendor_id(),
       
   417 			internal_settings->m_EAPType.get_vendor_type(),
       
   418 			internal_settings->m_IndexType,
       
   419 			internal_settings->m_Index));
       
   420 
       
   421 		return EAP_STATUS_RETURN(
       
   422 			m_am_tools,
       
   423 			error_complete(
       
   424 				m_am_tools->convert_am_error_to_eapol_error(error),
       
   425 				internal_settings,
       
   426 				error_completion_function));
       
   427 	}
       
   428 
       
   429 	eap_method_settings_c * const complete_settings = new eap_method_settings_c(m_am_tools);
       
   430 
       
   431 	eap_automatic_variable_c<eap_method_settings_c> automatic_complete_settings(
       
   432 		m_am_tools,
       
   433 		complete_settings);
       
   434 
       
   435 	if (complete_settings == 0)
       
   436 	{
       
   437 		return EAP_STATUS_RETURN(
       
   438 			m_am_tools,
       
   439 			error_complete(
       
   440 				eap_status_allocation_error,
       
   441 				internal_settings,
       
   442 				error_completion_function));
       
   443 	}
       
   444 
       
   445 	error = CEapConversion::ConvertEAPSettingsToInternalType(
       
   446 		m_am_tools,
       
   447 		local_settings,
       
   448 		complete_settings);
       
   449 	if (error != KErrNone)
       
   450 	{
       
   451 		return EAP_STATUS_RETURN(
       
   452 			m_am_tools,
       
   453 			error_complete(
       
   454 				m_am_tools->convert_am_error_to_eapol_error(error),
       
   455 				internal_settings,
       
   456 				error_completion_function));
       
   457 	}
       
   458 
       
   459 	complete_settings->m_EAPType = internal_settings->m_EAPType;
       
   460 	complete_settings->m_IndexType = internal_settings->m_IndexType;
       
   461 	complete_settings->m_Index = internal_settings->m_Index;
       
   462 	complete_settings->m_completion_status = eap_status_ok;
       
   463 
       
   464 	eap_status_e status = m_partner->complete_get_configuration(complete_settings);
       
   465 
       
   466 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   467 }
       
   468 
       
   469 // ----------------------------------------------------------------------
       
   470 
       
   471 eap_status_e eap_am_plugin_symbian_c::set_configuration(const eap_method_settings_c * const internal_settings)
       
   472 {
       
   473 	EAP_TRACE_DEBUG(
       
   474 		m_am_tools,
       
   475 		TRACE_FLAGS_DEFAULT,
       
   476 		(EAPL("eap_am_plugin_symbian_c::set_configuration(): this=0x%08x.\n"),
       
   477 		this));
       
   478 
       
   479 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_plugin_symbian_c::set_configuration()");
       
   480 
       
   481 	const eap_tlv_message_type_function_e error_completion_function(eap_tlv_message_type_function_plugin_complete_set_configuration);
       
   482 
       
   483 	CEapTypePlugin* const eapType = get_eap_type(internal_settings->m_EAPType, internal_settings->m_IndexType, internal_settings->m_Index);
       
   484 	if (eapType == 0)
       
   485 	{
       
   486 		return EAP_STATUS_RETURN(
       
   487 			m_am_tools,
       
   488 			error_complete(
       
   489 				eap_status_allocation_error,
       
   490 				internal_settings,
       
   491 				error_completion_function));
       
   492 	}
       
   493 
       
   494 	if (internal_settings->m_TunnelingTypePresent == true)
       
   495 	{
       
   496 		TEapExpandedType aExpandedType;
       
   497     
       
   498 		TInt err = CEapConversion::ConvertInternalTypeToExpandedEAPType(
       
   499 				&(internal_settings->m_TunnelingType),
       
   500 				&aExpandedType);
       
   501 
       
   502 		eapType->SetTunnelingType(aExpandedType);
       
   503 	}
       
   504 
       
   505 	EAPSettings * local_settings = new EAPSettings;
       
   506 
       
   507 	eap_automatic_variable_c<EAPSettings> automatic_aSettings(
       
   508 		m_am_tools,
       
   509 		local_settings);
       
   510 
       
   511 	if (local_settings == 0)
       
   512 	{
       
   513 		return EAP_STATUS_RETURN(
       
   514 			m_am_tools,
       
   515 			error_complete(
       
   516 				eap_status_allocation_error,
       
   517 				internal_settings,
       
   518 				error_completion_function));
       
   519 	}
       
   520 
       
   521 	TInt error = CEapConversion::ConvertInternalTypeToEAPSettings(
       
   522 		m_am_tools,
       
   523 		internal_settings,
       
   524 		local_settings);
       
   525 	if (error != KErrNone)
       
   526 	{
       
   527 		return EAP_STATUS_RETURN(
       
   528 			m_am_tools,
       
   529 			error_complete(
       
   530 				m_am_tools->convert_am_error_to_eapol_error(error),
       
   531 				internal_settings,
       
   532 				error_completion_function));
       
   533 	}
       
   534 
       
   535 	TRAP(error, (eapType->SetConfigurationL(*local_settings)));
       
   536 	if (error != KErrNone)
       
   537 	{
       
   538 		EAP_TRACE_DEBUG(
       
   539 			m_am_tools,
       
   540 			TRACE_FLAGS_DEFAULT,
       
   541 			(EAPL("ERROR: Cannot write configuration to EAP-type=0xfe%06x%08x, index_type=%d, index=%d.\n"),
       
   542 			internal_settings->m_EAPType.get_vendor_id(),
       
   543 			internal_settings->m_EAPType.get_vendor_type(),
       
   544 			internal_settings->m_IndexType,
       
   545 			internal_settings->m_Index));
       
   546 
       
   547 		return EAP_STATUS_RETURN(
       
   548 			m_am_tools,
       
   549 			error_complete(
       
   550 				m_am_tools->convert_am_error_to_eapol_error(error),
       
   551 				internal_settings,
       
   552 				error_completion_function));
       
   553 	}
       
   554 
       
   555 	eap_method_settings_c * const complete_settings = new eap_method_settings_c(m_am_tools, internal_settings);
       
   556 
       
   557 	eap_automatic_variable_c<eap_method_settings_c> automatic_complete_settings(
       
   558 		m_am_tools,
       
   559 		complete_settings);
       
   560 
       
   561 	if (complete_settings == 0)
       
   562 	{
       
   563 		return EAP_STATUS_RETURN(
       
   564 			m_am_tools,
       
   565 			error_complete(
       
   566 				eap_status_allocation_error,
       
   567 				internal_settings,
       
   568 				error_completion_function));
       
   569 	}
       
   570 
       
   571 	complete_settings->m_completion_status = eap_status_ok;
       
   572 
       
   573 	eap_status_e status = m_partner->complete_set_configuration(complete_settings);
       
   574 
       
   575 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   576 }
       
   577 
       
   578 // ----------------------------------------------------------------------
       
   579 
       
   580 eap_status_e eap_am_plugin_symbian_c::copy_configuration(const eap_method_settings_c * const internal_settings)
       
   581 {
       
   582 	EAP_TRACE_DEBUG(
       
   583 		m_am_tools,
       
   584 		TRACE_FLAGS_DEFAULT,
       
   585 		(EAPL("eap_am_plugin_symbian_c::set_configuration(): this=0x%08x.\n"),
       
   586 		this));
       
   587 
       
   588 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_plugin_symbian_c::set_configuration()");
       
   589 
       
   590 	const eap_tlv_message_type_function_e error_completion_function(eap_tlv_message_type_function_plugin_complete_copy_configuration);
       
   591 
       
   592 	CEapTypePlugin* const eapType = get_eap_type(internal_settings->m_EAPType, internal_settings->m_IndexType, internal_settings->m_Index);
       
   593 	if (eapType == 0)
       
   594 	{
       
   595 		return EAP_STATUS_RETURN(
       
   596 			m_am_tools,
       
   597 			error_complete(
       
   598 				eap_status_allocation_error,
       
   599 				internal_settings,
       
   600 				error_completion_function));
       
   601 	}
       
   602 
       
   603 	if (internal_settings->m_TunnelingTypePresent == true)
       
   604 	{
       
   605 		TEapExpandedType aExpandedType;
       
   606     
       
   607 		TInt err = CEapConversion::ConvertInternalTypeToExpandedEAPType(
       
   608 				&(internal_settings->m_TunnelingType),
       
   609 				&aExpandedType);
       
   610 
       
   611 		eapType->SetTunnelingType(aExpandedType);
       
   612 	}
       
   613 
       
   614 	EAPSettings * local_settings = new EAPSettings;
       
   615 
       
   616 	eap_automatic_variable_c<EAPSettings> automatic_aSettings(
       
   617 		m_am_tools,
       
   618 		local_settings);
       
   619 
       
   620 	if (local_settings == 0)
       
   621 	{
       
   622 		return EAP_STATUS_RETURN(
       
   623 			m_am_tools,
       
   624 			error_complete(
       
   625 				eap_status_allocation_error,
       
   626 				internal_settings,
       
   627 				error_completion_function));
       
   628 	}
       
   629 
       
   630 	TInt error = CEapConversion::ConvertInternalTypeToEAPSettings(
       
   631 		m_am_tools,
       
   632 		internal_settings,
       
   633 		local_settings);
       
   634 	if (error != KErrNone)
       
   635 	{
       
   636 		return EAP_STATUS_RETURN(
       
   637 			m_am_tools,
       
   638 			error_complete(
       
   639 				m_am_tools->convert_am_error_to_eapol_error(error),
       
   640 				internal_settings,
       
   641 				error_completion_function));
       
   642 	}
       
   643 
       
   644 	if (internal_settings->m_DestinationIndexAndTypePresent == false)
       
   645 	{
       
   646 		return EAP_STATUS_RETURN(
       
   647 			m_am_tools,
       
   648 			error_complete(
       
   649 				eap_status_illegal_parameter,
       
   650 				internal_settings,
       
   651 				error_completion_function));
       
   652 	}
       
   653 
       
   654 	TIndexType aDestinationIndexType(static_cast<TIndexType>(internal_settings->m_DestinationIndexType));
       
   655 	TUint aDestinationIndex(static_cast<TUint>(internal_settings->m_DestinationIndex));
       
   656 
       
   657 	TRAP(error, (eapType->CopySettingsL(
       
   658 		aDestinationIndexType, 
       
   659 		aDestinationIndex)));
       
   660 	if (error != KErrNone)
       
   661 	{
       
   662 		EAP_TRACE_DEBUG(
       
   663 			m_am_tools,
       
   664 			TRACE_FLAGS_DEFAULT,
       
   665 			(EAPL("ERROR: Cannot copy configuration from EAP-type=0xfe%06x%08x, (index_type=%d, index=%d) to (index_type=%d, index=%d).\n"),
       
   666 			internal_settings->m_EAPType.get_vendor_id(),
       
   667 			internal_settings->m_EAPType.get_vendor_type(),
       
   668 			internal_settings->m_IndexType,
       
   669 			internal_settings->m_Index,
       
   670 			internal_settings->m_DestinationIndexType,
       
   671 			internal_settings->m_DestinationIndex));
       
   672 
       
   673 		return EAP_STATUS_RETURN(
       
   674 			m_am_tools,
       
   675 			error_complete(
       
   676 				m_am_tools->convert_am_error_to_eapol_error(error),
       
   677 				internal_settings,
       
   678 				error_completion_function));
       
   679 	}
       
   680 
       
   681 	eap_method_settings_c * const complete_settings = new eap_method_settings_c(m_am_tools, internal_settings);
       
   682 
       
   683 	eap_automatic_variable_c<eap_method_settings_c> automatic_complete_settings(
       
   684 		m_am_tools,
       
   685 		complete_settings);
       
   686 
       
   687 	if (complete_settings == 0)
       
   688 	{
       
   689 		return EAP_STATUS_RETURN(
       
   690 			m_am_tools,
       
   691 			error_complete(
       
   692 				eap_status_allocation_error,
       
   693 				internal_settings,
       
   694 				error_completion_function));
       
   695 	}
       
   696 
       
   697 	complete_settings->m_completion_status = eap_status_ok;
       
   698 
       
   699 	eap_status_e status = m_partner->complete_copy_configuration(complete_settings);
       
   700 
       
   701 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   702 }
       
   703 
       
   704 // ----------------------------------------------------------------------
       
   705 
       
   706 eap_status_e eap_am_plugin_symbian_c::delete_configuration(const eap_method_settings_c * const internal_settings)
       
   707 {
       
   708 	EAP_TRACE_DEBUG(
       
   709 		m_am_tools,
       
   710 		TRACE_FLAGS_DEFAULT,
       
   711 		(EAPL("eap_am_plugin_symbian_c::delete_configuration(): this=0x%08x.\n"),
       
   712 		this));
       
   713 
       
   714 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_plugin_symbian_c::delete_configuration()");
       
   715 
       
   716 	const eap_tlv_message_type_function_e error_completion_function(eap_tlv_message_type_function_plugin_complete_delete_configuration);
       
   717 
       
   718 	CEapTypePlugin* const eapType = get_eap_type(internal_settings->m_EAPType, internal_settings->m_IndexType, internal_settings->m_Index);
       
   719 	if (eapType == 0)
       
   720 	{
       
   721 		return EAP_STATUS_RETURN(
       
   722 			m_am_tools,
       
   723 			error_complete(
       
   724 				eap_status_allocation_error,
       
   725 				internal_settings,
       
   726 				error_completion_function));
       
   727 	}
       
   728 
       
   729 	if (internal_settings->m_TunnelingTypePresent == true)
       
   730 	{
       
   731 		TEapExpandedType aExpandedType;
       
   732     
       
   733 		TInt err = CEapConversion::ConvertInternalTypeToExpandedEAPType(
       
   734 				&(internal_settings->m_TunnelingType),
       
   735 				&aExpandedType);
       
   736 
       
   737 		eapType->SetTunnelingType(aExpandedType);
       
   738 	}
       
   739 
       
   740 	EAPSettings * local_settings = new EAPSettings;
       
   741 
       
   742 	eap_automatic_variable_c<EAPSettings> automatic_aSettings(
       
   743 		m_am_tools,
       
   744 		local_settings);
       
   745 
       
   746 	if (local_settings == 0)
       
   747 	{
       
   748 		return EAP_STATUS_RETURN(
       
   749 			m_am_tools,
       
   750 			error_complete(
       
   751 				eap_status_allocation_error,
       
   752 				internal_settings,
       
   753 				error_completion_function));
       
   754 	}
       
   755 
       
   756 	TInt error = CEapConversion::ConvertInternalTypeToEAPSettings(
       
   757 		m_am_tools,
       
   758 		internal_settings,
       
   759 		local_settings);
       
   760 	if (error != KErrNone)
       
   761 	{
       
   762 		return EAP_STATUS_RETURN(
       
   763 			m_am_tools,
       
   764 			error_complete(
       
   765 				m_am_tools->convert_am_error_to_eapol_error(error),
       
   766 				internal_settings,
       
   767 				error_completion_function));
       
   768 	}
       
   769 
       
   770 	TRAP(error, (eapType->DeleteConfigurationL()));
       
   771 	if (error != KErrNone)
       
   772 	{
       
   773 		EAP_TRACE_DEBUG(
       
   774 			m_am_tools,
       
   775 			TRACE_FLAGS_DEFAULT,
       
   776 			(EAPL("ERROR: Cannot delete configuration from EAP-type=0xfe%06x%08x, (index_type=%d, index=%d).\n"),
       
   777 			internal_settings->m_EAPType.get_vendor_id(),
       
   778 			internal_settings->m_EAPType.get_vendor_type(),
       
   779 			internal_settings->m_IndexType,
       
   780 			internal_settings->m_Index));
       
   781 
       
   782 		return EAP_STATUS_RETURN(
       
   783 			m_am_tools,
       
   784 			error_complete(
       
   785 				m_am_tools->convert_am_error_to_eapol_error(error),
       
   786 				internal_settings,
       
   787 				error_completion_function));
       
   788 	}
       
   789 
       
   790 	eap_method_settings_c * const complete_settings = new eap_method_settings_c(m_am_tools, internal_settings);
       
   791 
       
   792 	eap_automatic_variable_c<eap_method_settings_c> automatic_complete_settings(
       
   793 		m_am_tools,
       
   794 		complete_settings);
       
   795 
       
   796 	if (complete_settings == 0)
       
   797 	{
       
   798 		return EAP_STATUS_RETURN(
       
   799 			m_am_tools,
       
   800 			error_complete(
       
   801 				eap_status_allocation_error,
       
   802 				internal_settings,
       
   803 				error_completion_function));
       
   804 	}
       
   805 
       
   806 	complete_settings->m_completion_status = eap_status_ok;
       
   807 
       
   808 	eap_status_e status = m_partner->complete_delete_configuration(complete_settings);
       
   809 
       
   810 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   811 }
       
   812 
       
   813 // ----------------------------------------------------------------------
       
   814 
       
   815 eap_status_e eap_am_plugin_symbian_c::set_index(const eap_method_settings_c * const internal_settings)
       
   816 {
       
   817 	EAP_TRACE_DEBUG(
       
   818 		m_am_tools,
       
   819 		TRACE_FLAGS_DEFAULT,
       
   820 		(EAPL("eap_am_plugin_symbian_c::set_index(): this=0x%08x.\n"),
       
   821 		this));
       
   822 
       
   823 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_plugin_symbian_c::set_index()");
       
   824 
       
   825 	const eap_tlv_message_type_function_e error_completion_function(eap_tlv_message_type_function_plugin_complete_set_index);
       
   826 
       
   827 	CEapTypePlugin* const eapType = get_eap_type(internal_settings->m_EAPType, internal_settings->m_IndexType, internal_settings->m_Index);
       
   828 	if (eapType == 0)
       
   829 	{
       
   830 		return EAP_STATUS_RETURN(
       
   831 			m_am_tools,
       
   832 			error_complete(
       
   833 				eap_status_allocation_error,
       
   834 				internal_settings,
       
   835 				error_completion_function));
       
   836 	}
       
   837 
       
   838 	if (internal_settings->m_TunnelingTypePresent == true)
       
   839 	{
       
   840 		TEapExpandedType aExpandedType;
       
   841     
       
   842 		TInt err = CEapConversion::ConvertInternalTypeToExpandedEAPType(
       
   843 				&(internal_settings->m_TunnelingType),
       
   844 				&aExpandedType);
       
   845 
       
   846 		eapType->SetTunnelingType(aExpandedType);
       
   847 	}
       
   848 
       
   849 	EAPSettings * local_settings = new EAPSettings;
       
   850 
       
   851 	eap_automatic_variable_c<EAPSettings> automatic_aSettings(
       
   852 		m_am_tools,
       
   853 		local_settings);
       
   854 
       
   855 	if (local_settings == 0)
       
   856 	{
       
   857 		return EAP_STATUS_RETURN(
       
   858 			m_am_tools,
       
   859 			error_complete(
       
   860 				eap_status_allocation_error,
       
   861 				internal_settings,
       
   862 				error_completion_function));
       
   863 	}
       
   864 
       
   865 	TInt error = CEapConversion::ConvertInternalTypeToEAPSettings(
       
   866 		m_am_tools,
       
   867 		internal_settings,
       
   868 		local_settings);
       
   869 	if (error != KErrNone)
       
   870 	{
       
   871 		return EAP_STATUS_RETURN(
       
   872 			m_am_tools,
       
   873 			error_complete(
       
   874 				m_am_tools->convert_am_error_to_eapol_error(error),
       
   875 				internal_settings,
       
   876 				error_completion_function));
       
   877 	}
       
   878 
       
   879 	if (internal_settings->m_DestinationIndexAndTypePresent == false)
       
   880 	{
       
   881 		return EAP_STATUS_RETURN(
       
   882 			m_am_tools,
       
   883 			error_complete(
       
   884 				eap_status_illegal_parameter,
       
   885 				internal_settings,
       
   886 				error_completion_function));
       
   887 	}
       
   888 
       
   889 	TIndexType aDestinationIndexType(static_cast<TIndexType>(internal_settings->m_DestinationIndexType));
       
   890 	TUint aDestinationIndex(static_cast<TUint>(internal_settings->m_DestinationIndex));
       
   891 
       
   892 	TRAP(error, (eapType->SetIndexL(
       
   893 		aDestinationIndexType, 
       
   894 		aDestinationIndex)));
       
   895 	if (error != KErrNone)
       
   896 	{
       
   897 		EAP_TRACE_DEBUG(
       
   898 			m_am_tools,
       
   899 			TRACE_FLAGS_DEFAULT,
       
   900 			(EAPL("ERROR: Cannot copy configuration from EAP-type=0xfe%06x%08x, (index_type=%d, index=%d) to (index_type=%d, index=%d).\n"),
       
   901 			internal_settings->m_EAPType.get_vendor_id(),
       
   902 			internal_settings->m_EAPType.get_vendor_type(),
       
   903 			internal_settings->m_IndexType,
       
   904 			internal_settings->m_Index,
       
   905 			internal_settings->m_DestinationIndexType,
       
   906 			internal_settings->m_DestinationIndex));
       
   907 
       
   908 		return EAP_STATUS_RETURN(
       
   909 			m_am_tools,
       
   910 			error_complete(
       
   911 				m_am_tools->convert_am_error_to_eapol_error(error),
       
   912 				internal_settings,
       
   913 				error_completion_function));
       
   914 	}
       
   915 
       
   916 	eap_method_settings_c * const complete_settings = new eap_method_settings_c(m_am_tools, internal_settings);
       
   917 
       
   918 	eap_automatic_variable_c<eap_method_settings_c> automatic_complete_settings(
       
   919 		m_am_tools,
       
   920 		complete_settings);
       
   921 
       
   922 	if (complete_settings == 0)
       
   923 	{
       
   924 		return EAP_STATUS_RETURN(
       
   925 			m_am_tools,
       
   926 			error_complete(
       
   927 				eap_status_allocation_error,
       
   928 				internal_settings,
       
   929 				error_completion_function));
       
   930 	}
       
   931 
       
   932 	complete_settings->m_completion_status = eap_status_ok;
       
   933 
       
   934 	eap_status_e status = m_partner->complete_set_index(complete_settings);
       
   935 
       
   936 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   937 }
       
   938 
       
   939 // ----------------------------------------------------------------------
       
   940 
       
   941 eap_status_e eap_am_plugin_symbian_c::get_type_info(const eap_method_settings_c * const internal_settings)
       
   942 {
       
   943 	EAP_TRACE_DEBUG(
       
   944 		m_am_tools,
       
   945 		TRACE_FLAGS_DEFAULT,
       
   946 		(EAPL("eap_am_plugin_symbian_c::get_type_info(): this=0x%08x.\n"),
       
   947 		this));
       
   948 
       
   949 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_plugin_symbian_c::get_type_info()");
       
   950 
       
   951 	const eap_tlv_message_type_function_e error_completion_function(eap_tlv_message_type_function_plugin_complete_get_type_info);
       
   952 
       
   953 	CEapTypePlugin* const eapType = get_eap_type(internal_settings->m_EAPType, internal_settings->m_IndexType, internal_settings->m_Index);
       
   954 	if (eapType == 0)
       
   955 	{
       
   956 		return EAP_STATUS_RETURN(
       
   957 			m_am_tools,
       
   958 			error_complete(
       
   959 				eap_status_allocation_error,
       
   960 				internal_settings,
       
   961 				error_completion_function));
       
   962 	}
       
   963 
       
   964 	if (internal_settings->m_TunnelingTypePresent == true)
       
   965 	{
       
   966 		TEapExpandedType aExpandedType;
       
   967     
       
   968 		TInt err = CEapConversion::ConvertInternalTypeToExpandedEAPType(
       
   969 				&(internal_settings->m_TunnelingType),
       
   970 				&aExpandedType);
       
   971 
       
   972 		eapType->SetTunnelingType(aExpandedType);
       
   973 	}
       
   974 
       
   975 	EAPSettings * local_settings = new EAPSettings;
       
   976 
       
   977 	eap_automatic_variable_c<EAPSettings> automatic_aSettings(
       
   978 		m_am_tools,
       
   979 		local_settings);
       
   980 
       
   981 	if (local_settings == 0)
       
   982 	{
       
   983 		return EAP_STATUS_RETURN(
       
   984 			m_am_tools,
       
   985 			error_complete(
       
   986 				eap_status_allocation_error,
       
   987 				internal_settings,
       
   988 				error_completion_function));
       
   989 	}
       
   990 
       
   991 	TInt error = CEapConversion::ConvertInternalTypeToEAPSettings(
       
   992 		m_am_tools,
       
   993 		internal_settings,
       
   994 		local_settings);
       
   995 	if (error != KErrNone)
       
   996 	{
       
   997 		return EAP_STATUS_RETURN(
       
   998 			m_am_tools,
       
   999 			error_complete(
       
  1000 				m_am_tools->convert_am_error_to_eapol_error(error),
       
  1001 				internal_settings,
       
  1002 				error_completion_function));
       
  1003 	}
       
  1004 
       
  1005 	if (internal_settings->m_DestinationIndexAndTypePresent == false)
       
  1006 	{
       
  1007 		return EAP_STATUS_RETURN(
       
  1008 			m_am_tools,
       
  1009 			error_complete(
       
  1010 				eap_status_illegal_parameter,
       
  1011 				internal_settings,
       
  1012 				error_completion_function));
       
  1013 	}
       
  1014 
       
  1015 	CEapTypeInfo * type_info = 0;
       
  1016 
       
  1017 	TRAP(error, (type_info = eapType->GetInfoL()));
       
  1018 	if (error != KErrNone
       
  1019 		|| type_info == 0)
       
  1020 	{
       
  1021 		EAP_TRACE_DEBUG(
       
  1022 			m_am_tools,
       
  1023 			TRACE_FLAGS_DEFAULT,
       
  1024 			(EAPL("ERROR: Cannot get type info configuration from EAP-type=0xfe%06x%08x, (index_type=%d, index=%d).\n"),
       
  1025 			internal_settings->m_EAPType.get_vendor_id(),
       
  1026 			internal_settings->m_EAPType.get_vendor_type(),
       
  1027 			internal_settings->m_IndexType,
       
  1028 			internal_settings->m_Index));
       
  1029 
       
  1030 		if (type_info != 0)
       
  1031 		{
       
  1032 			delete type_info;
       
  1033 			type_info = 0;
       
  1034 		}
       
  1035 
       
  1036 		return EAP_STATUS_RETURN(
       
  1037 			m_am_tools,
       
  1038 			error_complete(
       
  1039 				m_am_tools->convert_am_error_to_eapol_error(error),
       
  1040 				internal_settings,
       
  1041 				error_completion_function));
       
  1042 	}
       
  1043 
       
  1044 	eap_method_settings_c * const complete_settings = new eap_method_settings_c(m_am_tools, internal_settings);
       
  1045 
       
  1046 	eap_automatic_variable_c<eap_method_settings_c> automatic_complete_settings(
       
  1047 		m_am_tools,
       
  1048 		complete_settings);
       
  1049 
       
  1050 	if (complete_settings == 0)
       
  1051 	{
       
  1052 		delete type_info;
       
  1053 		type_info = 0;
       
  1054 		return EAP_STATUS_RETURN(
       
  1055 			m_am_tools,
       
  1056 			error_complete(
       
  1057 				eap_status_allocation_error,
       
  1058 				internal_settings,
       
  1059 				error_completion_function));
       
  1060 	}
       
  1061 
       
  1062 	error = CEapConversion::ConvertFromTDesCToInternal(
       
  1063 		m_am_tools,
       
  1064 		type_info->ReleaseDate(),
       
  1065 		&(complete_settings->m_KReleaseDate));
       
  1066 
       
  1067 	if(error == KErrNone)
       
  1068 	{
       
  1069 		error = CEapConversion::ConvertFromTDesCToInternal(
       
  1070 			m_am_tools,
       
  1071 			type_info->Version(),
       
  1072 			&(complete_settings->m_KEapTypeVersion));
       
  1073 	}
       
  1074 
       
  1075 	if(error == KErrNone)
       
  1076 	{
       
  1077 		error = CEapConversion::ConvertFromTDesCToInternal(
       
  1078 			m_am_tools,
       
  1079 			type_info->Manufacturer(),
       
  1080 			&(complete_settings->m_KManufacturer));
       
  1081 	}
       
  1082 
       
  1083 	delete type_info;
       
  1084 	type_info = 0;
       
  1085 
       
  1086 	if(error != KErrNone)
       
  1087 	{
       
  1088 		return EAP_STATUS_RETURN(
       
  1089 			m_am_tools,
       
  1090 			error_complete(
       
  1091 				m_am_tools->convert_am_error_to_eapol_error(error),
       
  1092 				internal_settings,
       
  1093 				error_completion_function));
       
  1094 	}
       
  1095 
       
  1096 	complete_settings->m_completion_status = eap_status_ok;
       
  1097 
       
  1098 	eap_status_e status = m_partner->complete_get_type_info(complete_settings);
       
  1099 
       
  1100 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1101 }
       
  1102 
       
  1103 // ----------------------------------------------------------------------
       
  1104 
       
  1105 
       
  1106 
       
  1107 // ----------------------------------------------------------------------
       
  1108 // End