eapol/eapol_framework/eapol_symbian/eap_server/src/eap_am_plugin_symbian.cpp
branchRCL_3
changeset 19 c74b3d9f6b9e
parent 18 bad0cc58d154
equal deleted inserted replaced
18:bad0cc58d154 19: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-plugin adaptation.
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 29 %
       
    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 	complete_settings->m_EAPType = internal_settings->m_EAPType;
       
   446 	complete_settings->m_IndexType = internal_settings->m_IndexType;
       
   447 	complete_settings->m_Index = internal_settings->m_Index;
       
   448 	complete_settings->m_completion_status = eap_status_ok;
       
   449 
       
   450 	error = CEapConversion::ConvertEAPSettingsToInternalType(
       
   451 		m_am_tools,
       
   452 		local_settings,
       
   453 		complete_settings);
       
   454 	if (error != KErrNone)
       
   455 	{
       
   456 		complete_settings->m_completion_status = m_am_tools->convert_am_error_to_eapol_error(error);
       
   457 
       
   458 		return EAP_STATUS_RETURN(
       
   459 			m_am_tools,
       
   460 			error_complete(
       
   461 				m_am_tools->convert_am_error_to_eapol_error(error),
       
   462 				internal_settings,
       
   463 				error_completion_function));
       
   464 	}
       
   465 
       
   466 	eap_status_e status = m_partner->complete_get_configuration(complete_settings);
       
   467 
       
   468 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   469 }
       
   470 
       
   471 // ----------------------------------------------------------------------
       
   472 
       
   473 eap_status_e eap_am_plugin_symbian_c::set_configuration(const eap_method_settings_c * const internal_settings)
       
   474 {
       
   475 	EAP_TRACE_DEBUG(
       
   476 		m_am_tools,
       
   477 		TRACE_FLAGS_DEFAULT,
       
   478 		(EAPL("eap_am_plugin_symbian_c::set_configuration(): this=0x%08x.\n"),
       
   479 		this));
       
   480 
       
   481 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_plugin_symbian_c::set_configuration()");
       
   482 
       
   483 	const eap_tlv_message_type_function_e error_completion_function(eap_tlv_message_type_function_plugin_complete_set_configuration);
       
   484 
       
   485 	CEapTypePlugin* const eapType = get_eap_type(internal_settings->m_EAPType, internal_settings->m_IndexType, internal_settings->m_Index);
       
   486 	if (eapType == 0)
       
   487 	{
       
   488 		return EAP_STATUS_RETURN(
       
   489 			m_am_tools,
       
   490 			error_complete(
       
   491 				eap_status_allocation_error,
       
   492 				internal_settings,
       
   493 				error_completion_function));
       
   494 	}
       
   495 
       
   496 	if (internal_settings->m_TunnelingTypePresent == true)
       
   497 	{
       
   498 		TEapExpandedType aExpandedType;
       
   499     
       
   500 		TInt err = CEapConversion::ConvertInternalTypeToExpandedEAPType(
       
   501 				&(internal_settings->m_TunnelingType),
       
   502 				&aExpandedType);
       
   503 
       
   504 		eapType->SetTunnelingType(aExpandedType);
       
   505 	}
       
   506 
       
   507 	EAPSettings * local_settings = new EAPSettings;
       
   508 
       
   509 	eap_automatic_variable_c<EAPSettings> automatic_aSettings(
       
   510 		m_am_tools,
       
   511 		local_settings);
       
   512 
       
   513 	if (local_settings == 0)
       
   514 	{
       
   515 		return EAP_STATUS_RETURN(
       
   516 			m_am_tools,
       
   517 			error_complete(
       
   518 				eap_status_allocation_error,
       
   519 				internal_settings,
       
   520 				error_completion_function));
       
   521 	}
       
   522 
       
   523 	TInt error = CEapConversion::ConvertInternalTypeToEAPSettings(
       
   524 		m_am_tools,
       
   525 		internal_settings,
       
   526 		local_settings);
       
   527 	if (error != KErrNone)
       
   528 	{
       
   529 		return EAP_STATUS_RETURN(
       
   530 			m_am_tools,
       
   531 			error_complete(
       
   532 				m_am_tools->convert_am_error_to_eapol_error(error),
       
   533 				internal_settings,
       
   534 				error_completion_function));
       
   535 	}
       
   536 
       
   537 	TRAP(error, (eapType->SetConfigurationL(*local_settings)));
       
   538 	if (error != KErrNone)
       
   539 	{
       
   540 		EAP_TRACE_DEBUG(
       
   541 			m_am_tools,
       
   542 			TRACE_FLAGS_DEFAULT,
       
   543 			(EAPL("ERROR: Cannot write configuration to EAP-type=0xfe%06x%08x, index_type=%d, index=%d.\n"),
       
   544 			internal_settings->m_EAPType.get_vendor_id(),
       
   545 			internal_settings->m_EAPType.get_vendor_type(),
       
   546 			internal_settings->m_IndexType,
       
   547 			internal_settings->m_Index));
       
   548 
       
   549 		return EAP_STATUS_RETURN(
       
   550 			m_am_tools,
       
   551 			error_complete(
       
   552 				m_am_tools->convert_am_error_to_eapol_error(error),
       
   553 				internal_settings,
       
   554 				error_completion_function));
       
   555 	}
       
   556 
       
   557 	eap_method_settings_c * const complete_settings = new eap_method_settings_c(m_am_tools, internal_settings);
       
   558 
       
   559 	eap_automatic_variable_c<eap_method_settings_c> automatic_complete_settings(
       
   560 		m_am_tools,
       
   561 		complete_settings);
       
   562 
       
   563 	if (complete_settings == 0)
       
   564 	{
       
   565 		return EAP_STATUS_RETURN(
       
   566 			m_am_tools,
       
   567 			error_complete(
       
   568 				eap_status_allocation_error,
       
   569 				internal_settings,
       
   570 				error_completion_function));
       
   571 	}
       
   572 
       
   573 	complete_settings->m_completion_status = eap_status_ok;
       
   574 
       
   575 	eap_status_e status = m_partner->complete_set_configuration(complete_settings);
       
   576 
       
   577 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   578 }
       
   579 
       
   580 // ----------------------------------------------------------------------
       
   581 
       
   582 eap_status_e eap_am_plugin_symbian_c::copy_configuration(const eap_method_settings_c * const internal_settings)
       
   583 {
       
   584 	EAP_TRACE_DEBUG(
       
   585 		m_am_tools,
       
   586 		TRACE_FLAGS_DEFAULT,
       
   587 		(EAPL("eap_am_plugin_symbian_c::set_configuration(): this=0x%08x.\n"),
       
   588 		this));
       
   589 
       
   590 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_plugin_symbian_c::set_configuration()");
       
   591 
       
   592 	const eap_tlv_message_type_function_e error_completion_function(eap_tlv_message_type_function_plugin_complete_copy_configuration);
       
   593 
       
   594 	CEapTypePlugin* const eapType = get_eap_type(internal_settings->m_EAPType, internal_settings->m_IndexType, internal_settings->m_Index);
       
   595 	if (eapType == 0)
       
   596 	{
       
   597 		return EAP_STATUS_RETURN(
       
   598 			m_am_tools,
       
   599 			error_complete(
       
   600 				eap_status_allocation_error,
       
   601 				internal_settings,
       
   602 				error_completion_function));
       
   603 	}
       
   604 
       
   605 	if (internal_settings->m_TunnelingTypePresent == true)
       
   606 	{
       
   607 		TEapExpandedType aExpandedType;
       
   608     
       
   609 		TInt err = CEapConversion::ConvertInternalTypeToExpandedEAPType(
       
   610 				&(internal_settings->m_TunnelingType),
       
   611 				&aExpandedType);
       
   612 
       
   613 		eapType->SetTunnelingType(aExpandedType);
       
   614 	}
       
   615 
       
   616 	EAPSettings * local_settings = new EAPSettings;
       
   617 
       
   618 	eap_automatic_variable_c<EAPSettings> automatic_aSettings(
       
   619 		m_am_tools,
       
   620 		local_settings);
       
   621 
       
   622 	if (local_settings == 0)
       
   623 	{
       
   624 		return EAP_STATUS_RETURN(
       
   625 			m_am_tools,
       
   626 			error_complete(
       
   627 				eap_status_allocation_error,
       
   628 				internal_settings,
       
   629 				error_completion_function));
       
   630 	}
       
   631 
       
   632 	TInt error = CEapConversion::ConvertInternalTypeToEAPSettings(
       
   633 		m_am_tools,
       
   634 		internal_settings,
       
   635 		local_settings);
       
   636 	if (error != KErrNone)
       
   637 	{
       
   638 		return EAP_STATUS_RETURN(
       
   639 			m_am_tools,
       
   640 			error_complete(
       
   641 				m_am_tools->convert_am_error_to_eapol_error(error),
       
   642 				internal_settings,
       
   643 				error_completion_function));
       
   644 	}
       
   645 
       
   646 	if (internal_settings->m_DestinationIndexAndTypePresent == false)
       
   647 	{
       
   648 		return EAP_STATUS_RETURN(
       
   649 			m_am_tools,
       
   650 			error_complete(
       
   651 				eap_status_illegal_parameter,
       
   652 				internal_settings,
       
   653 				error_completion_function));
       
   654 	}
       
   655 
       
   656 	TIndexType aDestinationIndexType(static_cast<TIndexType>(internal_settings->m_DestinationIndexType));
       
   657 	TUint aDestinationIndex(static_cast<TUint>(internal_settings->m_DestinationIndex));
       
   658 
       
   659 	TRAP(error, (eapType->CopySettingsL(
       
   660 		aDestinationIndexType, 
       
   661 		aDestinationIndex)));
       
   662 	if (error != KErrNone)
       
   663 	{
       
   664 		EAP_TRACE_DEBUG(
       
   665 			m_am_tools,
       
   666 			TRACE_FLAGS_DEFAULT,
       
   667 			(EAPL("ERROR: Cannot copy configuration from EAP-type=0xfe%06x%08x, (index_type=%d, index=%d) to (index_type=%d, index=%d).\n"),
       
   668 			internal_settings->m_EAPType.get_vendor_id(),
       
   669 			internal_settings->m_EAPType.get_vendor_type(),
       
   670 			internal_settings->m_IndexType,
       
   671 			internal_settings->m_Index,
       
   672 			internal_settings->m_DestinationIndexType,
       
   673 			internal_settings->m_DestinationIndex));
       
   674 
       
   675 		return EAP_STATUS_RETURN(
       
   676 			m_am_tools,
       
   677 			error_complete(
       
   678 				m_am_tools->convert_am_error_to_eapol_error(error),
       
   679 				internal_settings,
       
   680 				error_completion_function));
       
   681 	}
       
   682 
       
   683 	eap_method_settings_c * const complete_settings = new eap_method_settings_c(m_am_tools, internal_settings);
       
   684 
       
   685 	eap_automatic_variable_c<eap_method_settings_c> automatic_complete_settings(
       
   686 		m_am_tools,
       
   687 		complete_settings);
       
   688 
       
   689 	if (complete_settings == 0)
       
   690 	{
       
   691 		return EAP_STATUS_RETURN(
       
   692 			m_am_tools,
       
   693 			error_complete(
       
   694 				eap_status_allocation_error,
       
   695 				internal_settings,
       
   696 				error_completion_function));
       
   697 	}
       
   698 
       
   699 	complete_settings->m_completion_status = eap_status_ok;
       
   700 
       
   701 	eap_status_e status = m_partner->complete_copy_configuration(complete_settings);
       
   702 
       
   703 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   704 }
       
   705 
       
   706 // ----------------------------------------------------------------------
       
   707 
       
   708 eap_status_e eap_am_plugin_symbian_c::delete_configuration(const eap_method_settings_c * const internal_settings)
       
   709 {
       
   710 	EAP_TRACE_DEBUG(
       
   711 		m_am_tools,
       
   712 		TRACE_FLAGS_DEFAULT,
       
   713 		(EAPL("eap_am_plugin_symbian_c::delete_configuration(): this=0x%08x.\n"),
       
   714 		this));
       
   715 
       
   716 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_plugin_symbian_c::delete_configuration()");
       
   717 
       
   718 	const eap_tlv_message_type_function_e error_completion_function(eap_tlv_message_type_function_plugin_complete_delete_configuration);
       
   719 
       
   720 	CEapTypePlugin* const eapType = get_eap_type(internal_settings->m_EAPType, internal_settings->m_IndexType, internal_settings->m_Index);
       
   721 	if (eapType == 0)
       
   722 	{
       
   723 		return EAP_STATUS_RETURN(
       
   724 			m_am_tools,
       
   725 			error_complete(
       
   726 				eap_status_allocation_error,
       
   727 				internal_settings,
       
   728 				error_completion_function));
       
   729 	}
       
   730 
       
   731 	if (internal_settings->m_TunnelingTypePresent == true)
       
   732 	{
       
   733 		TEapExpandedType aExpandedType;
       
   734     
       
   735 		TInt err = CEapConversion::ConvertInternalTypeToExpandedEAPType(
       
   736 				&(internal_settings->m_TunnelingType),
       
   737 				&aExpandedType);
       
   738 
       
   739 		eapType->SetTunnelingType(aExpandedType);
       
   740 	}
       
   741 
       
   742 	EAPSettings * local_settings = new EAPSettings;
       
   743 
       
   744 	eap_automatic_variable_c<EAPSettings> automatic_aSettings(
       
   745 		m_am_tools,
       
   746 		local_settings);
       
   747 
       
   748 	if (local_settings == 0)
       
   749 	{
       
   750 		return EAP_STATUS_RETURN(
       
   751 			m_am_tools,
       
   752 			error_complete(
       
   753 				eap_status_allocation_error,
       
   754 				internal_settings,
       
   755 				error_completion_function));
       
   756 	}
       
   757 
       
   758 	TInt error = CEapConversion::ConvertInternalTypeToEAPSettings(
       
   759 		m_am_tools,
       
   760 		internal_settings,
       
   761 		local_settings);
       
   762 	if (error != KErrNone)
       
   763 	{
       
   764 		return EAP_STATUS_RETURN(
       
   765 			m_am_tools,
       
   766 			error_complete(
       
   767 				m_am_tools->convert_am_error_to_eapol_error(error),
       
   768 				internal_settings,
       
   769 				error_completion_function));
       
   770 	}
       
   771 
       
   772 	TRAP(error, (eapType->DeleteConfigurationL()));
       
   773 	if (error != KErrNone)
       
   774 	{
       
   775 		EAP_TRACE_DEBUG(
       
   776 			m_am_tools,
       
   777 			TRACE_FLAGS_DEFAULT,
       
   778 			(EAPL("ERROR: Cannot delete configuration from EAP-type=0xfe%06x%08x, (index_type=%d, index=%d).\n"),
       
   779 			internal_settings->m_EAPType.get_vendor_id(),
       
   780 			internal_settings->m_EAPType.get_vendor_type(),
       
   781 			internal_settings->m_IndexType,
       
   782 			internal_settings->m_Index));
       
   783 
       
   784 		return EAP_STATUS_RETURN(
       
   785 			m_am_tools,
       
   786 			error_complete(
       
   787 				m_am_tools->convert_am_error_to_eapol_error(error),
       
   788 				internal_settings,
       
   789 				error_completion_function));
       
   790 	}
       
   791 
       
   792 	eap_method_settings_c * const complete_settings = new eap_method_settings_c(m_am_tools, internal_settings);
       
   793 
       
   794 	eap_automatic_variable_c<eap_method_settings_c> automatic_complete_settings(
       
   795 		m_am_tools,
       
   796 		complete_settings);
       
   797 
       
   798 	if (complete_settings == 0)
       
   799 	{
       
   800 		return EAP_STATUS_RETURN(
       
   801 			m_am_tools,
       
   802 			error_complete(
       
   803 				eap_status_allocation_error,
       
   804 				internal_settings,
       
   805 				error_completion_function));
       
   806 	}
       
   807 
       
   808 	complete_settings->m_completion_status = eap_status_ok;
       
   809 
       
   810 	eap_status_e status = m_partner->complete_delete_configuration(complete_settings);
       
   811 
       
   812 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   813 }
       
   814 
       
   815 // ----------------------------------------------------------------------
       
   816 
       
   817 eap_status_e eap_am_plugin_symbian_c::set_index(const eap_method_settings_c * const internal_settings)
       
   818 {
       
   819 	EAP_TRACE_DEBUG(
       
   820 		m_am_tools,
       
   821 		TRACE_FLAGS_DEFAULT,
       
   822 		(EAPL("eap_am_plugin_symbian_c::set_index(): this=0x%08x.\n"),
       
   823 		this));
       
   824 
       
   825 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_plugin_symbian_c::set_index()");
       
   826 
       
   827 	const eap_tlv_message_type_function_e error_completion_function(eap_tlv_message_type_function_plugin_complete_set_index);
       
   828 
       
   829 	CEapTypePlugin* const eapType = get_eap_type(internal_settings->m_EAPType, internal_settings->m_IndexType, internal_settings->m_Index);
       
   830 	if (eapType == 0)
       
   831 	{
       
   832 		return EAP_STATUS_RETURN(
       
   833 			m_am_tools,
       
   834 			error_complete(
       
   835 				eap_status_allocation_error,
       
   836 				internal_settings,
       
   837 				error_completion_function));
       
   838 	}
       
   839 
       
   840 	if (internal_settings->m_TunnelingTypePresent == true)
       
   841 	{
       
   842 		TEapExpandedType aExpandedType;
       
   843     
       
   844 		TInt err = CEapConversion::ConvertInternalTypeToExpandedEAPType(
       
   845 				&(internal_settings->m_TunnelingType),
       
   846 				&aExpandedType);
       
   847 
       
   848 		eapType->SetTunnelingType(aExpandedType);
       
   849 	}
       
   850 
       
   851 	EAPSettings * local_settings = new EAPSettings;
       
   852 
       
   853 	eap_automatic_variable_c<EAPSettings> automatic_aSettings(
       
   854 		m_am_tools,
       
   855 		local_settings);
       
   856 
       
   857 	if (local_settings == 0)
       
   858 	{
       
   859 		return EAP_STATUS_RETURN(
       
   860 			m_am_tools,
       
   861 			error_complete(
       
   862 				eap_status_allocation_error,
       
   863 				internal_settings,
       
   864 				error_completion_function));
       
   865 	}
       
   866 
       
   867 	TInt error = CEapConversion::ConvertInternalTypeToEAPSettings(
       
   868 		m_am_tools,
       
   869 		internal_settings,
       
   870 		local_settings);
       
   871 	if (error != KErrNone)
       
   872 	{
       
   873 		return EAP_STATUS_RETURN(
       
   874 			m_am_tools,
       
   875 			error_complete(
       
   876 				m_am_tools->convert_am_error_to_eapol_error(error),
       
   877 				internal_settings,
       
   878 				error_completion_function));
       
   879 	}
       
   880 
       
   881 	if (internal_settings->m_DestinationIndexAndTypePresent == false)
       
   882 	{
       
   883 		return EAP_STATUS_RETURN(
       
   884 			m_am_tools,
       
   885 			error_complete(
       
   886 				eap_status_illegal_parameter,
       
   887 				internal_settings,
       
   888 				error_completion_function));
       
   889 	}
       
   890 
       
   891 	TIndexType aDestinationIndexType(static_cast<TIndexType>(internal_settings->m_DestinationIndexType));
       
   892 	TUint aDestinationIndex(static_cast<TUint>(internal_settings->m_DestinationIndex));
       
   893 
       
   894 	TRAP(error, (eapType->SetIndexL(
       
   895 		aDestinationIndexType, 
       
   896 		aDestinationIndex)));
       
   897 	if (error != KErrNone)
       
   898 	{
       
   899 		EAP_TRACE_DEBUG(
       
   900 			m_am_tools,
       
   901 			TRACE_FLAGS_DEFAULT,
       
   902 			(EAPL("ERROR: Cannot copy configuration from EAP-type=0xfe%06x%08x, (index_type=%d, index=%d) to (index_type=%d, index=%d).\n"),
       
   903 			internal_settings->m_EAPType.get_vendor_id(),
       
   904 			internal_settings->m_EAPType.get_vendor_type(),
       
   905 			internal_settings->m_IndexType,
       
   906 			internal_settings->m_Index,
       
   907 			internal_settings->m_DestinationIndexType,
       
   908 			internal_settings->m_DestinationIndex));
       
   909 
       
   910 		return EAP_STATUS_RETURN(
       
   911 			m_am_tools,
       
   912 			error_complete(
       
   913 				m_am_tools->convert_am_error_to_eapol_error(error),
       
   914 				internal_settings,
       
   915 				error_completion_function));
       
   916 	}
       
   917 
       
   918 	eap_method_settings_c * const complete_settings = new eap_method_settings_c(m_am_tools, internal_settings);
       
   919 
       
   920 	eap_automatic_variable_c<eap_method_settings_c> automatic_complete_settings(
       
   921 		m_am_tools,
       
   922 		complete_settings);
       
   923 
       
   924 	if (complete_settings == 0)
       
   925 	{
       
   926 		return EAP_STATUS_RETURN(
       
   927 			m_am_tools,
       
   928 			error_complete(
       
   929 				eap_status_allocation_error,
       
   930 				internal_settings,
       
   931 				error_completion_function));
       
   932 	}
       
   933 
       
   934 	complete_settings->m_completion_status = eap_status_ok;
       
   935 
       
   936 	eap_status_e status = m_partner->complete_set_index(complete_settings);
       
   937 
       
   938 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   939 }
       
   940 
       
   941 // ----------------------------------------------------------------------
       
   942 
       
   943 eap_status_e eap_am_plugin_symbian_c::get_type_info(const eap_method_settings_c * const internal_settings)
       
   944 {
       
   945 	EAP_TRACE_DEBUG(
       
   946 		m_am_tools,
       
   947 		TRACE_FLAGS_DEFAULT,
       
   948 		(EAPL("eap_am_plugin_symbian_c::get_type_info(): this=0x%08x.\n"),
       
   949 		this));
       
   950 
       
   951 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_plugin_symbian_c::get_type_info()");
       
   952 
       
   953 	const eap_tlv_message_type_function_e error_completion_function(eap_tlv_message_type_function_plugin_complete_get_type_info);
       
   954 
       
   955 	CEapTypePlugin* const eapType = get_eap_type(internal_settings->m_EAPType, internal_settings->m_IndexType, internal_settings->m_Index);
       
   956 	if (eapType == 0)
       
   957 	{
       
   958 		return EAP_STATUS_RETURN(
       
   959 			m_am_tools,
       
   960 			error_complete(
       
   961 				eap_status_allocation_error,
       
   962 				internal_settings,
       
   963 				error_completion_function));
       
   964 	}
       
   965 
       
   966 	if (internal_settings->m_TunnelingTypePresent == true)
       
   967 	{
       
   968 		TEapExpandedType aExpandedType;
       
   969     
       
   970 		TInt err = CEapConversion::ConvertInternalTypeToExpandedEAPType(
       
   971 				&(internal_settings->m_TunnelingType),
       
   972 				&aExpandedType);
       
   973 
       
   974 		eapType->SetTunnelingType(aExpandedType);
       
   975 	}
       
   976 
       
   977 	EAPSettings * local_settings = new EAPSettings;
       
   978 
       
   979 	eap_automatic_variable_c<EAPSettings> automatic_aSettings(
       
   980 		m_am_tools,
       
   981 		local_settings);
       
   982 
       
   983 	if (local_settings == 0)
       
   984 	{
       
   985 		return EAP_STATUS_RETURN(
       
   986 			m_am_tools,
       
   987 			error_complete(
       
   988 				eap_status_allocation_error,
       
   989 				internal_settings,
       
   990 				error_completion_function));
       
   991 	}
       
   992 
       
   993 	TInt error = CEapConversion::ConvertInternalTypeToEAPSettings(
       
   994 		m_am_tools,
       
   995 		internal_settings,
       
   996 		local_settings);
       
   997 	if (error != KErrNone)
       
   998 	{
       
   999 		return EAP_STATUS_RETURN(
       
  1000 			m_am_tools,
       
  1001 			error_complete(
       
  1002 				m_am_tools->convert_am_error_to_eapol_error(error),
       
  1003 				internal_settings,
       
  1004 				error_completion_function));
       
  1005 	}
       
  1006 
       
  1007 	if (internal_settings->m_DestinationIndexAndTypePresent == false)
       
  1008 	{
       
  1009 		return EAP_STATUS_RETURN(
       
  1010 			m_am_tools,
       
  1011 			error_complete(
       
  1012 				eap_status_illegal_parameter,
       
  1013 				internal_settings,
       
  1014 				error_completion_function));
       
  1015 	}
       
  1016 
       
  1017 	CEapTypeInfo * type_info = 0;
       
  1018 
       
  1019 	TRAP(error, (type_info = eapType->GetInfoL()));
       
  1020 	if (error != KErrNone
       
  1021 		|| type_info == 0)
       
  1022 	{
       
  1023 		EAP_TRACE_DEBUG(
       
  1024 			m_am_tools,
       
  1025 			TRACE_FLAGS_DEFAULT,
       
  1026 			(EAPL("ERROR: Cannot get type info configuration from EAP-type=0xfe%06x%08x, (index_type=%d, index=%d).\n"),
       
  1027 			internal_settings->m_EAPType.get_vendor_id(),
       
  1028 			internal_settings->m_EAPType.get_vendor_type(),
       
  1029 			internal_settings->m_IndexType,
       
  1030 			internal_settings->m_Index));
       
  1031 
       
  1032 		if (type_info != 0)
       
  1033 		{
       
  1034 			delete type_info;
       
  1035 			type_info = 0;
       
  1036 		}
       
  1037 
       
  1038 		return EAP_STATUS_RETURN(
       
  1039 			m_am_tools,
       
  1040 			error_complete(
       
  1041 				m_am_tools->convert_am_error_to_eapol_error(error),
       
  1042 				internal_settings,
       
  1043 				error_completion_function));
       
  1044 	}
       
  1045 
       
  1046 	eap_method_settings_c * const complete_settings = new eap_method_settings_c(m_am_tools, internal_settings);
       
  1047 
       
  1048 	eap_automatic_variable_c<eap_method_settings_c> automatic_complete_settings(
       
  1049 		m_am_tools,
       
  1050 		complete_settings);
       
  1051 
       
  1052 	if (complete_settings == 0)
       
  1053 	{
       
  1054 		delete type_info;
       
  1055 		type_info = 0;
       
  1056 		return EAP_STATUS_RETURN(
       
  1057 			m_am_tools,
       
  1058 			error_complete(
       
  1059 				eap_status_allocation_error,
       
  1060 				internal_settings,
       
  1061 				error_completion_function));
       
  1062 	}
       
  1063 
       
  1064 	error = CEapConversion::ConvertFromTDesCToInternal(
       
  1065 		m_am_tools,
       
  1066 		type_info->ReleaseDate(),
       
  1067 		&(complete_settings->m_KReleaseDate));
       
  1068 
       
  1069 	if(error == KErrNone)
       
  1070 	{
       
  1071 		error = CEapConversion::ConvertFromTDesCToInternal(
       
  1072 			m_am_tools,
       
  1073 			type_info->Version(),
       
  1074 			&(complete_settings->m_KEapTypeVersion));
       
  1075 	}
       
  1076 
       
  1077 	if(error == KErrNone)
       
  1078 	{
       
  1079 		error = CEapConversion::ConvertFromTDesCToInternal(
       
  1080 			m_am_tools,
       
  1081 			type_info->Manufacturer(),
       
  1082 			&(complete_settings->m_KManufacturer));
       
  1083 	}
       
  1084 
       
  1085 	delete type_info;
       
  1086 	type_info = 0;
       
  1087 
       
  1088 	if(error != KErrNone)
       
  1089 	{
       
  1090 		return EAP_STATUS_RETURN(
       
  1091 			m_am_tools,
       
  1092 			error_complete(
       
  1093 				m_am_tools->convert_am_error_to_eapol_error(error),
       
  1094 				internal_settings,
       
  1095 				error_completion_function));
       
  1096 	}
       
  1097 
       
  1098 	complete_settings->m_completion_status = eap_status_ok;
       
  1099 
       
  1100 	eap_status_e status = m_partner->complete_get_type_info(complete_settings);
       
  1101 
       
  1102 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1103 }
       
  1104 
       
  1105 // ----------------------------------------------------------------------
       
  1106 
       
  1107 
       
  1108 
       
  1109 // ----------------------------------------------------------------------
       
  1110 // End