eapol/eapol_framework/eapol_symbian/am/type/securid/symbian/plugin/src/EapSecurID.cpp
branchRCL_3
changeset 46 c74b3d9f6b9e
parent 45 bad0cc58d154
equal deleted inserted replaced
45:bad0cc58d154 46:c74b3d9f6b9e
    14 * Description:  EAP and WLAN authentication protocols.
    14 * Description:  EAP and WLAN authentication protocols.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 25 %
    19 * %version: 15.1.2 %
    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
    35 #include "eap_type_securid.h"
    35 #include "eap_type_securid.h"
    36 #include "EapSecurIDGlobal.h"
    36 #include "EapSecurIDGlobal.h"
    37 #include <EapTypeInfo.h>
    37 #include <EapTypeInfo.h>
    38 #include "EapGtcDbUtils.h"
    38 #include "EapGtcDbUtils.h"
    39 
    39 
       
    40 #include <EapGtcUiConnection.h>
       
    41 #include "EapGtcUi.h"
       
    42 
    40 #include "eap_am_tools_symbian.h"
    43 #include "eap_am_tools_symbian.h"
    41 #include "EapConversion.h"
       
    42 #include "EapTraceSymbian.h"
       
    43 
    44 
    44 // LOCAL CONSTANTS
    45 // LOCAL CONSTANTS
    45 
    46 
    46 // The version number of this interface.
    47 // The version number of this interface.
    47 const TUint KInterfaceVersion = 1;
    48 const TUint KInterfaceVersion = 1;
   149 	return KInterfaceVersion; 
   150 	return KInterfaceVersion; 
   150 }
   151 }
   151 
   152 
   152 // ----------------------------------------------------------
   153 // ----------------------------------------------------------
   153 
   154 
   154 CEapTypeInfo* CEapSecurID::GetInfoL()
   155 TInt CEapSecurID::InvokeUiL()
       
   156 {
       
   157 	TInt buttonId(0);
       
   158 
       
   159 #ifdef USE_EAP_EXPANDED_TYPES
       
   160 
       
   161     CEapGtcUiConnection uiConn(iIndexType, iIndex, iTunnelingType.get_vendor_type());
       
   162 	
       
   163 #else
       
   164 
       
   165     CEapGtcUiConnection uiConn(iIndexType, iIndex, iTunnelingType);
       
   166 
       
   167 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
   168 	
       
   169 	CEapGtcUi* ui = CEapGtcUi::NewL(&uiConn);
       
   170 	CleanupStack::PushL(ui);
       
   171 	buttonId = ui->InvokeUiL();
       
   172 	CleanupStack::PopAndDestroy(ui);
       
   173 	return buttonId;
       
   174 }
       
   175 
       
   176 // ----------------------------------------------------------
       
   177 
       
   178 CEapTypeInfo* CEapSecurID::GetInfoLC()
   155 {
   179 {
   156 	CEapTypeInfo* info = new(ELeave) CEapTypeInfo(
   180 	CEapTypeInfo* info = new(ELeave) CEapTypeInfo(
   157 		(TDesC&) KReleaseDate,
   181 		(TDesC&) KReleaseDate,
   158 		(TDesC&) KEapTypeVersion,
   182 		(TDesC&) KEapTypeVersion,
   159 		(TDesC&) KManufacturer);
   183 		(TDesC&) KManufacturer);
   160 
   184 	CleanupStack::PushL(info);
   161 	return info;
   185 	return info;
   162 }
   186 }
   163 
   187 
   164 // ----------------------------------------------------------
   188 // ----------------------------------------------------------
   165 
   189 
   168 	EapGtcDbUtils::DeleteConfigurationL(iIndexType, iIndex, iTunnelingType);
   192 	EapGtcDbUtils::DeleteConfigurationL(iIndexType, iIndex, iTunnelingType);
   169 }
   193 }
   170 
   194 
   171 // ----------------------------------------------------------
   195 // ----------------------------------------------------------
   172 
   196 
   173 void CEapSecurID::SetTunnelingType(const TEapExpandedType aTunnelingType)
   197 void CEapSecurID::SetTunnelingType(const TInt aTunnelingType)
   174     {
   198 {
   175     EAP_TRACE_DATA_DEBUG_SYMBIAN(
   199 #ifdef USE_EAP_EXPANDED_TYPES
   176         (EAPL("CEapSecurID::SetTunnelingType - tunneling type"),
   200 
   177         aTunnelingType.GetValue().Ptr(), aTunnelingType.GetValue().Length()));
   201 	// Vendor id is eap_type_vendor_id_ietf always in this plugin.
   178     
   202 	iTunnelingType.set_eap_type_values(eap_type_vendor_id_ietf, aTunnelingType);
   179     eap_type_value_e aInternalType;
   203 
   180     
   204 #else
   181     TInt err = CEapConversion::ConvertExpandedEAPTypeToInternalType(
   205 
   182             &aTunnelingType,
   206 	iTunnelingType = static_cast<eap_type_value_e>(aTunnelingType);
   183             &aInternalType);
   207 
   184     
   208 #endif //#ifdef USE_EAP_EXPANDED_TYPES
   185     iTunnelingType = aInternalType;
   209 }
   186     }
       
   187 
   210 
   188 // ----------------------------------------------------------
   211 // ----------------------------------------------------------
   189 void CEapSecurID::SetIndexL(
   212 void CEapSecurID::SetIndexL(
   190 		const TIndexType aIndexType, 
   213 		const TIndexType aIndexType, 
   191 		const TInt aIndex)
   214 		const TInt aIndex)
   205 	iIndexType = tmpIndexType;
   228 	iIndexType = tmpIndexType;
   206 	iIndex = tmpIndex;
   229 	iIndex = tmpIndex;
   207 
   230 
   208 	RDbNamedDatabase db;
   231 	RDbNamedDatabase db;
   209 
   232 
   210 	RFs session;
   233 	RDbs session;
       
   234 	
       
   235 	EapGtcDbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
   211 	
   236 	
   212 	CleanupClosePushL(session);
   237 	CleanupClosePushL(session);
   213 	CleanupClosePushL(db);
   238 	CleanupClosePushL(db);
   214 	TInt error = session.Connect();
   239 		
   215 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapSecurID::SetIndexL(): - session.Connect(), error=%d\n"), error));
       
   216 	User::LeaveIfError(error);
       
   217 
       
   218 	EapGtcDbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
       
   219 
       
   220 	EapGtcDbUtils::SetIndexL(
   240 	EapGtcDbUtils::SetIndexL(
   221 		db, 
   241 		db, 
   222 		iIndexType, 
   242 		iIndexType, 
   223 		iIndex, 
   243 		iIndex, 
   224 		iTunnelingType, 
   244 		iTunnelingType, 
   227 		iTunnelingType);
   247 		iTunnelingType);
   228 	
   248 	
   229 	iIndexType = aIndexType;
   249 	iIndexType = aIndexType;
   230 	iIndex = aIndex;
   250 	iIndex = aIndex;
   231 
   251 
   232 	db.Close();
   252 	CleanupStack::PopAndDestroy(2); // db
   233 	session.Close();
   253 	
   234 
   254 		
   235 	CleanupStack::PopAndDestroy(&db);
       
   236 	CleanupStack::PopAndDestroy(&session);
       
   237 }
   255 }
   238 
   256 
   239 void CEapSecurID::SetConfigurationL(const EAPSettings& aSettings)
   257 void CEapSecurID::SetConfigurationL(const EAPSettings& aSettings)
   240 {
   258 {
   241 	RDbNamedDatabase db;
   259 	RDbNamedDatabase db;
   242 
   260 
   243 	RFs session;
   261 	RDbs session;	
       
   262 	
       
   263 	// This also creates the IAP entry if it doesn't exist
       
   264 	EapGtcDbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
   244 	
   265 	
   245 	CleanupClosePushL(session);
   266 	CleanupClosePushL(session);
   246 	CleanupClosePushL(db);
   267 	CleanupClosePushL(db);
   247 	TInt error = session.Connect();
       
   248 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapSecurID::SetConfigurationL(): - session.Connect(), error=%d\n"), error));
       
   249 	User::LeaveIfError(error);
       
   250 
       
   251 	// This also creates the IAP entry if it doesn't exist
       
   252 	EapGtcDbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
       
   253 
   268 
   254 	EapGtcDbUtils::SetConfigurationL(
   269 	EapGtcDbUtils::SetConfigurationL(
   255 		db,
   270 		db,
   256 		aSettings, 
   271 		aSettings, 
   257 		iIndexType,
   272 		iIndexType,
   258 		iIndex,
   273 		iIndex,
   259 		iTunnelingType);		
   274 		iTunnelingType);		
   260 
   275 		
   261 	db.Close();
   276 	CleanupStack::PopAndDestroy(2); // db, session
   262 	session.Close();
       
   263 
       
   264 	CleanupStack::PopAndDestroy(&db);
       
   265 	CleanupStack::PopAndDestroy(&session);
       
   266 }
   277 }
   267 
   278 
   268 void CEapSecurID::GetConfigurationL(EAPSettings& aSettings)
   279 void CEapSecurID::GetConfigurationL(EAPSettings& aSettings)
   269 {
   280 {
   270 	RDbNamedDatabase db;
   281 	RDbNamedDatabase db;
   271 
   282 
   272 	RFs session;
   283 	RDbs session;
       
   284 	
       
   285 	// This also creates the IAP entry if it doesn't exist
       
   286 	EapGtcDbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
   273 	
   287 	
   274 	CleanupClosePushL(session);
   288 	CleanupClosePushL(session);
   275 	CleanupClosePushL(db);
   289 	CleanupClosePushL(db);
   276 	TInt error = session.Connect();
       
   277 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapSecurID::GetConfigurationL(): - session.Connect(), error=%d\n"), error));
       
   278 	User::LeaveIfError(error);
       
   279 
       
   280 	// This also creates the IAP entry if it doesn't exist
       
   281 	EapGtcDbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
       
   282 
   290 
   283 	EapGtcDbUtils::GetConfigurationL(
   291 	EapGtcDbUtils::GetConfigurationL(
   284 		db,
   292 		db,
   285 		aSettings, 
   293 		aSettings, 
   286 		iIndexType,
   294 		iIndexType,
   287 		iIndex,
   295 		iIndex,
   288 		iTunnelingType);
   296 		iTunnelingType);
   289 
   297 		
   290 	db.Close();
   298 	CleanupStack::PopAndDestroy(2); // db, session
   291 	session.Close();
       
   292 
       
   293 	CleanupStack::PopAndDestroy(&db);
       
   294 	CleanupStack::PopAndDestroy(&session);
       
   295 }
   299 }
   296 
   300 
   297 void CEapSecurID::CopySettingsL(
   301 void CEapSecurID::CopySettingsL(
   298 	const TIndexType aDestinationIndexType,
   302 	const TIndexType aDestinationIndexType,
   299 	const TInt aDestinationIndex)
   303 	const TInt aDestinationIndex)
   313 	iIndexType = tmpIndexType;
   317 	iIndexType = tmpIndexType;
   314 	iIndex = tmpIndex;
   318 	iIndex = tmpIndex;
   315 
   319 
   316 	RDbNamedDatabase db;
   320 	RDbNamedDatabase db;
   317 
   321 
   318 	RFs session;
   322 	RDbs session;
       
   323 	
       
   324 	EapGtcDbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
   319 	
   325 	
   320 	CleanupClosePushL(session);
   326 	CleanupClosePushL(session);
   321 	CleanupClosePushL(db);
   327 	CleanupClosePushL(db);
   322 	TInt error = session.Connect();
   328 		
   323 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapSecurID::CopySettingsL(): - session.Connect(), error=%d\n"), error));
       
   324 	User::LeaveIfError(error);
       
   325 
       
   326 	EapGtcDbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
       
   327 
       
   328 	EapGtcDbUtils::CopySettingsL(
   329 	EapGtcDbUtils::CopySettingsL(
   329 		db,
   330 		db,
   330 		iIndexType,
   331 		iIndexType,
   331 		iIndex,
   332 		iIndex,
   332 		iTunnelingType, 
   333 		iTunnelingType, 
   333 		aDestinationIndexType, 
   334 		aDestinationIndexType, 
   334 		aDestinationIndex, 
   335 		aDestinationIndex, 
   335 		iTunnelingType);
   336 		iTunnelingType);
   336 
   337 		
   337 	db.Close();
   338 	CleanupStack::PopAndDestroy(2); // db
   338 	session.Close();
   339 	
   339 
       
   340 	CleanupStack::PopAndDestroy(&db);
       
   341 	CleanupStack::PopAndDestroy(&session);
       
   342 }
   340 }
   343 
   341 
   344 
   342 
   345 // End of File
   343 // End of File