eapol/eapol_framework/eapol_symbian/am/type/aka/symbian/plugin/src/EapAka.cpp
changeset 0 c8830336c852
child 2 1c7bc153c08e
equal deleted inserted replaced
-1:000000000000 0:c8830336c852
       
     1 /*
       
     2 * Copyright (c) 2001-2006 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 and WLAN authentication protocols.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // This is enumeration of EAPOL source code.
       
    20 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    21 	#undef EAP_FILE_NUMBER_ENUM
       
    22 	#define EAP_FILE_NUMBER_ENUM 605 
       
    23 	#undef EAP_FILE_NUMBER_DATE 
       
    24 	#define EAP_FILE_NUMBER_DATE 1127594498 
       
    25 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    26 
       
    27 
       
    28 // INCLUDE FILES
       
    29 
       
    30 #include "EapAka.h"
       
    31 #include "eap_base_type.h"
       
    32 #include "eap_type_aka.h"
       
    33 #include "EapAkaGlobal.h"
       
    34 #include <EapTypeInfo.h>
       
    35 #include "eap_am_type_aka_symbian.h"
       
    36 #include "EapAkaDbUtils.h"
       
    37 
       
    38 #include <EapAkaUiConnection.h>
       
    39 #include "EapAkaUi.h"
       
    40 
       
    41 
       
    42 #include "eap_am_tools_symbian.h"
       
    43 
       
    44 // LOCAL CONSTANTS
       
    45 
       
    46 // The version number of this interface.
       
    47 const TUint KInterfaceVersion = 1;
       
    48 
       
    49 
       
    50 // ================= MEMBER FUNCTIONS =======================
       
    51 
       
    52 
       
    53 CEapAka::CEapAka(const TIndexType aIndexType,	
       
    54 				 const TInt aIndex)
       
    55 : iIndexType(aIndexType)
       
    56 , iIndex(aIndex)
       
    57 , iTunnelingType(eap_type_none)
       
    58 {
       
    59 }
       
    60 
       
    61 // ----------------------------------------------------------
       
    62 
       
    63 CEapAka* CEapAka::NewL(SIapInfo *aIapInfo)
       
    64 {
       
    65 	return new (ELeave) CEapAka(aIapInfo->indexType, aIapInfo->index);
       
    66 }
       
    67 
       
    68 // ----------------------------------------------------------
       
    69 
       
    70 CEapAka::~CEapAka()
       
    71 {
       
    72 }
       
    73 
       
    74 // ----------------------------------------------------------
       
    75 
       
    76 #ifdef USE_EAP_SIMPLE_CONFIG
       
    77 
       
    78 eap_base_type_c* CEapAka::GetStackInterfaceL(abs_eap_am_tools_c* const aTools, 
       
    79 											   abs_eap_base_type_c* const aPartner,
       
    80 											   const bool is_client_when_true,
       
    81 											   const eap_am_network_id_c * const receive_network_id,
       
    82 											   abs_eap_configuration_if_c * const /*configuration_if*/)
       
    83 	
       
    84 #else
       
    85 	
       
    86 eap_base_type_c* CEapAka::GetStackInterfaceL(abs_eap_am_tools_c* const aTools, 
       
    87 											abs_eap_base_type_c* const aPartner,
       
    88 											const bool is_client_when_true,
       
    89 											const eap_am_network_id_c * const receive_network_id)
       
    90 	
       
    91 #endif // #ifdef USE_EAP_SIMPLE_CONFIG
       
    92 {
       
    93 	// Create AM
       
    94 	eap_am_type_aka_symbian_c* amEapType = eap_am_type_aka_symbian_c::NewL(
       
    95 		aTools, 
       
    96 		aPartner, 
       
    97 		iIndexType, 
       
    98 		iIndex, 
       
    99 		iTunnelingType,
       
   100 		is_client_when_true,
       
   101 		receive_network_id);
       
   102 
       
   103 	if (amEapType->get_is_valid() == false)
       
   104 	{
       
   105 		amEapType->shutdown();
       
   106 		delete amEapType;
       
   107 		User::Leave(KErrGeneral);
       
   108 	}	
       
   109 	
       
   110 	eap_base_type_c* type = 0;
       
   111 
       
   112 	type = new eap_type_aka_c(
       
   113 		aTools, 
       
   114 		aPartner, 
       
   115 		amEapType, 
       
   116 		true /* free_am */, 
       
   117 		is_client_when_true,
       
   118 		receive_network_id);
       
   119 	
       
   120 	if (type == 0)
       
   121 	{
       
   122 		// Out of memory
       
   123 		amEapType->shutdown();
       
   124 		delete amEapType;
       
   125 		User::Leave(KErrNoMemory);
       
   126 	}
       
   127 	else if (type->get_is_valid() == false) 
       
   128 	{		
       
   129 		type->shutdown();
       
   130 		// amEapType is freed by eap_type_aka_c
       
   131 		delete type;		
       
   132 		User::Leave(KErrGeneral);
       
   133 	}
       
   134 	return type;
       
   135 }
       
   136 
       
   137 // ----------------------------------------------------------
       
   138 TInt CEapAka::InvokeUiL()
       
   139 {
       
   140 	TInt buttonId(0);
       
   141  
       
   142 #ifdef USE_EAP_EXPANDED_TYPES
       
   143 
       
   144     CEapAkaUiConnection uiConn(iIndexType, iIndex, iTunnelingType.get_vendor_type());
       
   145 	
       
   146 #else
       
   147 
       
   148     CEapAkaUiConnection uiConn(iIndexType, iIndex, iTunnelingType);
       
   149 
       
   150 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
   151  
       
   152 	CEapAkaUi* ui = CEapAkaUi::NewL(&uiConn);
       
   153 	CleanupStack::PushL(ui);
       
   154 	buttonId = ui->InvokeUiL();
       
   155 	CleanupStack::PopAndDestroy(ui);
       
   156 	return buttonId;
       
   157 }
       
   158 
       
   159 // ----------------------------------------------------------
       
   160 CEapTypeInfo* CEapAka::GetInfoLC()
       
   161 {
       
   162 	CEapTypeInfo* info = new(ELeave) CEapTypeInfo(
       
   163 		(TDesC&)KReleaseDate, 
       
   164 		(TDesC&)KEapTypeVersion,
       
   165 		(TDesC&)KManufacturer);
       
   166 
       
   167 	CleanupStack::PushL(info);
       
   168 	return info;
       
   169 }
       
   170 
       
   171 // ----------------------------------------------------------
       
   172 void CEapAka::DeleteConfigurationL()
       
   173 {		
       
   174 	EapAkaDbUtils::DeleteConfigurationL(iIndexType, iIndex, iTunnelingType);
       
   175 }
       
   176 
       
   177 // ----------------------------------------------------------
       
   178 
       
   179 TUint CEapAka::GetInterfaceVersion()
       
   180 {
       
   181 	return KInterfaceVersion;
       
   182 }
       
   183 
       
   184 // ----------------------------------------------------------
       
   185 
       
   186 void CEapAka::SetTunnelingType(const TInt aTunnelingType)
       
   187 {
       
   188 #ifdef USE_EAP_EXPANDED_TYPES
       
   189 
       
   190 	// Vendor id is eap_type_vendor_id_ietf always in this plugin.
       
   191 	iTunnelingType.set_eap_type_values(eap_type_vendor_id_ietf, aTunnelingType);
       
   192 
       
   193 #else
       
   194 
       
   195 	iTunnelingType = static_cast<eap_type_value_e>(aTunnelingType);
       
   196 
       
   197 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
   198 }
       
   199 
       
   200 
       
   201 // ----------------------------------------------------------
       
   202 void CEapAka::SetIndexL(
       
   203 		const TIndexType aIndexType, 
       
   204 		const TInt aIndex )
       
   205 {		
       
   206 	// First delete the target configuration
       
   207 	TIndexType tmpIndexType = iIndexType;
       
   208 	TInt tmpIndex = iIndex;
       
   209 		
       
   210 	iIndexType = aIndexType;
       
   211 	iIndex = aIndex;
       
   212 	
       
   213 	TInt err(KErrNone);
       
   214 	TRAP(err, DeleteConfigurationL());
       
   215 	// Ignore error on purpose
       
   216 	
       
   217 	// Return the indices
       
   218 	iIndexType = tmpIndexType;
       
   219 	iIndex = tmpIndex;
       
   220 
       
   221 	RDbNamedDatabase db;
       
   222 
       
   223 	RDbs session;
       
   224 	
       
   225 	EapAkaDbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
       
   226 	
       
   227 	CleanupClosePushL(session);
       
   228 	CleanupClosePushL(db);
       
   229 		
       
   230 	EapAkaDbUtils::SetIndexL(
       
   231 		db, 
       
   232 		iIndexType, 
       
   233 		iIndex, 
       
   234 		iTunnelingType, 
       
   235 		aIndexType, 
       
   236 		aIndex, 
       
   237 		iTunnelingType);
       
   238 	
       
   239 	iIndexType = aIndexType;
       
   240 	iIndex = aIndex;
       
   241 
       
   242 	CleanupStack::PopAndDestroy(2); // db	
       
   243 }
       
   244 
       
   245 // ----------------------------------------------------------
       
   246 
       
   247 void CEapAka::SetConfigurationL(const EAPSettings& aSettings)
       
   248 {
       
   249 	RDbNamedDatabase db;
       
   250 
       
   251 	RDbs session;	
       
   252 	
       
   253 	// This also creates the IAP entry if it doesn't exist
       
   254 	EapAkaDbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
       
   255 	
       
   256 	CleanupClosePushL(session);
       
   257 	CleanupClosePushL(db);
       
   258 
       
   259 	EapAkaDbUtils::SetConfigurationL(
       
   260 		db,
       
   261 		aSettings, 
       
   262 		iIndexType,
       
   263 		iIndex,
       
   264 		iTunnelingType);		
       
   265 		
       
   266 	CleanupStack::PopAndDestroy(2); // db, session
       
   267 }
       
   268 
       
   269 // ----------------------------------------------------------
       
   270 
       
   271 void CEapAka::GetConfigurationL(EAPSettings& aSettings)
       
   272 {
       
   273 	RDbNamedDatabase db;
       
   274 
       
   275 	RDbs session;
       
   276 	
       
   277 	// This also creates the IAP entry if it doesn't exist
       
   278 	EapAkaDbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
       
   279 	
       
   280 	CleanupClosePushL(session);
       
   281 	CleanupClosePushL(db);
       
   282 
       
   283 	EapAkaDbUtils::GetConfigurationL(
       
   284 		db,
       
   285 		aSettings, 
       
   286 		iIndexType,
       
   287 		iIndex,
       
   288 		iTunnelingType);
       
   289 		
       
   290 	CleanupStack::PopAndDestroy(2); // db, session
       
   291 }
       
   292 
       
   293 // ----------------------------------------------------------
       
   294 
       
   295 void CEapAka::CopySettingsL(
       
   296 	const TIndexType aDestinationIndexType,
       
   297 	const TInt aDestinationIndex)
       
   298 {
       
   299 	// First delete the target configuration
       
   300 	TIndexType tmpIndexType = iIndexType;
       
   301 	TInt tmpIndex = iIndex;
       
   302 		
       
   303 	iIndexType = aDestinationIndexType;
       
   304 	iIndex = aDestinationIndex;
       
   305 
       
   306 	TInt err(KErrNone)	;
       
   307 	TRAP(err, DeleteConfigurationL());
       
   308 	// Ignore error on purpose
       
   309 	
       
   310 	// Return the indices
       
   311 	iIndexType = tmpIndexType;
       
   312 	iIndex = tmpIndex;
       
   313 
       
   314 	RDbNamedDatabase db;
       
   315 
       
   316 	RDbs session;
       
   317 	
       
   318 	EapAkaDbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
       
   319 	
       
   320 	CleanupClosePushL(session);
       
   321 	CleanupClosePushL(db);
       
   322 		
       
   323 	EapAkaDbUtils::CopySettingsL(
       
   324 		db,
       
   325 		iIndexType,
       
   326 		iIndex,
       
   327 		iTunnelingType, 
       
   328 		aDestinationIndexType, 
       
   329 		aDestinationIndex, 
       
   330 		iTunnelingType);
       
   331 		
       
   332 	CleanupStack::PopAndDestroy(2); // db
       
   333 	
       
   334 }
       
   335 // End of file