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