wlanutilities/eapwizard/src/eapwizard_p.cpp
branchRCL_3
changeset 25 f28ada11abbf
parent 24 63be7eb3fc78
equal deleted inserted replaced
24:63be7eb3fc78 25:f28ada11abbf
     1 /*
       
     2  * Copyright (c) 2010 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 "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: 
       
    15  *   EAP Wizard: Private implementation.
       
    16  */
       
    17 
       
    18 // System includes
       
    19 #include <QDebug>
       
    20 #include <QDataStream>
       
    21 #include <HbTranslator>
       
    22 #include <HbParameterLengthLimiter>
       
    23 #include <eapqtconfiginterface.h>
       
    24 #include <eapqtplugininfo.h>
       
    25 #include <eapqtpluginhandle.h>
       
    26 #include <eapqtconfig.h>
       
    27 #include <eapqtpacstoreconfig.h>
       
    28 #include <eapqtcertificateinfo.h>
       
    29 #include <wlanerrorcodes.h>
       
    30 
       
    31 // User includes
       
    32 #include "wlanwizardhelper.h"
       
    33 #include "wlanwizardplugin.h"
       
    34 #include "eapwizard.h"
       
    35 #include "eapwizard_p.h"
       
    36 #include "eapwizarduistrings.h"
       
    37 #include "eapwizardpageoutertype.h"
       
    38 #include "eapwizardpagecertca.h"
       
    39 #include "eapwizardpagecertuser.h"
       
    40 #include "eapwizardpageidentity.h"
       
    41 #include "eapwizardpageinnertype.h"
       
    42 #include "eapwizardpageusernamepassword.h"
       
    43 #include "eapwizardpagenewpacstore.h"
       
    44 #include "eapwizardpagepacstorepasswordconfirm.h"
       
    45 #include "OstTraceDefinitions.h"
       
    46 #ifdef OST_TRACE_COMPILER_IN_USE
       
    47 #include "eapwizard_pTraces.h"
       
    48 #endif
       
    49 
       
    50 /*!
       
    51    \class EapWizardPrivate
       
    52    \brief Implements the EAP wizard plugin for WLAN wizard.
       
    53  */
       
    54 
       
    55 // External function prototypes
       
    56 
       
    57 // Local constants
       
    58 
       
    59 
       
    60 // ======== LOCAL FUNCTIONS ========
       
    61 
       
    62 // ======== MEMBER FUNCTIONS ========
       
    63 
       
    64 /*!
       
    65    Constructor of EAP Wizard.
       
    66 
       
    67    @param [in] wizardHelper pointer to the helper instance.
       
    68  */
       
    69 EapWizardPrivate::EapWizardPrivate(
       
    70     WlanWizardHelper *wizardHelper) :
       
    71     mWizardHelper(wizardHelper), 
       
    72     mTranslator(new HbTranslator("eapwizard")), 
       
    73     mEapConfIf(new EapQtConfigInterface(
       
    74         EapQtConfigInterface::EapBearerTypeWlan, 
       
    75         EapQtConfigInterface::IapIdUndefined))
       
    76 {
       
    77     OstTraceFunctionEntry0( EAPWIZARDPRIVATE_EAPWIZARDPRIVATE_ENTRY );
       
    78     Q_ASSERT(wizardHelper);
       
    79     createPages();
       
    80     OstTraceFunctionExit0( EAPWIZARDPRIVATE_EAPWIZARDPRIVATE_EXIT );
       
    81 }
       
    82 
       
    83 /*!
       
    84    Destructor.
       
    85  */
       
    86 EapWizardPrivate::~EapWizardPrivate()
       
    87 {
       
    88     OstTraceFunctionEntry0( DUP1_EAPWIZARDPRIVATE_EAPWIZARDPRIVATE_ENTRY );
       
    89     OstTraceFunctionExit0( DUP1_EAPWIZARDPRIVATE_EAPWIZARDPRIVATE_EXIT );
       
    90 }
       
    91 
       
    92 /*!
       
    93    See EapWizard::summary().
       
    94  */
       
    95 bool EapWizardPrivate::summary(
       
    96     WlanWizardPlugin::Summary sum, 
       
    97     QString &item, 
       
    98     QString &value)
       
    99 {
       
   100     OstTraceFunctionEntry0( EAPWIZARDPRIVATE_SUMMARY_ENTRY );
       
   101     bool ret = false;
       
   102     int outerType = configurations(EapWizardPrivate::OuterType).toInt();
       
   103 
       
   104     switch (sum) {
       
   105     case WlanWizardPlugin::SummaryEapInnerType:
       
   106         if (hasInnerMethod()) {
       
   107             item = hbTrId("txt_occ_dblist_inner_eap");
       
   108             value = eapTypeToString(configurations(EapWizardPrivate::InnerType).toInt());
       
   109             ret = true;
       
   110         }
       
   111         break;
       
   112 
       
   113     case WlanWizardPlugin::SummaryEapFastProvisioningMode:
       
   114         if (outerType == EapQtPluginHandle::PluginEapFast) {
       
   115             item = hbTrId("txt_occ_dblist_provisioning_mode_for_eapfast");
       
   116             value = hbTrId("txt_occ_dblist_provisioning_mode_for_val_unauthent");
       
   117             ret = true;
       
   118         }
       
   119         break;
       
   120 
       
   121     default:
       
   122         Q_ASSERT(sum == WlanWizardPlugin::SummaryEapOuterType);
       
   123         item = hbTrId("txt_occ_dblist_outer_eap");
       
   124         value = eapTypeToString(outerType);
       
   125         ret = true;
       
   126         break;
       
   127 
       
   128     }
       
   129     OstTraceFunctionExit0( EAPWIZARDPRIVATE_SUMMARY_EXIT );
       
   130     return ret;
       
   131 }
       
   132 
       
   133 /*!
       
   134    See EapWizard::storeSettings().
       
   135 
       
   136    @return true - ok, false - failed
       
   137  */
       
   138 bool EapWizardPrivate::storeSettings()
       
   139 {
       
   140     OstTraceFunctionEntry0( EAPWIZARDPRIVATE_STORESETTINGS_ENTRY );
       
   141     bool ret = false;
       
   142     EapQtPluginHandle outerType(static_cast<EapQtPluginHandle::Plugin>(
       
   143         configurations(OuterType).toInt()));
       
   144 
       
   145     int iapId = mWizardHelper->configuration(WlanWizardHelper::ConfIapId).toInt();
       
   146 
       
   147     if (mEapConfIf->setConfigurationReference(iapId) 
       
   148         && storeOuterTypeSettings(outerType)
       
   149         && storeInnerTypeSettings(outerType)) {
       
   150         ret = true;
       
   151     }
       
   152 
       
   153     OstTraceFunctionExit0( EAPWIZARDPRIVATE_STORESETTINGS_EXIT );
       
   154     return ret;
       
   155 }
       
   156 
       
   157 /*!
       
   158    See WlanWizardPlugin::errorString().
       
   159 
       
   160    Returns EAP spesific error string.
       
   161  */
       
   162 QString EapWizardPrivate::errorString(int errorCode)
       
   163 {
       
   164     OstTraceFunctionEntry0( EAPWIZARDPRIVATE_ERRORSTRING_ENTRY );
       
   165     char* textId = NULL;
       
   166     int eapType = EapQtPluginHandle::PluginUndefined;
       
   167 
       
   168     switch (errorCode){
       
   169     case KErrWlanUserRejected:
       
   170         textId = "txt_occ_dialog_1_auth_failed_user_cert_rej";
       
   171         eapType = configurations(OuterType).toInt();
       
   172         break;
       
   173 
       
   174     case KErrWlanUserCertificateExpired:
       
   175         textId = "txt_occ_dialog_1_auth_failed_user_cert_exp";
       
   176         eapType = configurations(OuterType).toInt();
       
   177         break;
       
   178 
       
   179     case KErrWlanServerCertificateExpired:
       
   180         textId = "txt_occ_dialog_1_authentication_failed_server_ce";
       
   181         eapType = configurations(OuterType).toInt();
       
   182         break;
       
   183 
       
   184     case KErrWlanCerficateVerifyFailed:
       
   185         textId = "txt_occ_dialog_1_authentication_failed_could_not";
       
   186         eapType = configurations(OuterType).toInt();
       
   187         break;
       
   188 
       
   189     case KErrWlanNoCipherSuite:
       
   190         textId = "txt_occ_dialog_1_authentication_failed_cipher_su";
       
   191         eapType = configurations(OuterType).toInt();
       
   192         break;
       
   193 
       
   194     case KErrWlanSimNotInstalled:
       
   195         textId = "txt_occ_dialog_1_authentication_failed_check_sim";
       
   196         eapType = configurations(OuterType).toInt();
       
   197         break;
       
   198 
       
   199     case KErrWlanEapFastPacStoreCorrupted:
       
   200         textId = "txt_occ_dialog_1_authentication_failed_reset_pac";
       
   201         eapType = EapQtPluginHandle::PluginEapFast;
       
   202         break;
       
   203 
       
   204     case KErrWlanEapSimFailed:
       
   205     case KErrWlanEapTlsFailed:
       
   206     case KErrWlanEapPeapFailed:
       
   207     case KErrWlanEapAkaFailed:
       
   208     case KErrWlanEapTtlsFailed:
       
   209     case KErrWlanLeapFailed:
       
   210     case KErrWlanNoUserCertificate:
       
   211     case KErrWlanEapFastTunnelCompromiseError:
       
   212     case KErrWlanEapFastUnexpextedTlvExhanged:
       
   213     case KErrWlanEapFastNoPacNorCertsToAuthenticateWithProvDisabled:
       
   214     case KErrWlanEapFastNoMatchingPacForAid:
       
   215     case KErrWlanEapFastAuthFailed:
       
   216         textId = "txt_occ_dialog_1_authentication_failed";
       
   217         eapType = configurations(OuterType).toInt();
       
   218         break;
       
   219 
       
   220     case KErrWlanEapMsChapv2:
       
   221     case KErrWlanEapGtcFailed:
       
   222         textId = "txt_occ_dialog_1_authentication_failed";
       
   223         eapType = configurations(InnerType).toInt();
       
   224         break;
       
   225 
       
   226     case KErrWlanNotSubscribed:
       
   227     case KErrWlanAccessBarred:
       
   228     case KErrWlanPasswordExpired:
       
   229     case KErrWlanNoDialinPermissions:
       
   230     case KErrWlanAccountDisabled:
       
   231     case KErrWlanRestrictedLogonHours:
       
   232         textId = "txt_occ_dialog_1_authentication_failed";
       
   233         if (hasInnerMethod()){
       
   234             eapType = configurations(InnerType).toInt();
       
   235         } else {
       
   236             eapType = configurations(OuterType).toInt();
       
   237         }
       
   238         break;
       
   239 
       
   240     default:
       
   241         // Return empty string
       
   242         break;
       
   243     }
       
   244 
       
   245     QString string;
       
   246     if (textId) {
       
   247         string = HbParameterLengthLimiter(textId).arg(eapTypeToString(eapType));
       
   248     }
       
   249 
       
   250     OstTraceFunctionExit0( EAPWIZARDPRIVATE_ERRORSTRING_EXIT );
       
   251     return string;
       
   252 }
       
   253 
       
   254 /*!
       
   255    Reader method for eap configurations.
       
   256 
       
   257    See ConfigurationId for further details about the data types in QVariant.
       
   258 
       
   259    @param [in] confId Defines what configuration is read.
       
   260 
       
   261    @return configuration value.
       
   262  */
       
   263 QVariant EapWizardPrivate::configurations(ConfigurationId confId) const
       
   264 {
       
   265     OstTraceFunctionEntry0( EAPWIZARDPRIVATE_CONFIGURATIONS_ENTRY );
       
   266     Q_ASSERT(mConfigurations.contains(confId));
       
   267 
       
   268 #ifdef OST_TRACE_COMPILER_IN_USE
       
   269     QString tmp;
       
   270     QDebug tmpStream(&tmp );
       
   271     tmpStream << mConfigurations[confId];
       
   272     TPtrC16 string(tmp.utf16(), tmp.length() );
       
   273 
       
   274     OstTraceExt2( 
       
   275         TRACE_NORMAL, 
       
   276         EAPWIZARDPRIVATE_CONFIGURATIONS, 
       
   277         "EapWizardPrivate::configurations;confId=%{ConfigurationId};string=%S", 
       
   278         (TUint)confId, string );
       
   279 #endif
       
   280 
       
   281     OstTraceFunctionExit0( EAPWIZARDPRIVATE_CONFIGURATIONS_EXIT );
       
   282     return mConfigurations[confId];
       
   283 }
       
   284 
       
   285 /*!
       
   286    Sets EAP configuration value for given configuration identifier.
       
   287    See ConfigurationId for further details about the data types in QVariant.
       
   288 
       
   289    @param [in] confId Configuration Identifier do to be set
       
   290    @param [in] value  Value for configuration.
       
   291  */
       
   292 void EapWizardPrivate::setConfigurations(
       
   293     ConfigurationId confId, const QVariant &value)
       
   294 {
       
   295     OstTraceFunctionEntry0( EAPWIZARDPRIVATE_SETCONFIGURATIONS_ENTRY );
       
   296 #ifdef OST_TRACE_COMPILER_IN_USE
       
   297     QString tmp;
       
   298     QDebug tmpStream(&tmp );
       
   299     tmpStream << value;
       
   300     TPtrC16 string( tmp.utf16(), tmp.length() );
       
   301 
       
   302     OstTraceExt2( 
       
   303         TRACE_NORMAL, 
       
   304         EAPWIZARDPRIVATE_SETCONFIGURATIONS, 
       
   305         "EapWizardPrivate::setConfigurations;confId=%{ConfigurationId};string=%S", 
       
   306         (TUint)confId, string );
       
   307 #endif
       
   308 
       
   309     mConfigurations[confId] = value;
       
   310     OstTraceFunctionExit0( EAPWIZARDPRIVATE_SETCONFIGURATIONS_EXIT );
       
   311 }
       
   312 
       
   313 /*!
       
   314    @return pointer to EapQtConfigInterface.
       
   315  */
       
   316 EapQtConfigInterface* EapWizardPrivate::eapConfigurationInterface() const
       
   317 {
       
   318     OstTraceFunctionEntry0( EAPWIZARDPRIVATE_EAPCONFIGURATIONINTERFACE_ENTRY );
       
   319     Q_ASSERT(mEapConfIf.data());
       
   320     OstTraceFunctionExit0( EAPWIZARDPRIVATE_EAPCONFIGURATIONINTERFACE_EXIT );
       
   321     return mEapConfIf.data();
       
   322 }
       
   323 
       
   324 /*!
       
   325    Maps given EAP Qt Plugin handle into string.
       
   326 
       
   327    @param [in] id EapQtPluginHandle::Handle, id to be mapped to string.
       
   328 
       
   329    @return EAP String.
       
   330  */
       
   331 QString EapWizardPrivate::eapTypeToString(int id) const
       
   332 {
       
   333     OstTraceFunctionEntry0( EAPWIZARDPRIVATE_EAPTYPETOSTRING_ENTRY );
       
   334     QString locId;
       
   335     switch (id) {
       
   336     case EapQtPluginHandle::PluginEapAka:
       
   337         locId = EapWizardUiStrings::EapAka;
       
   338         break;
       
   339 
       
   340     case EapQtPluginHandle::PluginEapFast:
       
   341         locId = EapWizardUiStrings::EapFast;
       
   342         break;
       
   343 
       
   344     case EapQtPluginHandle::PluginLeap:
       
   345         locId = EapWizardUiStrings::Leap;
       
   346         break;
       
   347 
       
   348     case EapQtPluginHandle::PluginPeap:
       
   349         locId = EapWizardUiStrings::Peap;
       
   350         break;
       
   351 
       
   352     case EapQtPluginHandle::PluginEapSim:
       
   353         locId = EapWizardUiStrings::EapSim;
       
   354         break;
       
   355 
       
   356     case EapQtPluginHandle::PluginEapTls:
       
   357         locId = EapWizardUiStrings::EapTls;
       
   358         break;
       
   359 
       
   360     case EapQtPluginHandle::PluginEapTtls:
       
   361         locId = EapWizardUiStrings::EapTtls;
       
   362         break;
       
   363 
       
   364     case EapQtPluginHandle::PluginEapMschapv2:
       
   365         locId = EapWizardUiStrings::EapMschapv2;
       
   366         break;
       
   367 
       
   368     case EapQtPluginHandle::PluginEapGtc:
       
   369         locId = EapWizardUiStrings::EapGtc;
       
   370         break;
       
   371 
       
   372     case EapQtPluginHandle::PluginPap:
       
   373         locId = EapWizardUiStrings::Pap;
       
   374         break;
       
   375 
       
   376     default:
       
   377         // Invalid enum
       
   378         Q_ASSERT(EapQtPluginHandle::PluginPlainMschapv2 == id);
       
   379         locId = EapWizardUiStrings::Mschapv2;
       
   380         break;
       
   381     }
       
   382 
       
   383     OstTraceFunctionExit0( EAPWIZARDPRIVATE_EAPTYPETOSTRING_EXIT );
       
   384     return locId;
       
   385 }
       
   386 
       
   387 /*!
       
   388    Accessor to WLAN Wizard Helper objects.
       
   389 
       
   390    @return a pointer to helper object.
       
   391  */
       
   392 WlanWizardHelper *EapWizardPrivate::wizardHelper() const
       
   393 {
       
   394     OstTraceFunctionEntry0( EAPWIZARDPRIVATE_WIZARDHELPER_ENTRY );
       
   395     Q_ASSERT(mWizardHelper);
       
   396     OstTraceFunctionExit0( EAPWIZARDPRIVATE_WIZARDHELPER_EXIT );
       
   397     return mWizardHelper;
       
   398 }
       
   399 
       
   400 /*!
       
   401    Creates EAP Wizard pages and add those to the wizard framework.
       
   402  */
       
   403 void EapWizardPrivate::createPages()
       
   404 {
       
   405     OstTraceFunctionEntry0( EAPWIZARDPRIVATE_CREATEPAGES_ENTRY );
       
   406     mWizardHelper->addPage(
       
   407         EapWizardPage::PageOuterType,
       
   408         new EapWizardPageOuterType(this));
       
   409 
       
   410     mWizardHelper->addPage(
       
   411         EapWizardPage::PageCertificateCa,
       
   412         new EapWizardPageCertCa(this));
       
   413 
       
   414     mWizardHelper->addPage(
       
   415         EapWizardPage::PageCertificateUser,
       
   416         new EapWizardPageCertUser(this));
       
   417 
       
   418     mWizardHelper->addPage(
       
   419         EapWizardPage::PageIdentity,
       
   420         new EapWizardPageIdentity(this));
       
   421 
       
   422     mWizardHelper->addPage(
       
   423         EapWizardPage::PageInnerTypeEapTtls, 
       
   424         new EapWizardPageInnerType(
       
   425             this, 
       
   426             EapQtPluginHandle::PluginEapTtls));
       
   427 
       
   428     mWizardHelper->addPage(
       
   429         EapWizardPage::PageInnerTypePeap, 
       
   430         new EapWizardPageInnerType(
       
   431             this,
       
   432             EapQtPluginHandle::PluginPeap));
       
   433 
       
   434     mWizardHelper->addPage(
       
   435         EapWizardPage::PageUsernamePassword, 
       
   436         new EapWizardPageUsernamePassword(this));
       
   437 
       
   438     mWizardHelper->addPage(
       
   439         EapWizardPage::PageNewPacStorePassword, 
       
   440         new EapWizardPageNewPacStore(this));
       
   441 
       
   442     mWizardHelper->addPage(
       
   443         EapWizardPage::PagePromptPacStorePassword,
       
   444         new EapWizardPagePacStorePasswordConfirm(this));
       
   445     OstTraceFunctionExit0( EAPWIZARDPRIVATE_CREATEPAGES_EXIT );
       
   446 }
       
   447 
       
   448 /*!
       
   449    Check whether selected outer type has inner method.
       
   450 
       
   451    @return true if inner method exists, false otherwise.
       
   452  */
       
   453 bool EapWizardPrivate::hasInnerMethod() const
       
   454 {
       
   455     OstTraceFunctionEntry0( EAPWIZARDPRIVATE_HASINNERMETHOD_ENTRY );
       
   456     int outerType = configurations(EapWizardPrivate::OuterType).toInt();
       
   457     bool ret = false;
       
   458 
       
   459     switch (outerType) {
       
   460     case EapQtPluginHandle::PluginEapTtls:
       
   461     case EapQtPluginHandle::PluginPeap:
       
   462     case EapQtPluginHandle::PluginEapFast:
       
   463         ret = true;
       
   464         break;
       
   465     }
       
   466 
       
   467     OstTraceFunctionExit0( EAPWIZARDPRIVATE_HASINNERMETHOD_EXIT );
       
   468     return ret;
       
   469 }
       
   470 
       
   471 
       
   472 /*
       
   473    Handles TLS methods (PEAP, EAP-TLS and EAP-TTLS) settings.
       
   474 
       
   475    Stores configurations to eapConf
       
   476 
       
   477    @param [in,out] eapConf configuration is written to this object.
       
   478    @param [in] outerType Outer EAP method
       
   479  */
       
   480 void EapWizardPrivate::handleTlsMethodsSettings(
       
   481     EapQtConfig &eapConf,
       
   482     EapQtPluginHandle &outerType)
       
   483 {
       
   484     OstTraceFunctionEntry0( EAPWIZARDPRIVATE_HANDLETLSMETHODSSETTINGS_ENTRY );
       
   485     // Common stuff for all tls methods
       
   486     eapConf.setValue(EapQtConfig::UseIdentityPrivacy, false);
       
   487     eapConf.setValue(EapQtConfig::VerifyServerRealm, false);
       
   488     eapConf.setValue(EapQtConfig::ClientAuthenticationRequired, false);
       
   489     eapConf.setValue(EapQtConfig::UsernameAutomatic, configurations(TunnelUsernameAutomatic));
       
   490     eapConf.setValue(EapQtConfig::Username, configurations(TunnelUsername));
       
   491     eapConf.setValue(EapQtConfig::RealmAutomatic, configurations(TunnelRealmAutomatic));
       
   492     eapConf.setValue(EapQtConfig::Realm, configurations(TunnelRealm));
       
   493 
       
   494     QVariant certVariant = configurations(CertificateCa);
       
   495 
       
   496     if (certVariant.canConvert<EapQtCertificateInfo> ()) {
       
   497         QList<QVariant> caCerts;
       
   498         caCerts.append(certVariant);
       
   499         eapConf.setValue(EapQtConfig::AuthorityCertificate, caCerts);
       
   500         eapConf.setValue(EapQtConfig::AuthorityCertificateAutomatic, false);
       
   501     } else {
       
   502         eapConf.setValue(EapQtConfig::AuthorityCertificateAutomatic, true);
       
   503     }
       
   504 
       
   505     // type specific configurations
       
   506     if (outerType == EapQtPluginHandle::PluginEapTls) {
       
   507         QList<QVariant> userCerts;
       
   508         userCerts.append(configurations(CertificateUser));
       
   509         eapConf.setValue(EapQtConfig::ClientAuthenticationRequired, true);
       
   510         eapConf.setValue(EapQtConfig::UserCertificate, userCerts);
       
   511 
       
   512     } else if (outerType == EapQtPluginHandle::PluginPeap) {
       
   513 
       
   514         switch (configurations(InnerType).toInt()) {
       
   515         case EapQtPluginHandle::PluginEapMschapv2:
       
   516             // EAP-MSCHAPv2: enable v0 only
       
   517             eapConf.setValue(EapQtConfig::PeapVersion0Allowed, true);
       
   518             eapConf.setValue(EapQtConfig::PeapVersion1Allowed, false);
       
   519             break;
       
   520 
       
   521         case EapQtPluginHandle::PluginEapGtc:
       
   522             // EAP-GTC: enable v1 only
       
   523             eapConf.setValue(EapQtConfig::PeapVersion0Allowed, false);
       
   524             eapConf.setValue(EapQtConfig::PeapVersion1Allowed, true);
       
   525             break;
       
   526         }
       
   527         eapConf.setValue(EapQtConfig::PeapVersion2Allowed, false);
       
   528     }
       
   529     OstTraceFunctionExit0( EAPWIZARDPRIVATE_HANDLETLSMETHODSSETTINGS_EXIT );
       
   530 }
       
   531 
       
   532 /*!
       
   533    Handles configurations for EAP-FAST.
       
   534 
       
   535    @param [in,out] eapConf EAP Configuration
       
   536 
       
   537    @param false in case of failure.
       
   538  */
       
   539 bool EapWizardPrivate::handleEapFastSettings(EapQtConfig &eapConf)
       
   540 {
       
   541     OstTraceFunctionEntry0( EAPWIZARDPRIVATE_HANDLEEAPFASTSETTINGS_ENTRY );
       
   542     bool ret = true;
       
   543     EapQtPacStoreConfig pacStoreConf;
       
   544 
       
   545     eapConf.setValue(EapQtConfig::ProvisioningModeAuthenticated, false);
       
   546     eapConf.setValue(EapQtConfig::ProvisioningModeUnauthenticated, true);
       
   547     eapConf.setValue(EapQtConfig::VerifyServerRealm, false);
       
   548     eapConf.setValue(EapQtConfig::UseIdentityPrivacy, false);
       
   549 
       
   550     switch (configurations(PacStoreState).toInt()) {
       
   551     case EapQtPacStoreConfig::PacStoreStateStoreNotExists:
       
   552     case EapQtPacStoreConfig::PacStoreStatePasswordRequired:            
       
   553         pacStoreConf.setValue(
       
   554             EapQtPacStoreConfig::PacStorePassword, 
       
   555             configurations(PacStorePassword));
       
   556 
       
   557         pacStoreConf.setValue(
       
   558             EapQtPacStoreConfig::PacStoreSavePassword, 
       
   559             true);
       
   560 
       
   561         if (!mEapConfIf->savePacStoreConfiguration(pacStoreConf)) {
       
   562             // no cleaning required
       
   563             ret = false;
       
   564         }
       
   565         break;
       
   566 
       
   567     default:
       
   568         // Do nothing
       
   569         break;
       
   570     }
       
   571 
       
   572     OstTraceFunctionExit0( EAPWIZARDPRIVATE_HANDLEEAPFASTSETTINGS_EXIT );
       
   573     return ret;
       
   574 }
       
   575 
       
   576 /*!
       
   577    Handles configurations for EAP-AKA and EAP-SIM.
       
   578 
       
   579    @param [in,out] eapConf EAP Configuration
       
   580  */
       
   581 void EapWizardPrivate::handleEapAkaSimSettings(EapQtConfig &eapConf)
       
   582 {
       
   583     OstTraceFunctionEntry0( EAPWIZARDPRIVATE_HANDLEEAPAKASIMSETTINGS_ENTRY );
       
   584     eapConf.setValue(EapQtConfig::UsernameAutomatic, true);
       
   585     eapConf.setValue(EapQtConfig::RealmAutomatic, true);    
       
   586     OstTraceFunctionExit0( EAPWIZARDPRIVATE_HANDLEEAPAKASIMSETTINGS_EXIT );
       
   587 }
       
   588 
       
   589 /*!
       
   590    Handles configurations for LEAP.
       
   591 
       
   592    @param [in,out] eapConf EAP Configuration
       
   593  */
       
   594 void EapWizardPrivate::handleLeapSettings(EapQtConfig &eapConf)
       
   595 {
       
   596     OstTraceFunctionEntry0( EAPWIZARDPRIVATE_HANDLELEAPSETTINGS_ENTRY );
       
   597     eapConf.setValue(EapQtConfig::UsernameAutomatic, false);
       
   598     eapConf.setValue(EapQtConfig::Username, configurations(Username));
       
   599     eapConf.setValue(EapQtConfig::PasswordPrompt, false);
       
   600     eapConf.setValue(EapQtConfig::Password, configurations(Password));    
       
   601     OstTraceFunctionExit0( EAPWIZARDPRIVATE_HANDLELEAPSETTINGS_EXIT );
       
   602 }
       
   603 
       
   604 /*!
       
   605    Store outer type settings.
       
   606 
       
   607    @param outerType reference to outertype
       
   608 
       
   609    @return false in case of failure.
       
   610  */
       
   611 bool EapWizardPrivate::storeOuterTypeSettings(EapQtPluginHandle &outerType)
       
   612 {
       
   613     OstTraceFunctionEntry0( EAPWIZARDPRIVATE_STOREOUTERTYPESETTINGS_ENTRY );
       
   614     EapQtConfig eapConf;
       
   615 
       
   616     // 1. Store outer type settings
       
   617     switch (outerType.pluginId()) {
       
   618     case EapQtPluginHandle::PluginEapTtls: 
       
   619     case EapQtPluginHandle::PluginPeap:
       
   620     case EapQtPluginHandle::PluginEapTls:
       
   621         handleTlsMethodsSettings(eapConf, outerType);
       
   622         break;
       
   623 
       
   624     case EapQtPluginHandle::PluginEapFast:
       
   625         if (!handleEapFastSettings(eapConf)) {
       
   626             OstTraceFunctionExit0( EAPWIZARDPRIVATE_STOREOUTERTYPESETTINGS_EXIT );
       
   627             return false;
       
   628         }
       
   629         break;
       
   630 
       
   631     case EapQtPluginHandle::PluginEapAka: 
       
   632     case EapQtPluginHandle::PluginEapSim:
       
   633         handleEapAkaSimSettings(eapConf);
       
   634         break;
       
   635 
       
   636     default:
       
   637         Q_ASSERT(outerType == EapQtPluginHandle::PluginLeap);
       
   638         handleLeapSettings(eapConf);
       
   639         break;
       
   640     }
       
   641 
       
   642     if (hasInnerMethod()) {
       
   643         EapQtPluginHandle inner = static_cast<EapQtPluginHandle::Plugin>(
       
   644             configurations(InnerType).toInt());
       
   645 
       
   646         QList<QVariant> innerType;
       
   647         innerType.append(qVariantFromValue(inner));
       
   648         eapConf.setValue(EapQtConfig::InnerType, innerType);
       
   649     }
       
   650 
       
   651     // store outer type configurations
       
   652     if (!mEapConfIf->saveConfiguration(outerType, eapConf)){
       
   653         mEapConfIf->deleteConfiguration();
       
   654         OstTraceFunctionExit0( DUP1_EAPWIZARDPRIVATE_STOREOUTERTYPESETTINGS_EXIT );
       
   655         return false;
       
   656     }
       
   657 
       
   658     QList<EapQtPluginHandle> selectedOuterTypes;
       
   659     selectedOuterTypes.append(outerType);
       
   660     if (!mEapConfIf->setSelectedOuterTypes(selectedOuterTypes)){
       
   661         mEapConfIf->deleteConfiguration();
       
   662         OstTraceFunctionExit0( DUP2_EAPWIZARDPRIVATE_STOREOUTERTYPESETTINGS_EXIT );
       
   663         return false;
       
   664     }
       
   665 
       
   666     OstTraceFunctionExit0( DUP3_EAPWIZARDPRIVATE_STOREOUTERTYPESETTINGS_EXIT );
       
   667     return true;
       
   668 }
       
   669 
       
   670 
       
   671 /*!
       
   672    Store inner type settings if exists.
       
   673 
       
   674    @param outerType reference to outertype
       
   675 
       
   676    @return false in case of failure.
       
   677  */
       
   678 bool EapWizardPrivate::storeInnerTypeSettings(EapQtPluginHandle &outerType)
       
   679 {
       
   680     OstTraceFunctionEntry0( EAPWIZARDPRIVATE_STOREINNERTYPESETTINGS_ENTRY );
       
   681     bool ret = true;
       
   682 
       
   683     if (hasInnerMethod()) {
       
   684         EapQtPluginHandle inner = static_cast<EapQtPluginHandle::Plugin>(
       
   685             configurations(InnerType).toInt());
       
   686 
       
   687         // All inner methods supported by wizard use password / username. 
       
   688         EapQtConfig eapConfInner;
       
   689         eapConfInner.setValue(EapQtConfig::OuterType, qVariantFromValue(outerType));
       
   690         eapConfInner.setValue(EapQtConfig::UsernameAutomatic, false);
       
   691         eapConfInner.setValue(EapQtConfig::Username, configurations(Username));
       
   692         eapConfInner.setValue(EapQtConfig::PasswordPrompt, false);
       
   693         eapConfInner.setValue(EapQtConfig::Password, configurations(Password));
       
   694 
       
   695         if (!mEapConfIf->saveConfiguration(inner, eapConfInner)){
       
   696             mEapConfIf->deleteConfiguration();
       
   697             ret = false;
       
   698         }
       
   699     }
       
   700     OstTraceFunctionExit0( EAPWIZARDPRIVATE_STOREINNERTYPESETTINGS_EXIT );
       
   701     return ret;
       
   702 }