diff -r 30e048a7b597 -r bad0cc58d154 eapol/eapol_framework/eapol_symbian/am/type/tls_peap/symbian/plugin/src/EapTlsPeapUiEapTypes.cpp --- a/eapol/eapol_framework/eapol_symbian/am/type/tls_peap/symbian/plugin/src/EapTlsPeapUiEapTypes.cpp Thu Aug 19 09:58:27 2010 +0300 +++ b/eapol/eapol_framework/eapol_symbian/am/type/tls_peap/symbian/plugin/src/EapTlsPeapUiEapTypes.cpp Tue Aug 31 15:16:37 2010 +0300 @@ -16,7 +16,7 @@ */ /* -* %version: 16 % +* %version: % */ // This is enumeration of EAPOL source code. @@ -30,11 +30,13 @@ // INCLUDE FILES #include -#include "EapTlsPeapUtils.h" +//#include "EapTlsPeapUtils.h" #include #include #include -#include "eap_am_trace_symbian.h" +#include +#include "EapConversion.h" +#include const TUint KNumberOfSupportedEAPTypes = 10; //Now 10, including EAP-FAST & TTLS-PAP @@ -42,17 +44,14 @@ : iIsOpened(EFalse) , iUiConn(aUiConn) , iDataPtr(NULL) +, iEapTypeConnection(NULL) { } CEapTlsPeapUiEapTypes::~CEapTlsPeapUiEapTypes() { - if (iUiConn) - { - Close(); - iUiConn = NULL; - } + Close(); } @@ -63,49 +62,48 @@ return KErrAlreadyExists; } - TInt err = iUiConn->GetDatabase(iDatabase); - if (err != KErrNone) - { - return err; - } + TEapExpandedType aEapType(iUiConn->GetEapType()); + TRAPD(error, iEapTypeConnection = CEapType::NewL(iUiConn->GetIndexType(), iUiConn->GetIndex(), aEapType)); + if (error != KErrNone) + { + EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: CEapTlsPeapUiEapTypes::Open() CEapType::NewL() error=%d\n"),error)); + return error; + } + + iEapTypeConnection->SetTunnelingType(iUiConn->GetTunnelingType()); + iIsOpened = ETrue; return KErrNone; } -TInt CEapTlsPeapUiEapTypes::GetEapTypes(CArrayFixFlat ** aDataPtr) +TInt CEapTlsPeapUiEapTypes::GetEapTypes(RPointerArray ** aDataPtr) { if (aDataPtr == NULL) { return KErrArgument; } - if (iIsOpened == EFalse) + + if (iIsOpened == EFalse) { return KErrSessionClosed; } + if (iDataPtr != 0) { *aDataPtr = iDataPtr; return KErrNone; } - iDataPtr = new CArrayFixFlat(KNumberOfSupportedEAPTypes); + + iDataPtr = new RPointerArray(KNumberOfSupportedEAPTypes); if (!iDataPtr) { return KErrNoMemory; } -#ifdef USE_EAP_EXPANDED_TYPES - TRAPD(err, FetchExpandedDataL()); - -#else - - TRAPD(err, FetchDataL()); - -#endif //#ifdef USE_EAP_EXPANDED_TYPES - if (err != KErrNone) { delete iDataPtr; @@ -121,56 +119,11 @@ TInt CEapTlsPeapUiEapTypes::Update() { -#ifdef USE_EAP_EXPANDED_TYPES - TRAPD(err, UpdateExpandedDataL()); -#else - - TRAPD(err, UpdateL()); - -#endif //#ifdef USE_EAP_EXPANDED_TYPES - return err; } -#ifndef USE_EAP_EXPANDED_TYPES - -void CEapTlsPeapUiEapTypes::UpdateL() -{ - TEapArray eapTypes; - TEap* eapTmp; - - TInt i(0); - - for(i = 0; i < iDataPtr->Count(); i++) - { - eapTmp = new (ELeave) TEap; - CleanupStack::PushL(eapTmp); - eapTmp->Enabled = iDataPtr->At(i).iIsEnabled; - eapTmp->UID.Copy(iDataPtr->At(i).iEapType); - User::LeaveIfError(eapTypes.Append(eapTmp)); - CleanupStack::Pop(eapTmp); - } - - TRAPD(err, EapTlsPeapUtils::SetEapDataL( - iDatabase, - 0, - eapTypes, - iUiConn->GetIndexType(), - iUiConn->GetIndex(), - static_cast(iUiConn->GetTunnelingType()), - static_cast(iUiConn->GetEapType()))); - - eapTypes.ResetAndDestroy(); - if (err != KErrNone) - { - User::Leave(err); - } -} -#endif // #ifndef USE_EAP_EXPANDED_TYPES - - TInt CEapTlsPeapUiEapTypes::Close() { if (iIsOpened == EFalse) @@ -182,217 +135,158 @@ iDataPtr = 0; iUiConn = NULL; + + if (iEapTypeConnection) + { + delete iEapTypeConnection; + iEapTypeConnection = 0; + } + + iIsOpened = EFalse; + return KErrNone; } -#ifndef USE_EAP_EXPANDED_TYPES - -void CEapTlsPeapUiEapTypes::FetchDataL() -{ - TEapArray eapTypes; - - TRAPD(err, EapTlsPeapUtils::GetEapDataL( - iDatabase, - 0, - eapTypes, - iUiConn->GetIndexType(), - iUiConn->GetIndex(), - static_cast(iUiConn->GetTunnelingType()), - static_cast(iUiConn->GetEapType()))); - - if (err != KErrNone) - { - eapTypes.ResetAndDestroy(); - User::Leave(err); - } - - TInt i(0); - for (i = 0; i < eapTypes.Count(); i++) - { - TEapTlsPeapUiEapType tmp; - - tmp.iIsEnabled = eapTypes[i]->Enabled; - - tmp.iEapType.Copy(eapTypes[i]->UID); - - TRAPD(err, iDataPtr->AppendL(tmp)); - if (err != KErrNone) - { - eapTypes.ResetAndDestroy(); - User::Leave(err); - } - } - eapTypes.ResetAndDestroy(); -} -#endif // #ifndef USE_EAP_EXPANDED_TYPES - -#ifdef USE_EAP_EXPANDED_TYPES - void CEapTlsPeapUiEapTypes::FetchExpandedDataL() { EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::FetchExpandedDataL: Start\n"))); - RExpandedEapTypePtrArray enabledEAPTypes; - RExpandedEapTypePtrArray disabledEAPTypes; - - eap_type_value_e tunnelingType(static_cast(iUiConn->GetTunnelingType())); - eap_type_value_e eapType(static_cast(iUiConn->GetEapType())); - - TRAPD(err, EapTlsPeapUtils::GetTunnelingExpandedEapDataL( - iDatabase, - 0, - enabledEAPTypes, - disabledEAPTypes, - iUiConn->GetIndexType(), - iUiConn->GetIndex(), - tunnelingType, - eapType)); - - if (err != KErrNone) + EAPSettings aSettings; + + TRAPD(error,iEapTypeConnection->GetConfigurationL(aSettings)); + if (error) { - enabledEAPTypes.ResetAndDestroy(); - disabledEAPTypes.ResetAndDestroy(); - - EAP_TRACE_DEBUG_SYMBIAN( - (_L("CEapTlsPeapUiEapTypes::FetchExpandedDataL: Error from GetTunnelingExpandedEapDataL:%d\n"), - err)); - - User::Leave(err); - } - - EAP_TRACE_DEBUG_SYMBIAN( - (_L("CEapTlsPeapUiEapTypes::FetchExpandedDataL: Got tunneling EAPs from DB: enabled=%d,disabled=%d\n"), - enabledEAPTypes.Count(), disabledEAPTypes.Count())); - - TInt i(0); - - // First fill the enabled EAP types. - for (i = 0; i < enabledEAPTypes.Count(); i++) - { - TEapTlsPeapUiEapType tmpEAP; - - tmpEAP.iIsEnabled = ETrue; // All EAP types here are enabled. - - tmpEAP.iEapType.Copy(enabledEAPTypes[i]->iExpandedEAPType); - - TRAPD(err, iDataPtr->AppendL(tmpEAP)); - if (err != KErrNone) - { - enabledEAPTypes.ResetAndDestroy(); - User::Leave(err); - } - - EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeapUiEapTypes::FetchExpandedDataL:Appended ENABLED EAP type:", - tmpEAP.iEapType.Ptr(), - tmpEAP.iEapType.Size() ) ); + EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: CEapTlsPeapUiEapTypes::FetchExpandedDataL(): GetConfigurationL() failed %d\n"), error)); + User::Leave(error); } - // Now fill the disabled EAP types. - for (i = 0; i < disabledEAPTypes.Count(); i++) - { - TEapTlsPeapUiEapType tmpEAP; + TInt i(0); - tmpEAP.iIsEnabled = EFalse; // All EAP types here are disabled. - - tmpEAP.iEapType.Copy(disabledEAPTypes[i]->iExpandedEAPType); - - TRAPD(err, iDataPtr->AppendL(tmpEAP)); - if (err != KErrNone) + { + TEapExpandedType enabledEAPType(*EapExpandedTypeNone.GetType()); + + if (aSettings.iEnabledEncapsulatedEAPExpandedTypesPresent) { - disabledEAPTypes.ResetAndDestroy(); - User::Leave(err); + // First fill the enabled EAP types. + for (i = 0; i < aSettings.iEnabledEncapsulatedEAPExpandedTypes.Count(); i++) + { + TEapTlsPeapUiEapType * tmpEAP = new (ELeave) TEapTlsPeapUiEapType; + if (tmpEAP == 0) + { + User::Leave(KErrNoMemory); + } + + tmpEAP->SetIsEnabled(ETrue); // All EAP types here are enabled. + + tmpEAP->SetEapType(aSettings.iEnabledEncapsulatedEAPExpandedTypes[i]); + + TRAPD(err, iDataPtr->AppendL(tmpEAP)); + if (err != KErrNone) + { + User::Leave(err); + } + + EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeapUiEapTypes::FetchExpandedDataL(): Appended ENABLED EAP type:", + tmpEAP->GetEapType().GetValue().Ptr(), + tmpEAP->GetEapType().GetValue().Length() ) ); + } } - - EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeapUiEapTypes::FetchExpandedDataL:Appended DISABLED EAP type:", - tmpEAP.iEapType.Ptr(), - tmpEAP.iEapType.Size() ) ); } - - enabledEAPTypes.ResetAndDestroy(); - disabledEAPTypes.ResetAndDestroy(); - - EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::FetchExpandedDataL: End\n"))); + + { + TEapExpandedType disabledEAPType(*EapExpandedTypeNone.GetType()); + + if (aSettings.iDisabledEncapsulatedEAPExpandedTypesPresent) + { + // Now fill the disabled EAP types. + for (i = 0; i < aSettings.iDisabledEncapsulatedEAPExpandedTypes.Count(); i++) + { + TEapTlsPeapUiEapType * tmpEAP = new (ELeave) TEapTlsPeapUiEapType; + if (tmpEAP == 0) + { + User::Leave(KErrNoMemory); + } + + tmpEAP->SetIsEnabled(EFalse); // All EAP types here are disabled. + + tmpEAP->SetEapType(aSettings.iDisabledEncapsulatedEAPExpandedTypes[i]); + + TRAPD(err, iDataPtr->AppendL(tmpEAP)); + if (err != KErrNone) + { + User::Leave(err); + } + + EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeapUiEapTypes::FetchExpandedDataL(): Appended DISABLED EAP type:", + tmpEAP->GetEapType().GetValue().Ptr(), + tmpEAP->GetEapType().GetValue().Length() ) ); + } + } + } + + EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::FetchExpandedDataL(): End\n"))); } void CEapTlsPeapUiEapTypes::UpdateExpandedDataL() { - EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::UpdateExpandedDataL: Start\n"))); + EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::UpdateExpandedDataL(): Start\n"))); - RExpandedEapTypePtrArray enabledEAPTypes; - RExpandedEapTypePtrArray disabledEAPTypes; - SExpandedEAPType* expandedEAPTmp; - + if (iDataPtr == 0) + { + EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::UpdateExpandedDataL(): iDataPtr == 0\n"))); + User::Leave(KErrArgument); + } + + EAPSettings aSettings; + for(TInt i=0 ; i < iDataPtr->Count(); i++) { - expandedEAPTmp = new (ELeave) SExpandedEAPType; - CleanupStack::PushL(expandedEAPTmp); - - expandedEAPTmp->iExpandedEAPType.Copy(iDataPtr->At(i).iEapType); - - if(iDataPtr->At(i).iIsEnabled) + if ((*iDataPtr)[i] != 0) { - // Enabled - TInt error = enabledEAPTypes.Append(expandedEAPTmp); - - if (error != KErrNone) + TEapExpandedType expandedEAPTmp = (*iDataPtr)[i]->GetEapType(); + + if((*iDataPtr)[i]->GetIsEnabled()) { - enabledEAPTypes.ResetAndDestroy(); - disabledEAPTypes.ResetAndDestroy(); - User::LeaveIfError(error); - } - - EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeapUiEapTypes::UpdateExpandedDataL:Appended ENABLED EAP type:", - expandedEAPTmp->iExpandedEAPType.Ptr(), - expandedEAPTmp->iExpandedEAPType.Size() ) ); - } - else - { - // Disabled - TInt error = disabledEAPTypes.Append(expandedEAPTmp); + // Enabled + TInt error = aSettings.iEnabledEncapsulatedEAPExpandedTypes.Append(expandedEAPTmp); - if (error != KErrNone) - { - enabledEAPTypes.ResetAndDestroy(); - disabledEAPTypes.ResetAndDestroy(); - User::LeaveIfError(error); - } + if (error != KErrNone) + { + User::LeaveIfError(error); + } + + aSettings.iEnabledEncapsulatedEAPExpandedTypesPresent = ETrue; - EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeapUiEapTypes::UpdateExpandedDataL:Appended DISABLED EAP type:", - expandedEAPTmp->iExpandedEAPType.Ptr(), - expandedEAPTmp->iExpandedEAPType.Size() ) ); - } - - CleanupStack::Pop(expandedEAPTmp); - } + EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeapUiEapTypes::UpdateExpandedDataL(): Appended ENABLED EAP type:", + expandedEAPTmp.GetValue().Ptr(), + expandedEAPTmp.GetValue().Size() ) ); + } + else + { + // Disabled + TInt error = aSettings.iDisabledEncapsulatedEAPExpandedTypes.Append(expandedEAPTmp); - eap_type_value_e tunnelingType(static_cast(iUiConn->GetTunnelingType())); - eap_type_value_e eapType(static_cast(iUiConn->GetEapType())); + if (error != KErrNone) + { + User::LeaveIfError(error); + } + + aSettings.iDisabledEncapsulatedEAPExpandedTypesPresent = ETrue; - TRAPD(err, EapTlsPeapUtils::SetTunnelingExpandedEapDataL( - iDatabase, - 0, - enabledEAPTypes, - disabledEAPTypes, - iUiConn->GetIndexType(), - iUiConn->GetIndex(), - tunnelingType, - eapType)); + EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeapUiEapTypes::UpdateExpandedDataL(): Appended DISABLED EAP type:", + expandedEAPTmp.GetValue().Ptr(), + expandedEAPTmp.GetValue().Size() ) ); + } + } + } // for() - enabledEAPTypes.ResetAndDestroy(); - disabledEAPTypes.ResetAndDestroy(); - - if (err != KErrNone) - { - EAP_TRACE_DEBUG_SYMBIAN( - (_L("CEapTlsPeapUiEapTypes::UpdateExpandedDataL: Error from SetTunnelingExpandedEapDataL:%d\n"), - err)); + TRAPD(error,iEapTypeConnection->SetConfigurationL(aSettings)); + + EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::UpdateExpandedDataL(): error = %d\n"),error)); + + User::LeaveIfError(error); - User::Leave(err); - } - - EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::UpdateExpandedDataL: End\n"))); + EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::UpdateExpandedDataL(): End\n"))); } - -#endif // #ifdef USE_EAP_EXPANDED_TYPES // End of file