eapol/eapol_framework/eapol_symbian/am/type/mschapv2/symbian/eap_am_type_mschapv2_symbian.cpp
changeset 26 9abfd4f00d37
parent 2 1c7bc153c08e
child 34 ad1f037f1ac2
equal deleted inserted replaced
25:e03a3db4489e 26:9abfd4f00d37
    14 * Description:  EAP and WLAN authentication protocols.
    14 * Description:  EAP and WLAN authentication protocols.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 33 %
    19 * %version: 30.1.14 %
    20 */
    20 */
    21 
    21 
    22 // This is enumeration of EAPOL source code.
    22 // This is enumeration of EAPOL source code.
    23 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
    23 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
    24 	#undef EAP_FILE_NUMBER_ENUM
    24 	#undef EAP_FILE_NUMBER_ENUM
    40 #include "EapMsChapV2DbDefaults.h"
    40 #include "EapMsChapV2DbDefaults.h"
    41 #include "EapMsChapV2DbUtils.h"
    41 #include "EapMsChapV2DbUtils.h"
    42 #include "EapMsChapV2NotifierUids.h"
    42 #include "EapMsChapV2NotifierUids.h"
    43 #include "eap_state_notification.h"
    43 #include "eap_state_notification.h"
    44 
    44 
    45 #include "eap_am_trace_symbian.h"
    45 #include "EapTraceSymbian.h"
    46 
    46 
    47 const TUint KMaxSqlQueryLength = 256;
    47 const TUint KMaxSqlQueryLength = 256;
    48 const TUint KMaxDBFieldNameLength = 255;
    48 const TUint KMaxDBFieldNameLength = 255;
    49 const char EAP_MSCHAPV2_CREDENTIAL_HANDLE_KEY[] = "eap_type_mschapv2_c credential_store";
    49 const char EAP_MSCHAPV2_CREDENTIAL_HANDLE_KEY[] = "eap_type_mschapv2_c credential_store";
    50 const TInt 	KDefaultColumnInView_One = 1; // For DB view.
    50 const TInt 	KDefaultColumnInView_One = 1; // For DB view.
    67 	m_database.Close();
    67 	m_database.Close();
    68 	m_session.Close();
    68 	m_session.Close();
    69 
    69 
    70 	delete m_username_password_io_ptr;
    70 	delete m_username_password_io_ptr;
    71 	delete m_username_password_io_pckg_ptr;
    71 	delete m_username_password_io_pckg_ptr;
       
    72 
       
    73 	if (iEapAuthNotifier != 0)
       
    74 		{
       
    75 		delete iEapAuthNotifier;
       
    76 		iEapAuthNotifier = 0;
       
    77 		}
    72 
    78 
    73 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
    79 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
    74 }
    80 }
    75 
    81 
    76 //--------------------------------------------------
    82 //--------------------------------------------------
    83 		m_am_tools, 
    89 		m_am_tools, 
    84 		TRACE_FLAGS_DEFAULT, 
    90 		TRACE_FLAGS_DEFAULT, 
    85 		(EAPL("eap_am_type_mschapv2_symbian_c::shutdown(): this = 0x%08x\n"),
    91 		(EAPL("eap_am_type_mschapv2_symbian_c::shutdown(): this = 0x%08x\n"),
    86 		this));
    92 		this));
    87 		
    93 		
    88 	if( IsActive() )
    94 
    89 	{
    95 
    90 		Cancel(); // Cancel only if active.
    96 
    91 	}  
       
    92 	else
       
    93 	{
       
    94 		if( m_is_notifier_connected )
       
    95 		{
       
    96 		
       
    97 		EAP_TRACE_DEBUG(
       
    98 			m_am_tools, 
       
    99 			TRACE_FLAGS_DEFAULT, 
       
   100 			(EAPL("eap_am_type_mschapv2_symbian_c::shutdown - calling m_notifier.CancelNotifier(..)\n")));
       
   101 			
       
   102 		TInt error = KErrNone;			
       
   103 		EAP_UNREFERENCED_PARAMETER(error);
       
   104 		error = m_notifier.CancelNotifier(KEapMsChapV2UsernamePasswordUid);
       
   105 	
       
   106 		EAP_TRACE_DEBUG(
       
   107 			m_am_tools, 
       
   108 			TRACE_FLAGS_DEFAULT, 
       
   109 			(EAPL("eap_am_type_mschapv2_symbian_c::shutdown - calling m_notifier.Close(), prev error=%d\n"),
       
   110 			error));
       
   111 		
       
   112 		m_notifier.Close(); // Call close only if it is connected.	
       
   113 		
       
   114 		m_is_notifier_connected = false;
       
   115 		}
       
   116 	}
       
   117 	
       
   118 	m_shutdown_was_called = true;
    97 	m_shutdown_was_called = true;
   119 
    98 
   120 	EAP_TRACE_DEBUG(
    99 	EAP_TRACE_DEBUG(
   121 		m_am_tools, 
   100 		m_am_tools, 
   122 		TRACE_FLAGS_DEFAULT, 
   101 		TRACE_FLAGS_DEFAULT, 
   154 , m_index(aIndex)
   133 , m_index(aIndex)
   155 , m_tunneling_type(aTunnelingType)
   134 , m_tunneling_type(aTunnelingType)
   156 , m_is_client(aIsClient)
   135 , m_is_client(aIsClient)
   157 , m_is_valid(false)
   136 , m_is_valid(false)
   158 , m_shutdown_was_called(false)
   137 , m_shutdown_was_called(false)
   159 , m_is_notifier_connected(false)
   138 
   160 , m_max_session_time(0)
   139 , m_max_session_time(0)
       
   140 	, iEapAuthNotifier(0)	
       
   141 
       
   142 
   161 {
   143 {
   162 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   144 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   163 	
   145 	
   164 #ifdef USE_EAP_EXPANDED_TYPES
       
   165 
       
   166 	m_tunneling_vendor_type = m_tunneling_type.get_vendor_type();
       
   167 
       
   168 #else
       
   169 
       
   170 	m_tunneling_vendor_type = static_cast<TUint>(m_tunneling_type);
       
   171 
       
   172 #endif //#ifdef USE_EAP_EXPANDED_TYPES	
       
   173 
       
   174 	if (receive_network_id != 0
   146 	if (receive_network_id != 0
   175 		&& receive_network_id->get_is_valid_data() == true)
   147 		&& receive_network_id->get_is_valid_data() == true)
   176 	{
   148 	{
   177 		eap_status_e status = m_receive_network_id.set_copy_of_network_id(
   149 		eap_status_e status = m_receive_network_id.set_copy_of_network_id(
   178 			receive_network_id);
   150 			receive_network_id);
   230 	// NOTE: Do not use m_partner here without null check
   202 	// NOTE: Do not use m_partner here without null check
   231 
   203 
   232 	// Open/create the database
   204 	// Open/create the database
   233 	EapMsChapV2DbUtils::OpenDatabaseL(m_database, m_session, m_index_type, m_index, m_tunneling_type);
   205 	EapMsChapV2DbUtils::OpenDatabaseL(m_database, m_session, m_index_type, m_index, m_tunneling_type);
   234 
   206 
   235 	m_username_password_io_ptr = new(ELeave) TEapMsChapV2UsernamePasswordInfo;
   207 	m_username_password_io_ptr = new(ELeave) CEapAuthNotifier::TEapDialogInfo;
   236 	m_username_password_io_pckg_ptr = new(ELeave) TPckg<TEapMsChapV2UsernamePasswordInfo> (*m_username_password_io_ptr);
   208 	m_username_password_io_pckg_ptr = new(ELeave) TPckg<CEapAuthNotifier::TEapDialogInfo> (*m_username_password_io_ptr);
       
   209 
       
   210 		EAP_TRACE_DATA_DEBUG(
       
   211 			m_am_tools,
       
   212 			TRACE_FLAGS_DEFAULT,
       
   213 			(EAPL("eap_am_type_mschapv2_symbian_c::ConstructL m_username_password_io_pckg_ptr"),
       
   214 			m_username_password_io_pckg_ptr->Ptr(),
       
   215 			m_username_password_io_pckg_ptr->Size()));	
   237 
   216 
   238 	CActiveScheduler::Add(this);
   217 	CActiveScheduler::Add(this);
   239 
   218 
   240 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   219 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   241 }
   220 }
   287 
   266 
   288 	m_partner->state_notification(&notification);
   267 	m_partner->state_notification(&notification);
   289 }
   268 }
   290 
   269 
   291 //--------------------------------------------------
   270 //--------------------------------------------------
   292 
   271 EAP_FUNC_EXPORT void eap_am_type_mschapv2_symbian_c::DlgComplete( TInt aStatus )
   293 void eap_am_type_mschapv2_symbian_c::RunL()
   272 	{
   294 {
   273 	if (aStatus == KErrCancel)
   295 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   274 		{
   296 	
       
   297 	EAP_TRACE_DEBUG(
       
   298 		m_am_tools,
       
   299 		TRACE_FLAGS_DEFAULT,
       
   300 		(EAPL("eap_am_type_mschapv2_symbian_c::RunL - start")
       
   301 		 EAPL("m_state, iStatus.Int()=%d\n"),
       
   302 		 m_state, iStatus.Int()));
       
   303 
       
   304 	if (iStatus.Int() == KErrCancel)
       
   305 	{
       
   306 		EAP_TRACE_DEBUG(
   275 		EAP_TRACE_DEBUG(
   307 			m_am_tools, 
   276 			m_am_tools, 
   308 			TRACE_FLAGS_DEFAULT, 
   277 			TRACE_FLAGS_DEFAULT, 
   309 			(EAPL("eap_am_type_mschapv2_symbian_c::RunL - User seems to have cancelled the prompt. Stop Immediately.\n")));
   278 			(EAPL("eap_am_type_mschapv2_symbian_c::RunL - User seems to have cancelled the prompt. Stop Immediately.\n")));
   310 		
   279 		
   312 		// Appropriate error notification is sent from finish_unsuccessful_authentication.
   281 		// Appropriate error notification is sent from finish_unsuccessful_authentication.
   313 		get_am_partner()->finish_unsuccessful_authentication(true);
   282 		get_am_partner()->finish_unsuccessful_authentication(true);
   314 		
   283 		
   315 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   284 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   316 		return;
   285 		return;
   317 	}
   286 		}
   318 
   287 
   319 	if (iStatus.Int() != KErrNone)
   288 	if (aStatus != KErrNone)
   320 	{
   289 		{
   321 		// Something is very wrong...
   290 		// Something is very wrong...
   322 		EAP_TRACE_ERROR(
   291 		EAP_TRACE_ERROR(
   323 			m_am_tools,
   292 			m_am_tools,
   324 			TRACE_FLAGS_DEFAULT,
   293 			TRACE_FLAGS_DEFAULT,
   325 			(EAPL("ERROR: EAP - MS-Chap-V2 notifier or dialog, iStatus.Int()=%d\n"), iStatus.Int()));
   294 			(EAPL("ERROR: EAP - MS-Chap-V2 notifier or dialog, aStatus=%d\n"), aStatus));
   326 
   295 
   327 		send_error_notification(eap_status_authentication_failure);
   296 		send_error_notification(eap_status_authentication_failure);
   328 
   297 
   329 		get_am_partner()->finish_unsuccessful_authentication(false);
   298 		get_am_partner()->finish_unsuccessful_authentication(false);
   330 
   299 
   331 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   300 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   332 		return;
   301 		return;
   333 	}
   302 		}
   334 
   303 
   335 	eap_status_e status(eap_status_ok);
   304 	eap_status_e status(eap_status_ok);
   336 
   305 
   337 	switch (m_state)
   306 	switch (m_state)
   338 	{
   307 		{
   339 	case EHandlingUsernamePasswordQuery:
   308 		case EHandlingUsernamePasswordQuery:
   340 		{
   309 			{
   341 			if (m_username_password_io_ptr->iPasswordPromptEnabled)
   310 			if (m_username_password_io_ptr->iPasswordPromptEnabled)
   342 			{
   311 				{
   343 				*m_password_prompt_enabled = true;
   312 				*m_password_prompt_enabled = true;
   344 			}
   313 				}
   345 			else
   314 			else
   346 			{
   315 				{
   347 				*m_password_prompt_enabled = false;
   316 				*m_password_prompt_enabled = false;
   348 			}
   317 				}
   349 
   318 
   350 			{
   319 				{
   351 				eap_variable_data_c tmp_username_unicode(
   320 				eap_variable_data_c tmp_username_unicode(
   352 					m_am_tools);
   321 					m_am_tools);
   353 
   322 
   354 				status = tmp_username_unicode.set_buffer(
   323 				status = tmp_username_unicode.set_buffer(
   355 					m_username_password_io_ptr->iUsername.Ptr(),
   324 					m_username_password_io_ptr->iUsername.Ptr(),
   356 					m_username_password_io_ptr->iUsername.Size(),
   325 					m_username_password_io_ptr->iUsername.Size(),
   357 					false,
   326 					false,
   358 					false);
   327 					false);
   359 				if (status != eap_status_ok)
   328 				if (status != eap_status_ok)
   360 				{
   329 					{
   361 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   330 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   362 					(void) EAP_STATUS_RETURN(m_am_tools, status);
   331 					(void) EAP_STATUS_RETURN(m_am_tools, status);
   363 					return;
   332 					return;
   364 				}
   333 					}
   365 
   334 
   366 				eap_variable_data_c tmp_username_utf8(m_am_tools);
   335 				eap_variable_data_c tmp_username_utf8(m_am_tools);
   367 				status = m_am_tools->convert_unicode_to_utf8(tmp_username_utf8, tmp_username_unicode);
   336 				status = m_am_tools->convert_unicode_to_utf8(tmp_username_utf8, tmp_username_unicode);
   368 				if (status != eap_status_ok)
   337 				if (status != eap_status_ok)
   369 				{
   338 					{
   370 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   339 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   371 					(void) EAP_STATUS_RETURN(m_am_tools, status);
   340 					(void) EAP_STATUS_RETURN(m_am_tools, status);
   372 					return;
   341 					return;
   373 				}
   342 					}
   374 
   343 
   375 				status = m_username_utf8->set_copy_of_buffer(&tmp_username_utf8);
   344 				status = m_username_utf8->set_copy_of_buffer(&tmp_username_utf8);
   376 				if (status != eap_status_ok)
   345 				if (status != eap_status_ok)
   377 				{
   346 					{
   378 					get_am_partner()->finish_unsuccessful_authentication(false);
   347 					get_am_partner()->finish_unsuccessful_authentication(false);
   379 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   348 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   380 					(void) EAP_STATUS_RETURN(m_am_tools, status);
   349 					(void) EAP_STATUS_RETURN(m_am_tools, status);
   381 					return;
   350 					return;
       
   351 					}
   382 				}
   352 				}
   383 			}
   353 
   384 
   354 				{
   385 			{
       
   386 				eap_variable_data_c tmp_password_unicode(
   355 				eap_variable_data_c tmp_password_unicode(
   387 					m_am_tools);
   356 					m_am_tools);
   388 
   357 
   389 				status = tmp_password_unicode.set_buffer(
   358 				status = tmp_password_unicode.set_buffer(
   390 					m_username_password_io_ptr->iPassword.Ptr(),
   359 					m_username_password_io_ptr->iPassword.Ptr(),
   391 					m_username_password_io_ptr->iPassword.Size(),
   360 					m_username_password_io_ptr->iPassword.Size(),
   392 					false,
   361 					false,
   393 					false);
   362 					false);
   394 				if (status != eap_status_ok)
   363 				if (status != eap_status_ok)
   395 				{
   364 					{
   396 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   365 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   397 					(void) EAP_STATUS_RETURN(m_am_tools, status);
   366 					(void) EAP_STATUS_RETURN(m_am_tools, status);
   398 					return;
   367 					return;
   399 				}
   368 					}
   400 
   369 
   401 				eap_variable_data_c tmp_password_utf8(m_am_tools);
   370 				eap_variable_data_c tmp_password_utf8(m_am_tools);
   402 				status = m_am_tools->convert_unicode_to_utf8(tmp_password_utf8, tmp_password_unicode);
   371 				status = m_am_tools->convert_unicode_to_utf8(tmp_password_utf8, tmp_password_unicode);
   403 				if (status != eap_status_ok)
   372 				if (status != eap_status_ok)
   404 				{
   373 					{
   405 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   374 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   406 					(void) EAP_STATUS_RETURN(m_am_tools, status);
   375 					(void) EAP_STATUS_RETURN(m_am_tools, status);
   407 					return;
   376 					return;
   408 				}
   377 					}
   409 
   378 
   410 				status = m_password_utf8->set_copy_of_buffer(&tmp_password_utf8);
   379 				status = m_password_utf8->set_copy_of_buffer(&tmp_password_utf8);
   411 				if (status != eap_status_ok)
   380 				if (status != eap_status_ok)
   412 				{
   381 					{
   413 					get_am_partner()->finish_unsuccessful_authentication(false);
   382 					get_am_partner()->finish_unsuccessful_authentication(false);
   414 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   383 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   415 					(void) EAP_STATUS_RETURN(m_am_tools, status);
   384 					(void) EAP_STATUS_RETURN(m_am_tools, status);
   416 					return;
   385 					return;
       
   386 					}
   417 				}
   387 				}
   418 			}
       
   419 
   388 
   420 			// Store username and/or password if "Prompt for username" is enabled
   389 			// Store username and/or password if "Prompt for username" is enabled
   421 			status = update_username_password();
   390 			status = update_username_password();
   422 			if (status != eap_status_ok)
   391 			if (status != eap_status_ok)
   423 			{
   392 				{
   424 				get_am_partner()->finish_unsuccessful_authentication(false);
   393 				get_am_partner()->finish_unsuccessful_authentication(false);
   425 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   394 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   426 				return;
   395 				return;
       
   396 				}
       
   397 
       
   398 			if (m_is_identity_query)
       
   399 				{
       
   400 				status = get_am_partner()->complete_eap_identity_query();
       
   401 				}
       
   402 			else
       
   403 				{
       
   404 				status = get_am_partner()->complete_failure_retry_response();
       
   405 				}
   427 			}
   406 			}
   428 
       
   429 			if (m_is_identity_query)
       
   430 			{
       
   431 				status = get_am_partner()->complete_eap_identity_query();
       
   432 			}
       
   433 			else
       
   434 			{
       
   435 				status = get_am_partner()->complete_failure_retry_response();
       
   436 			}
       
   437 		}
       
   438 		break;
   407 		break;
   439 
   408 
   440 	case EHandlingChangePasswordQuery:
   409 	case EHandlingChangePasswordQuery:
   441 		{
   410 		{
   442 			{
   411 				{
   443 				eap_variable_data_c tmp_password_unicode(
   412 				eap_variable_data_c tmp_password_unicode(
   444 					m_am_tools);
   413 					m_am_tools);
   445 
   414 
   446 				status = tmp_password_unicode.set_buffer(
   415 				status = tmp_password_unicode.set_buffer(
   447 					m_username_password_io_ptr->iPassword.Ptr(),
   416 					m_username_password_io_ptr->iPassword.Ptr(),
   448 					m_username_password_io_ptr->iPassword.Size(),
   417 					m_username_password_io_ptr->iPassword.Size(),
   449 					false,
   418 					false,
   450 					false);
   419 					false);
   451 				if (status != eap_status_ok)
   420 				if (status != eap_status_ok)
   452 				{
   421 					{
   453 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   422 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   454 					(void) EAP_STATUS_RETURN(m_am_tools, status);
   423 					(void) EAP_STATUS_RETURN(m_am_tools, status);
   455 					return;
   424 					return;
   456 				}
   425 					}
   457 
   426 
   458 				eap_variable_data_c tmp_password_utf8(m_am_tools);
   427 				eap_variable_data_c tmp_password_utf8(m_am_tools);
   459 				status = m_am_tools->convert_unicode_to_utf8(tmp_password_utf8, tmp_password_unicode);
   428 				status = m_am_tools->convert_unicode_to_utf8(tmp_password_utf8, tmp_password_unicode);
   460 				if (status != eap_status_ok)
   429 				if (status != eap_status_ok)
   461 				{
   430 					{
   462 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   431 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   463 					(void) EAP_STATUS_RETURN(m_am_tools, status);
   432 					(void) EAP_STATUS_RETURN(m_am_tools, status);
   464 					return;
   433 					return;
   465 				}
   434 					}
   466 
   435 
   467 				eap_status_e status = m_password_utf8->set_copy_of_buffer(&tmp_password_utf8);
   436 				eap_status_e status = m_password_utf8->set_copy_of_buffer(&tmp_password_utf8);
   468 				if (status != eap_status_ok)
   437 				if (status != eap_status_ok)
   469 				{
   438 					{
   470 					get_am_partner()->finish_unsuccessful_authentication(false);
   439 					get_am_partner()->finish_unsuccessful_authentication(false);
   471 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   440 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   472 					return;
   441 					return;
       
   442 					}
   473 				}
   443 				}
   474 			}
   444 
   475 
   445 				{
   476 			{
       
   477 				eap_variable_data_c tmp_old_password_unicode(
   446 				eap_variable_data_c tmp_old_password_unicode(
   478 					m_am_tools);
   447 					m_am_tools);
   479 
   448 
   480 				status = tmp_old_password_unicode.set_buffer(
   449 				status = tmp_old_password_unicode.set_buffer(
   481 					m_username_password_io_ptr->iOldPassword.Ptr(),
   450 					m_username_password_io_ptr->iOldPassword.Ptr(),
   482 					m_username_password_io_ptr->iOldPassword.Size(),
   451 					m_username_password_io_ptr->iOldPassword.Size(),
   483 					false,
   452 					false,
   484 					false);
   453 					false);
   485 				if (status != eap_status_ok)
   454 				if (status != eap_status_ok)
   486 				{
   455 					{
   487 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   456 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   488 					(void) EAP_STATUS_RETURN(m_am_tools, status);
   457 					(void) EAP_STATUS_RETURN(m_am_tools, status);
   489 					return;
   458 					return;
   490 				}
   459 					}
   491 
   460 
   492 				eap_variable_data_c tmp_old_password_utf8(m_am_tools);
   461 				eap_variable_data_c tmp_old_password_utf8(m_am_tools);
   493 				status = m_am_tools->convert_unicode_to_utf8(tmp_old_password_utf8, tmp_old_password_unicode);
   462 				status = m_am_tools->convert_unicode_to_utf8(tmp_old_password_utf8, tmp_old_password_unicode);
   494 				if (status != eap_status_ok)
   463 				if (status != eap_status_ok)
   495 				{
   464 					{
   496 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   465 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   497 					(void) EAP_STATUS_RETURN(m_am_tools, status);
   466 					(void) EAP_STATUS_RETURN(m_am_tools, status);
   498 					return;
   467 					return;
   499 				}
   468 					}
   500 
   469 
   501 				status = m_old_password_utf8->set_copy_of_buffer(&tmp_old_password_utf8);
   470 				status = m_old_password_utf8->set_copy_of_buffer(&tmp_old_password_utf8);
   502 				if (status != eap_status_ok)
   471 				if (status != eap_status_ok)
   503 				{
   472 					{
   504 					get_am_partner()->finish_unsuccessful_authentication(false);
   473 					get_am_partner()->finish_unsuccessful_authentication(false);
   505 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   474 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   506 					return;
   475 					return;
       
   476 					}
   507 				}
   477 				}
       
   478 
       
   479 			status = get_am_partner()->complete_change_password_query();
   508 			}
   480 			}
   509 
       
   510 			status = get_am_partner()->complete_change_password_query();
       
   511 		}
       
   512 		break;
   481 		break;
   513 
   482 
   514 	default:
   483 	default:
   515 		EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: EAP - MS-Chap-V2 illegal state in RunL.\n")));
   484 		EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: EAP - MS-Chap-V2 illegal state in RunL.\n")));
   516 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   485 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   517 		return;		
   486 		return;		
   518 	}
   487 
       
   488 		}
       
   489 	}
       
   490 
       
   491 //--------------------------------------------------
       
   492 
       
   493 void eap_am_type_mschapv2_symbian_c::RunL()
       
   494 {
       
   495 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   496 	
       
   497 	EAP_TRACE_DEBUG(
       
   498 		m_am_tools,
       
   499 		TRACE_FLAGS_DEFAULT,
       
   500 		(EAPL("eap_am_type_mschapv2_symbian_c::RunL - start")
       
   501 		 EAPL("m_state, iStatus.Int()=%d\n"),
       
   502 		 m_state, iStatus.Int()));
       
   503 
   519 
   504 
   520 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   505 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   521 }
   506 }
   522 
   507 
   523 //--------------------------------------------------
   508 //--------------------------------------------------
   524 
   509 
   525 void eap_am_type_mschapv2_symbian_c::DoCancel()
   510 void eap_am_type_mschapv2_symbian_c::DoCancel()
   526 {
   511 {
   527 	if( m_is_notifier_connected )
   512 	if (iEapAuthNotifier != 0)
   528 	{
   513 		{
   529 	EAP_TRACE_DEBUG(
   514 		iEapAuthNotifier->Cancel();
   530 		m_am_tools, 
   515 		}
   531 		TRACE_FLAGS_DEFAULT, 
   516 
   532 		(EAPL("eap_am_type_mschapv2_symbian_c::DoCancel - calling m_notifier.CancelNotifier(..)\n")));
   517 
   533 			
   518 	}
   534 		TInt error = KErrNone;
       
   535 		EAP_UNREFERENCED_PARAMETER(error);
       
   536 		error = m_notifier.CancelNotifier(KEapMsChapV2UsernamePasswordUid);
       
   537 
       
   538 	EAP_TRACE_DEBUG(
       
   539 		m_am_tools, 
       
   540 		TRACE_FLAGS_DEFAULT, 
       
   541 		(EAPL("eap_am_type_mschapv2_symbian_c::DoCancel - calling m_notifier.Close(), prev error=%d\n"),
       
   542 		error));
       
   543 		
       
   544 		m_notifier.Close(); // Call close only if it is connected.	
       
   545 		
       
   546 		m_is_notifier_connected = false;
       
   547 	}
       
   548 }
       
   549 
   519 
   550 //--------------------------------------------------
   520 //--------------------------------------------------
   551 
   521 
   552 
   522 
   553 EAP_FUNC_EXPORT eap_status_e eap_am_type_mschapv2_symbian_c::type_configure_read(
   523 EAP_FUNC_EXPORT eap_status_e eap_am_type_mschapv2_symbian_c::type_configure_read(
   602 			
   572 			
   603 	// Now do the database query
   573 	// Now do the database query
   604 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
   574 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
   605 	TPtr sqlStatement = buf->Des();
   575 	TPtr sqlStatement = buf->Des();
   606 
   576 
   607 	_LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
   577 	_LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
   608 	sqlStatement.Format(KSQLQueryRow,
   578 	sqlStatement.Format(
   609 						&unicodeString,
   579 		KSQLQueryRow,
   610 						&KMsChapV2TableName,
   580 		&unicodeString,
   611 						&KServiceType,
   581 		&KMsChapV2TableName,
   612 						m_index_type,
   582 		&KServiceType,
   613 						&KServiceIndex,
   583 		m_index_type,
   614 						m_index,
   584 		&KServiceIndex,
   615 						&KTunnelingType, 
   585 		m_index,
   616 						m_tunneling_vendor_type);
   586 		&KTunnelingTypeVendorId,
       
   587 		m_tunneling_type.get_vendor_id(),
       
   588 		&KTunnelingType, 
       
   589 		m_tunneling_type.get_vendor_type());
   617 	
   590 	
   618 	RDbView view;
   591 	RDbView view;
   619 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
   592 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
   620 	CleanupClosePushL(view);
   593 	CleanupClosePushL(view);
   621 	User::LeaveIfError(view.EvaluateAll());	
   594 	User::LeaveIfError(view.EvaluateAll());	
   748 
   721 
   749 	// Now do the database update
   722 	// Now do the database update
   750 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
   723 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
   751 	TPtr sqlStatement = buf->Des();
   724 	TPtr sqlStatement = buf->Des();
   752 
   725 
   753 	_LIT(KSQLUpdate, "SELECT %S,%S,%S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
   726 	_LIT(KSQLUpdate, "SELECT %S,%S,%S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
   754 	sqlStatement.Format(KSQLUpdate,
   727 	sqlStatement.Format(
   755 						&cf_str_EAP_MSCHAPV2_username_literal,
   728 		KSQLUpdate,
   756 						&cf_str_EAP_MSCHAPV2_password_prompt_literal,
   729 		&cf_str_EAP_MSCHAPV2_username_literal,
   757 						&cf_str_EAP_MSCHAPV2_password_literal,
   730 		&cf_str_EAP_MSCHAPV2_password_prompt_literal,
   758 						&KMsChapV2TableName,
   731 		&cf_str_EAP_MSCHAPV2_password_literal,
   759 						&KServiceType,
   732 		&KMsChapV2TableName,
   760 						m_index_type,
   733 		&KServiceType,
   761 						&KServiceIndex,
   734 		m_index_type,
   762 						m_index,
   735 		&KServiceIndex,
   763 						&KTunnelingType, 
   736 		m_index,
   764 						m_tunneling_vendor_type);
   737 		&KTunnelingTypeVendorId,
       
   738 		m_tunneling_type.get_vendor_id(),
       
   739 		&KTunnelingType, 
       
   740 		m_tunneling_type.get_vendor_type());
   765 	
   741 	
   766 	RDbView view;
   742 	RDbView view;
   767 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), RDbView::EUpdatable));
   743 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), RDbView::EUpdatable));
   768 	CleanupClosePushL(view);
   744 	CleanupClosePushL(view);
   769 
   745 
   819 	}
   795 	}
   820 
   796 
   821 	if (*m_password_prompt_enabled)
   797 	if (*m_password_prompt_enabled)
   822 	{
   798 	{
   823 		// Username and password prompt flag is stored, password is cleared
   799 		// Username and password prompt flag is stored, password is cleared
   824 		view.SetColL(colSet->ColNo(cf_str_EAP_MSCHAPV2_password_prompt_literal), EMSCHAPV2PasswordPromptOn);
   800 		view.SetColL(colSet->ColNo(cf_str_EAP_MSCHAPV2_password_prompt_literal), EEapDbTrue);
   825 		view.SetColNullL(colSet->ColNo(cf_str_EAP_MSCHAPV2_password_literal));
   801 		view.SetColNullL(colSet->ColNo(cf_str_EAP_MSCHAPV2_password_literal));
   826 	}
   802 	}
   827 	else
   803 	else
   828 	{
   804 	{
   829 		eap_variable_data_c tmp_password_unicode(m_am_tools);
   805 		eap_variable_data_c tmp_password_unicode(m_am_tools);
   851 			password.Length()));
   827 			password.Length()));
   852 			
   828 			
   853 			User::Leave(KErrArgument);
   829 			User::Leave(KErrArgument);
   854 		}
   830 		}
   855 
   831 
   856 		view.SetColL(colSet->ColNo(cf_str_EAP_MSCHAPV2_password_prompt_literal), EMSCHAPV2PasswordPromptOff);
   832 		view.SetColL(colSet->ColNo(cf_str_EAP_MSCHAPV2_password_prompt_literal), EEapDbFalse);
   857 
   833 
   858 		// Length is ok. Set the value in DB.			
   834 		// Length is ok. Set the value in DB.			
   859 		view.SetColL(colSet->ColNo(cf_str_EAP_MSCHAPV2_password_literal), password);
   835 		view.SetColL(colSet->ColNo(cf_str_EAP_MSCHAPV2_password_literal), password);
   860 	}
   836 	}
   861 
   837 
   926 	m_username_utf8 = &username_utf8;
   902 	m_username_utf8 = &username_utf8;
   927 	m_password_utf8 = &password_utf8;
   903 	m_password_utf8 = &password_utf8;
   928 	m_password_prompt_enabled = &password_prompt_enabled;
   904 	m_password_prompt_enabled = &password_prompt_enabled;
   929 	m_is_identity_query = is_identity_query;
   905 	m_is_identity_query = is_identity_query;
   930 
   906 
   931 	if (!IsActive())
       
   932 	{
       
   933 		if (*m_password_prompt_enabled == true)
   907 		if (*m_password_prompt_enabled == true)
   934 		{
   908 			{
   935 			m_username_password_io_ptr->iPasswordPromptEnabled = ETrue; 
   909 			m_username_password_io_ptr->iPasswordPromptEnabled = ETrue; 
   936 		}
   910 			}
   937 		else
   911 		else
   938 		{
   912 			{
   939 			m_username_password_io_ptr->iPasswordPromptEnabled = EFalse; 
   913 			m_username_password_io_ptr->iPasswordPromptEnabled = EFalse; 
   940 		}
   914 			}
   941 
   915 
   942 		if (m_is_identity_query == true)
   916 		if (m_is_identity_query == true)
   943 		{
   917 			{
   944 			m_username_password_io_ptr->iIsIdentityQuery = ETrue; 
   918 			m_username_password_io_ptr->iIsIdentityQuery = ETrue; 
   945 		}
   919 			}
   946 		else
   920 		else
   947 		{
   921 			{
   948 			m_username_password_io_ptr->iIsIdentityQuery = EFalse; 
   922 			m_username_password_io_ptr->iIsIdentityQuery = EFalse; 
   949 		}
   923 			}
   950 
   924 
   951 
   925 
   952 		{
   926 		eap_variable_data_c tmp_username_unicode(m_am_tools);
   953 			eap_variable_data_c tmp_username_unicode(m_am_tools);
   927 		eap_status_e status = m_am_tools->convert_utf8_to_unicode(tmp_username_unicode, *m_username_utf8);
   954 			eap_status_e status = m_am_tools->convert_utf8_to_unicode(tmp_username_unicode, *m_username_utf8);
   928 		if (status != eap_status_ok)
   955 			if (status != eap_status_ok)
       
   956 			{
   929 			{
   957 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   930 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   958 				return EAP_STATUS_RETURN(m_am_tools, status);
   931 			return EAP_STATUS_RETURN(m_am_tools, status);
   959 			}
   932 			}
   960 
   933 
   961 			m_username_password_io_ptr->iUsername.Copy(
   934 		m_username_password_io_ptr->iUsername.Copy(
   962 				reinterpret_cast<TUint16 *> (
   935 			reinterpret_cast<TUint16 *> (
   963 					tmp_username_unicode.get_data(tmp_username_unicode.get_data_length())),
   936 				tmp_username_unicode.get_data(tmp_username_unicode.get_data_length())),
   964 					tmp_username_unicode.get_data_length() / 2); // 8bit -> 16bit
   937 				tmp_username_unicode.get_data_length() / 2); // 8bit -> 16bit
   965 		}
       
   966 
   938 
   967 
   939 
   968 		m_state = EHandlingUsernamePasswordQuery;
   940 		m_state = EHandlingUsernamePasswordQuery;
   969 		
       
   970 	EAP_TRACE_DEBUG(
       
   971 		m_am_tools, 
       
   972 		TRACE_FLAGS_DEFAULT, 
       
   973 		(EAPL(" eap_am_type_mschapv2_symbian_c::show_username_password_dialog - before m_notifier.Connect(), m_is_notifier_connected=%d\n"),
       
   974 		m_is_notifier_connected));
       
   975 		
       
   976 		if( !m_is_notifier_connected )
       
   977 		{
       
   978 			TInt error = m_notifier.Connect();
       
   979 
       
   980 	EAP_TRACE_DEBUG(
       
   981 		m_am_tools, 
       
   982 		TRACE_FLAGS_DEFAULT, 
       
   983 		(EAPL(" eap_am_type_mschapv2_symbian_c::show_username_password_dialog - m_notifier.Connect() returned error=%d\n"),
       
   984 		error));
       
   985 			
       
   986 			if( error != KErrNone)
       
   987 			{
       
   988 				// Can not connect to notifier.
       
   989 				return EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(error));		
       
   990 			}
       
   991 			
       
   992 			m_is_notifier_connected = true; // Got connectted to notifier.
       
   993 		}
       
   994 
   941 
   995 	EAP_TRACE_DEBUG(
   942 	EAP_TRACE_DEBUG(
   996 		m_am_tools, 
   943 		m_am_tools, 
   997 		TRACE_FLAGS_DEFAULT, 
   944 		TRACE_FLAGS_DEFAULT, 
   998 		(EAPL(" eap_am_type_mschapv2_symbian_c::show_username_password_dialog - before m_notifier.StartNotifierAndGetResponse()\n")));		
   945 		(EAPL(" eap_am_type_mschapv2_symbian_c::show_username_password_dialog - before m_notifier.StartNotifierAndGetResponse()\n")));		
   999 
   946 
  1000 		m_notifier.StartNotifierAndGetResponse(
   947 	    TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  1001 			iStatus, 
   948 	    
  1002 			KEapMsChapV2UsernamePasswordUid, 
   949 	    m_username_password_io_ptr->iPassword.Zero();
  1003 			*m_username_password_io_pckg_ptr, 
   950 	    
  1004 			*m_username_password_io_pckg_ptr);
   951 	    if (iEapAuthNotifier == 0)
  1005 
   952 	    	{
  1006 		SetActive();
   953 	    	TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
  1007 	} 
   954 	  		if (err)
  1008 	else
   955 	  			{
  1009 	{
   956 	  				return eap_status_authentication_failure;
  1010 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_mschapv2_symbian_c: Already active when tried to show username/password dialog.\n")));
   957 	  			}
  1011 		return eap_status_process_general_error;
   958 	    	}
  1012 	}
   959 	    else
       
   960 		   	{
       
   961 			 	iEapAuthNotifier->Cancel();
       
   962 	     	}
       
   963 	
       
   964 	    TRAPD(err1, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeMsChapV2UsernamePasswordDialog, m_username_password_io_ptr, aEapType));
       
   965   		if (err1)
       
   966   			{
       
   967   				return eap_status_authentication_failure;
       
   968   			}
       
   969 	    	
       
   970 
  1013 
   971 
  1014 	return eap_status_pending_request;
   972 	return eap_status_pending_request;
  1015 }
   973 }
  1016 
   974 
  1017 //--------------------------------------------------
   975 //--------------------------------------------------
  1042 	m_username_utf8 = &username;
  1000 	m_username_utf8 = &username;
  1043 	m_password_utf8 = &password;
  1001 	m_password_utf8 = &password;
  1044 	m_old_password_utf8 = &old_password;
  1002 	m_old_password_utf8 = &old_password;
  1045 	m_password_prompt_enabled = &password_prompt_enabled;
  1003 	m_password_prompt_enabled = &password_prompt_enabled;
  1046 
  1004 
  1047 	if (!IsActive())
  1005 
  1048 	{
  1006 
  1049 		{
       
  1050 			eap_variable_data_c tmp_username_unicode(m_am_tools);
       
  1051 			eap_status_e status = m_am_tools->convert_utf8_to_unicode(tmp_username_unicode, *m_username_utf8);
       
  1052 			if (status != eap_status_ok)
       
  1053 			{
       
  1054 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1055 				return EAP_STATUS_RETURN(m_am_tools, status);
       
  1056 			}
       
  1057 
       
  1058 			m_username_password_io_ptr->iUsername.Copy(
       
  1059 				reinterpret_cast<TUint16 *> (
       
  1060 					tmp_username_unicode.get_data(tmp_username_unicode.get_data_length())),
       
  1061 					tmp_username_unicode.get_data_length() / 2); // 8bit -> 16bit
       
  1062 		}
       
  1063 
       
  1064 		m_state = EHandlingChangePasswordQuery;
       
  1065 		
       
  1066 	EAP_TRACE_DEBUG(
       
  1067 		m_am_tools, 
       
  1068 		TRACE_FLAGS_DEFAULT, 
       
  1069 		(EAPL(" eap_am_type_mschapv2_symbian_c::show_change_password_dialog - before m_notifier.Connect(), m_is_notifier_connected=%d\n"),
       
  1070 		m_is_notifier_connected));
       
  1071 		
       
  1072 		if( !m_is_notifier_connected )
       
  1073 		{
       
  1074 			TInt error = m_notifier.Connect();
       
  1075 
       
  1076 	EAP_TRACE_DEBUG(
       
  1077 		m_am_tools, 
       
  1078 		TRACE_FLAGS_DEFAULT, 
       
  1079 		(EAPL(" eap_am_type_mschapv2_symbian_c::show_change_password_dialog - m_notifier.Connect() returned error=%d\n"),
       
  1080 		error));
       
  1081 			
       
  1082 			if( error != KErrNone)
       
  1083 			{
       
  1084 				// Can not connect to notifier.
       
  1085 				return EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(error));		
       
  1086 			}
       
  1087 			
       
  1088 			m_is_notifier_connected = true; // Got connectted to notifier.
       
  1089 		}
       
  1090 
       
  1091 	EAP_TRACE_DEBUG(
       
  1092 		m_am_tools, 
       
  1093 		TRACE_FLAGS_DEFAULT, 
       
  1094 		(EAPL(" eap_am_type_mschapv2_symbian_c::show_change_password_dialog - before m_notifier.StartNotifierAndGetResponse()\n")));	
       
  1095 
       
  1096 		m_notifier.StartNotifierAndGetResponse(
       
  1097 			iStatus, 
       
  1098 			KEapMsChapV2ChangePasswordUid, 
       
  1099 			*m_username_password_io_pckg_ptr, 
       
  1100 			*m_username_password_io_pckg_ptr);
       
  1101 
       
  1102 		SetActive();
       
  1103 	} 
       
  1104 	else
       
  1105 	{
       
  1106 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_mschapv2_symbian_c: Already active when tried to show change password dialog.\n")));
       
  1107 		return eap_status_process_general_error;
       
  1108 	}
       
  1109 
  1007 
  1110 	return eap_status_pending_request;
  1008 	return eap_status_pending_request;
  1111 	
  1009 	
  1112 #endif	
  1010 #endif	
  1113 }
  1011 }
  1177 	{
  1075 	{
  1178 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1076 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1179 		return EAP_STATUS_RETURN(m_am_tools, status);
  1077 		return EAP_STATUS_RETURN(m_am_tools, status);
  1180 	}
  1078 	}
  1181 
  1079 
  1182 	status = memory_store_key->add_data(
  1080 	{
  1183 		&m_tunneling_vendor_type,
  1081 		u32_t vendor_id = m_tunneling_type.get_vendor_id();
  1184 		sizeof(m_tunneling_vendor_type));
  1082 
  1185 	if (status != eap_status_ok)
  1083 		status = memory_store_key->add_data(
  1186 	{
  1084 			&vendor_id,
  1187 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1085 			sizeof(vendor_id));
  1188 		return EAP_STATUS_RETURN(m_am_tools, status);
  1086 		if (status != eap_status_ok)
       
  1087 		{
       
  1088 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1089 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1090 		}
       
  1091 	}
       
  1092 
       
  1093 	{
       
  1094 		u32_t vendor_type = m_tunneling_type.get_vendor_type();
       
  1095 		status = memory_store_key->add_data(
       
  1096 			&vendor_type,
       
  1097 			sizeof(vendor_type));
       
  1098 		if (status != eap_status_ok)
       
  1099 		{
       
  1100 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1101 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1102 		}
  1189 	}
  1103 	}
  1190 
  1104 
  1191 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1105 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1192 	return EAP_STATUS_RETURN(m_am_tools, status);
  1106 	return EAP_STATUS_RETURN(m_am_tools, status);
  1193 }
  1107 }
  1226 
  1140 
  1227 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  1141 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  1228 	TPtr sqlStatement = buf->Des();
  1142 	TPtr sqlStatement = buf->Des();
  1229 	
  1143 	
  1230 	// Query all the relevant parameters
  1144 	// Query all the relevant parameters
  1231 	_LIT(KSQLQuery, "SELECT %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
  1145 	_LIT(KSQLQuery, "SELECT %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
  1232 	sqlStatement.Format(KSQLQuery, &cf_str_EAP_MSCHAPv2_max_session_validity_time_literal,
  1146 	sqlStatement.Format(
  1233 						&KMSCHAPv2LastFullAuthTime, &KMsChapV2TableName,
  1147 		KSQLQuery,
  1234 						&KServiceType, m_index_type, 
  1148 		&cf_str_EAP_MSCHAPv2_max_session_validity_time_literal,
  1235 						&KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  1149 		&KMSCHAPv2LastFullAuthTime,
       
  1150 		&KMsChapV2TableName,
       
  1151 		&KServiceType,
       
  1152 		m_index_type, 
       
  1153 		&KServiceIndex,
       
  1154 		m_index,
       
  1155 		&KTunnelingTypeVendorId,
       
  1156 		m_tunneling_type.get_vendor_id(),
       
  1157 		&KTunnelingType, 
       
  1158 		m_tunneling_type.get_vendor_type());
  1236 
  1159 
  1237 	RDbView view;
  1160 	RDbView view;
  1238 	// Evaluate view
  1161 	// Evaluate view
  1239 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement)));
  1162 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement)));
  1240 	CleanupClosePushL(view);
  1163 	CleanupClosePushL(view);
  1367 
  1290 
  1368 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  1291 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  1369 	TPtr sqlStatement = buf->Des();
  1292 	TPtr sqlStatement = buf->Des();
  1370 	
  1293 	
  1371 	// Query all the relevant parameters
  1294 	// Query all the relevant parameters
  1372 	_LIT(KSQLQuery, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
  1295 	_LIT(KSQLQuery, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
  1373 	sqlStatement.Format(KSQLQuery, &KMSCHAPv2LastFullAuthTime, &KMsChapV2TableName,
  1296 	sqlStatement.Format(
  1374 						&KServiceType, m_index_type, 
  1297 		KSQLQuery,
  1375 						&KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  1298 		&KMSCHAPv2LastFullAuthTime,
       
  1299 		&KMsChapV2TableName,
       
  1300 		&KServiceType,
       
  1301 		m_index_type, 
       
  1302 		&KServiceIndex,
       
  1303 		m_index,
       
  1304 		&KTunnelingTypeVendorId,
       
  1305 		m_tunneling_type.get_vendor_id(),
       
  1306 		&KTunnelingType, 
       
  1307 		m_tunneling_type.get_vendor_type());
  1376 
  1308 
  1377 	RDbView view;
  1309 	RDbView view;
  1378 	// Evaluate view
  1310 	// Evaluate view
  1379 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  1311 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  1380 	CleanupClosePushL(view);
  1312 	CleanupClosePushL(view);