securitysettings/qtconfigutils/eapqtconfiginterface/src/eapqtconfiginterface_p.cpp
branchRCL_3
changeset 46 c74b3d9f6b9e
parent 45 bad0cc58d154
child 55 9c2aa05919d9
equal deleted inserted replaced
45:bad0cc58d154 46:c74b3d9f6b9e
     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 method configuration QT interface
       
    16  *
       
    17  */
       
    18 
       
    19 /*
       
    20  * %version: 52 %
       
    21  */
       
    22 
       
    23 // System includes
       
    24 #include <QDir>
       
    25 #include <QList>
       
    26 #include <QVariant>
       
    27 #include <QPluginLoader>
       
    28 #include <HbTranslator>
       
    29 #include <QLocale>
       
    30 #include <QCoreApplication>
       
    31 #include <QDebug>
       
    32 #include <cmmanager.h>
       
    33 #include <cmpluginwlandef.h>
       
    34 #include <EapGeneralSettings.h>
       
    35 #include <eapqtplugininfo.h>
       
    36 #include <eapqtcertificateinfo.h>
       
    37 
       
    38 // User includes
       
    39 #include "cpeapplugininterface.h"
       
    40 #include "eapqtconfiginterface_p.h"
       
    41 #include "eapqtvalidatorpassword.h"
       
    42 #include "eapqtvalidatorusername.h"
       
    43 #include "eapqtvalidatorrealm.h"
       
    44 #include "eapqtvalidatorpacstorepassword.h"
       
    45 #include "eapqtvalidatorpacstorepasswordconfirm.h"
       
    46 
       
    47 /*!
       
    48  *  \class EapQtConfigInterfacePrivate
       
    49  *  \brief Private implementation of EAP QT configuration interface
       
    50  */
       
    51 
       
    52 // External function prototypes
       
    53 
       
    54 // Local constants
       
    55 static const QString eapTranslationFile("cpeapuiplugins");
       
    56 
       
    57 // ======== LOCAL FUNCTIONS ========
       
    58 
       
    59 // ======== MEMBER FUNCTIONS ========
       
    60 
       
    61 EapQtConfigInterfacePrivate::EapQtConfigInterfacePrivate() :
       
    62   mValidatorInstance(true),
       
    63   mLastOuterHandle(EapQtPluginHandle::PluginUndefined),
       
    64   mTranslator(NULL),
       
    65   mEapGsIf(NULL), 
       
    66   mEapTypeIf(NULL),
       
    67   mIapId(0),
       
    68   mEapBearer(ELan),
       
    69   mEapDbIndex(EapQtConfigInterface::IapIdUndefined),
       
    70   mEapDbIndexValid(false)
       
    71 {
       
    72     qDebug("EapQtConfigInterfacePrivate() - created validator instance, this = 0x%08x", this);
       
    73 }
       
    74 
       
    75 EapQtConfigInterfacePrivate::EapQtConfigInterfacePrivate(
       
    76     const EapQtConfigInterface::EapBearerType bearerType, const int iapId) :  
       
    77   mValidatorInstance(false),
       
    78   mLastOuterHandle(EapQtPluginHandle::PluginUndefined),
       
    79   mTranslator(NULL), 
       
    80   mEapGsIf(NULL), 
       
    81   mEapTypeIf(NULL),
       
    82   mIapId(iapId),
       
    83   mEapBearer(ELan),
       
    84   mEapDbIndex(EapQtConfigInterface::IapIdUndefined),
       
    85   mEapDbIndexValid(false)
       
    86 {
       
    87     qDebug("EapQtConfigInterfacePrivate() - creating non-validator instance, this = 0x%08x", this);
       
    88 
       
    89     switch (bearerType) {
       
    90     case EapQtConfigInterface::EapBearerTypeVpn:
       
    91         mEapBearer = EVpn;
       
    92         break;
       
    93     default:
       
    94         // All others default to EapQtConfigInterface::EapBearerTypeWlan i.e. ELan
       
    95         mEapBearer = ELan;
       
    96     }
       
    97 
       
    98     if (!setEapDbIndex(iapId)) {
       
    99         qDebug("ERROR: EapQtConfigInterfacePrivate() - setIapId failed, bearer = %d, index = %d",
       
   100             mEapBearer, iapId);
       
   101         shutdown();
       
   102         // throw an exception
       
   103         qt_symbian_throwIfError(KErrNotFound);
       
   104     }
       
   105 
       
   106     // load plugins after everything else is ok
       
   107     qDebug("EapQtConfigInterfacePrivate() - load plugins");
       
   108     loadPlugins();
       
   109 
       
   110     qDebug("EapQtConfigInterfacePrivate() - ends");
       
   111 }
       
   112 
       
   113 EapQtConfigInterfacePrivate::~EapQtConfigInterfacePrivate()
       
   114 {
       
   115     qDebug("EapQtConfigInterfacePrivate::~EapQtConfigInterfacePrivate(), this = 0x%08x", this);
       
   116 
       
   117     shutdown();
       
   118 }
       
   119 
       
   120 void EapQtConfigInterfacePrivate::shutdown()
       
   121 {
       
   122     qDebug("EapQtConfigInterfacePrivate::shutdown(), this = 0x%08x", this);
       
   123 
       
   124     mOuterEapsOn.Close();
       
   125     mOuterEapsOff.Close();
       
   126 
       
   127     // cleanup Ecom
       
   128     REComSession::FinalClose();
       
   129 
       
   130     // mTranslator gets deleted automatically (QScopedPointer)
       
   131     // mEapTypeIf gets deleted automatically (QScopedPointer)
       
   132     // mEapGsIf gets deleted automatically (QScopedPointer)
       
   133 }
       
   134 
       
   135 bool EapQtConfigInterfacePrivate::setConfigurationReference(const int iapId)
       
   136 {
       
   137     qDebug("EapQtConfigInterfacePrivate::setConfigurationReference - requested id: %d, this = 0x%08x", iapId, this);
       
   138 
       
   139     checkInstanceThrowing();
       
   140     return setEapDbIndex(iapId);
       
   141 }
       
   142 
       
   143 bool EapQtConfigInterfacePrivate::setEapDbIndex(const int iapId)
       
   144 {
       
   145 
       
   146     qDebug("EapQtConfigInterfacePrivate::setIapId - requested id: %d, this = 0x%08x", iapId, this);
       
   147 
       
   148 
       
   149     // optimization: do not re-create the interface if the reference does
       
   150     // not change and mEapGsIf exists already
       
   151 
       
   152     // WLAN reference is checked after setEapWlanDbIndex below since iapId may be
       
   153     // different than WLAN service ID
       
   154 
       
   155     // case for EapQtConfigInterface::IapIdUndefined i.e. setIapId was called
       
   156     // with a negative id last time and now again
       
   157     if (!mEapDbIndexValid && !mEapGsIf.isNull() && iapId < 0) {
       
   158         qDebug(
       
   159             "EapQtConfigInterfacePrivate::setIapId - interface created for IapIdUndefined already");
       
   160         return true;
       
   161     }
       
   162 
       
   163     // case for VPN (or any other bearer) in which iap id equals EAP db index
       
   164     if (mEapBearer != ELan && mEapDbIndexValid && !mEapGsIf.isNull() && iapId == mEapDbIndex) {
       
   165         qDebug(
       
   166             "EapQtConfigInterfacePrivate::setIapId - interface created for requested IAP ID for VPN already");
       
   167         return true;
       
   168     }
       
   169 
       
   170     // save the current id for checking if WLAN reference changes or not
       
   171     TInt previousEapDbIndex = mEapDbIndex;
       
   172     bool wlanIndexOk = true;
       
   173 
       
   174     // allow accessing certain methods with negative iapId
       
   175     if (iapId < 0) {
       
   176         // set to zero to be able to create EAP server instances
       
   177         mEapDbIndex = 0;
       
   178         mEapDbIndexValid = false;
       
   179     }
       
   180     // for real usage iapId must not be negative
       
   181     else {
       
   182         // for VPN
       
   183         mIapId = iapId;
       
   184         mEapDbIndex = iapId;
       
   185         mEapDbIndexValid = true;
       
   186 
       
   187         // for WLAN
       
   188         if (mEapBearer == ELan) {
       
   189             // get WLAN service ID as the reference
       
   190             mEapDbIndexValid = setEapWlanDbIndex(iapId);
       
   191             wlanIndexOk = mEapDbIndexValid;
       
   192             // do not re-create if the interface is ok for the new (i.e. same) index already
       
   193             if (!mEapGsIf.isNull() && mEapDbIndex == previousEapDbIndex) {
       
   194                 qDebug() << "EapQtConfigInterfacePrivate::setIapId - interface"
       
   195                     << "created for requested IAP ID for WLAN already";
       
   196                 return true;
       
   197             }
       
   198 
       
   199         }
       
   200     }
       
   201 
       
   202     // delete possibly existing instances
       
   203     mEapGsIf.reset(NULL);
       
   204     mEapTypeIf.reset(NULL);
       
   205 
       
   206     mCurrentServerEapType = *EapExpandedTypeNone.GetType();
       
   207     mLastOuterHandle = EapQtPluginHandle::PluginUndefined;
       
   208 
       
   209     if (!wlanIndexOk && mEapBearer == ELan) {
       
   210         // setEapWlanDbIndex was called and failed
       
   211         qDebug("ERROR: EapQtConfigInterfacePrivate::setIapId() - setEapWlanDbIndex failed");
       
   212         return false;
       
   213     }
       
   214 
       
   215     qDebug(
       
   216         "EapQtConfigInterfacePrivate::setIapId() - calls CEapGeneralSettings::NewL(), bearer = %d, index = %d",
       
   217         mEapBearer, mEapDbIndex);
       
   218 
       
   219     // load EAP general settings interface
       
   220     CEapGeneralSettings* tmp = NULL;
       
   221     TRAPD(err, tmp = CEapGeneralSettings::NewL(mEapBearer, mEapDbIndex));
       
   222     if (err != KErrNone) {
       
   223         qDebug("ERROR: EapQtConfigInterfacePrivate::setIapId - CEapGeneralSettings::NewL() failed");
       
   224         mEapDbIndexValid = false;
       
   225         return false;
       
   226     }
       
   227 
       
   228     // set to the created instance
       
   229     mEapGsIf.reset(tmp);
       
   230 
       
   231     return true;
       
   232 }
       
   233 
       
   234 bool EapQtConfigInterfacePrivate::setEapWlanDbIndex(const int iapId)
       
   235 {
       
   236     qDebug("EapQtConfigInterfacePrivate::setEapWlanDbIndex - requested id: %d, this = 0x%08x", iapId, this);
       
   237 
       
   238     RCmManager cmm;
       
   239     TRAPD(err, cmm.OpenL());
       
   240     if (err != KErrNone) {
       
   241         qDebug("ERROR: EapQtConfigInterfacePrivate::setEapWlanDbIndex - cmm.OpenL() failed",
       
   242             mEapBearer, iapId);
       
   243         mEapDbIndex = EapQtConfigInterface::IapIdUndefined;
       
   244         mIapId = 0;
       
   245         return false;
       
   246     }
       
   247 
       
   248     TRAP(err, mEapDbIndex = cmm.GetConnectionMethodInfoIntL(iapId, CMManager::EWlanServiceId));
       
   249     if (err != KErrNone) {
       
   250         qDebug(
       
   251             "ERROR: EapQtConfigInterfacePrivate::setEapWlanDbIndex - cmm.GetConnectionMethodInfoIntL() failed",
       
   252             mEapBearer, iapId);
       
   253         cmm.Close();
       
   254         mEapDbIndex = EapQtConfigInterface::IapIdUndefined;
       
   255         mIapId = 0;
       
   256         return false;
       
   257     }
       
   258 
       
   259     cmm.Close();
       
   260 
       
   261     qDebug("EapQtConfigInterfacePrivate::setEapWlanDbIndex - obtained WLAN service id: %d",
       
   262         mEapDbIndex);
       
   263 
       
   264     return true;
       
   265 }
       
   266 
       
   267 void EapQtConfigInterfacePrivate::checkInstanceThrowing() const
       
   268 {
       
   269     qDebug() << "EapQtConfigInterfacePrivate::checkInstanceThrowing() - mValidatorInstance:"
       
   270         << mValidatorInstance;
       
   271 
       
   272     if (mValidatorInstance) {
       
   273         qDebug(
       
   274             "ERROR: EapQtConfigInterfacePrivate::checkInstanceThrowing - method not supported by this instance");
       
   275         qt_symbian_throwIfError(KErrNotSupported);
       
   276     }
       
   277 }
       
   278 
       
   279 void EapQtConfigInterfacePrivate::appendEapTypes(const RArray<TEapExpandedType>* const eapTypes,
       
   280     QList<QByteArray>* const eapList)
       
   281 {
       
   282     qDebug("EapQtConfigInterfacePrivate::appendEapTypes(), this = 0x%08x", this);
       
   283 
       
   284     Q_ASSERT(eapTypes);
       
   285     Q_ASSERT(eapList);
       
   286 
       
   287     qDebug("EapQtConfigInterfacePrivate - appendEapTypes, EAP count = %d", eapTypes->Count());
       
   288 
       
   289     QByteArray tmpEap;
       
   290     for (int ind = 0; ind < eapTypes->Count(); ind++) {
       
   291         tmpEap.append(reinterpret_cast<const char*> ((*eapTypes)[ind].GetValue().Ptr()),
       
   292             (*eapTypes)[ind].GetValue().Length());
       
   293         eapList->append(tmpEap);
       
   294         qDebug() << "EapQtConfigInterfacePrivate - appendEapTypes added EAP: " << tmpEap.toHex();
       
   295         tmpEap.clear();
       
   296     }
       
   297 }
       
   298 
       
   299 QList<EapQtPluginInfo> EapQtConfigInterfacePrivate::supportedOuterTypes()
       
   300 {
       
   301     qDebug("EapQtConfigInterfacePrivate::supportedOuterTypes(), this = 0x%08x", this);
       
   302 
       
   303     checkInstanceThrowing();
       
   304 
       
   305     if (mEapGsIf.isNull()) {
       
   306         qDebug("ERROR: EapQtConfigInterfacePrivate::supportedOuterTypes() - mEapGsIf is NULL");
       
   307         mOuterEapsOn.Reset();
       
   308         mOuterEapsOff.Reset();
       
   309         // return empty list
       
   310         mSupportedOuterTypes.clear();
       
   311         return mSupportedOuterTypes;
       
   312     }
       
   313 
       
   314     // get outer EAPs from EAP server,
       
   315     // returned in two lists: enabled and disabled outer EAPs
       
   316     // do this always as the list might have changed and mOuterEapsOn/Off are needed in
       
   317     // other methods
       
   318 
       
   319     mOuterEapsOn.Reset();
       
   320     mOuterEapsOff.Reset();
       
   321 
       
   322     qDebug("EapQtConfigInterfacePrivate::supportedOuterTypes() - calls GetEapMethods()");
       
   323 
       
   324     TUint err = mEapGsIf->GetEapMethods(mOuterEapsOn, mOuterEapsOff);
       
   325     if (err != KErrNone) {
       
   326         qDebug("ERROR: EapQtConfigInterfacePrivate::supportedOuterTypes() - GetEapMethods failed");
       
   327         mOuterEapsOn.Reset();
       
   328         mOuterEapsOff.Reset();
       
   329         // return empty list
       
   330         mSupportedOuterTypes.clear();
       
   331         return mSupportedOuterTypes;
       
   332     }
       
   333 
       
   334     // optimization: collect the list only once per instance life time
       
   335     // since no new EAPs will appear to the combination of mOuterEapsOn and mOuterEapsOff
       
   336     if (mSupportedOuterTypes.count() > 0) {
       
   337         qDebug(
       
   338             "EapQtConfigInterfacePrivate - supportedOuterTypes: supported EAPs already listed, return stored list");
       
   339         return mSupportedOuterTypes;
       
   340     }
       
   341 
       
   342     qDebug("EapQtConfigInterfacePrivate - supportedOuterTypes: copy response to QList");
       
   343 
       
   344     // copy response to qlist for easier comparison
       
   345     QList<QByteArray> outerEaps;
       
   346 
       
   347     appendEapTypes(&mOuterEapsOn, &outerEaps);
       
   348     appendEapTypes(&mOuterEapsOff, &outerEaps);
       
   349 
       
   350     qDebug("EapQtConfigInterfacePrivate - supportedOuterTypes: EAP server outer type count: %d",
       
   351         outerEaps.count());
       
   352 
       
   353     qDebug("EapQtConfigInterfacePrivate - supportedOuterTypes: collected UI plugin count: %d",
       
   354         mPluginInfos.count());
       
   355 
       
   356     // set mSupportedOuterTypes to contain only EAPs that both UI and EAP server support
       
   357     QByteArray tmpEap;
       
   358     for (int ind = 0; ind < mPluginInfos.count(); ind++) {
       
   359         tmpEap = mPluginInfos[ind].pluginHandle().type().eapExpandedData();
       
   360         if (outerEaps.contains(tmpEap)) {
       
   361             mSupportedOuterTypes.append(mPluginInfos[ind]);
       
   362             qDebug() << "EapQtConfigInterfacePrivate - supportedOuterTypes: appended EAP: "
       
   363                 << tmpEap.toHex();
       
   364         }
       
   365     }
       
   366 
       
   367     // sort the list
       
   368     qSort(mSupportedOuterTypes.begin(), mSupportedOuterTypes.end(),
       
   369         EapQtConfigInterfacePrivate::pluginLessThan);
       
   370 
       
   371     qDebug("EapQtConfigInterfacePrivate - supportedOuterTypes: supported EAP count: %d",
       
   372         mSupportedOuterTypes.count());
       
   373 
       
   374     return mSupportedOuterTypes;
       
   375 }
       
   376 
       
   377 // checks if UI plugins support supplied eapType and returns the
       
   378 // index (in mPluginInfos) of the supporting plugin
       
   379 bool EapQtConfigInterfacePrivate::isUiSupported(const QByteArray &eapType, int &pluginIndex) const
       
   380 {
       
   381     qDebug("EapQtConfigInterfacePrivate::isUiSupported(), this = 0x%08x", this);
       
   382 
       
   383     bool ret = false;
       
   384     for (int ind = 0; ind < mPluginInfos.count(); ind++) {
       
   385         qDebug("EapQtConfigInterfacePrivate::isUiSupported() - checking index: %d", ind);
       
   386         pluginIndex = ind;
       
   387         if (eapType == mPluginInfos[ind].pluginHandle().type().eapExpandedData()) {
       
   388             qDebug("EapQtConfigInterfacePrivate::isUiSupported() - ui supported!");
       
   389             ret = true;
       
   390             break;
       
   391         }
       
   392     }
       
   393     return ret;
       
   394 }
       
   395 
       
   396 QList<EapQtPluginInfo> EapQtConfigInterfacePrivate::supportedInnerTypes(
       
   397     const EapQtPluginHandle &outer)
       
   398 {
       
   399     qDebug("EapQtConfigInterfacePrivate::supportedInnerTypes(), this = 0x%08x", this);
       
   400 
       
   401     checkInstanceThrowing();
       
   402 
       
   403     // check if we already have up-to-date data
       
   404     if (mLastOuterHandle == outer) {
       
   405         return mSupportedInnerTypes;
       
   406     }
       
   407 
       
   408     // clear previous query result
       
   409     mSupportedInnerTypes.clear();
       
   410     mLastOuterHandle = EapQtPluginHandle::PluginUndefined;
       
   411 
       
   412     qDebug()
       
   413         << "EapQtConfigInterfacePrivate::supportedInnerTypes() - calls isSupportedOuterType for: "
       
   414         << outer.type().eapExpandedData().toHex();
       
   415 
       
   416     // check if the queried outer EAP is supported
       
   417     if (!isSupportedOuterType(outer)) {
       
   418         qDebug()
       
   419             << "ERROR: EapQtConfigInterfacePrivate::supportedInnerTypes() - queried outer type not supported: "
       
   420             << outer.type().eapExpandedData().toHex();
       
   421         // return empty list
       
   422         return mSupportedInnerTypes;
       
   423     }
       
   424 
       
   425     qDebug("EapQtConfigInterfacePrivate::supportedInnerTypes() - calls getEapTypeIf");
       
   426 
       
   427     // get outer EAP settings interface
       
   428     getEapTypeIf(outer);
       
   429     if (mEapTypeIf.isNull()) {
       
   430         qDebug("ERROR: EapQtConfigInterfacePrivate::supportedInnerTypes() - getEapTypeIf failed");
       
   431         // return empty list
       
   432         return mSupportedInnerTypes;
       
   433     }
       
   434 
       
   435     // get outer EAP settings
       
   436     EAPSettings eapSettings;
       
   437     TRAPD(err, mEapTypeIf->GetConfigurationL(eapSettings));
       
   438     // getEapTypeIf has set mCurrentServerEapType correctly for comparison
       
   439     if (err != KErrNone || eapSettings.iEAPExpandedType != mCurrentServerEapType) {
       
   440         qDebug()
       
   441             << "ERROR: EapQtConfigInterfacePrivate::supportedInnerTypes - GetConfigurationL failed, code:"
       
   442             << err;
       
   443         // clear the instance so that the next attempt starts from scratch
       
   444         mEapTypeIf.reset(NULL);
       
   445         // return empty list
       
   446         return mSupportedInnerTypes;
       
   447     }
       
   448 
       
   449     // store inner EAPs supported by EAP server
       
   450     QList<QByteArray> innerEaps;
       
   451     appendEapTypes(&(eapSettings.iEnabledEncapsulatedEAPExpandedTypes), &innerEaps);
       
   452     appendEapTypes(&(eapSettings.iDisabledEncapsulatedEAPExpandedTypes), &innerEaps);
       
   453 
       
   454     int pluginIndex = 0;
       
   455     for (int ind = 0; ind < innerEaps.count(); ind++) {
       
   456         // report only EAPs which do have an UI plugin
       
   457         if (isUiSupported(innerEaps[ind], pluginIndex)) {
       
   458             mSupportedInnerTypes.append(mPluginInfos[pluginIndex]);
       
   459             qDebug() << "EapQtConfigInterfacePrivate::supportedInnerTypes - added inner EAP: "
       
   460                 << innerEaps[ind].toHex();
       
   461         }
       
   462     }
       
   463 
       
   464     mLastOuterHandle = outer;
       
   465 
       
   466     // sort the list
       
   467     qSort(mSupportedInnerTypes.begin(), mSupportedInnerTypes.end(),
       
   468         EapQtConfigInterfacePrivate::pluginLessThan);
       
   469 
       
   470     qDebug("EapQtConfigInterfacePrivate - supportedInnerTypes: supported EAP count: %d",
       
   471         mSupportedInnerTypes.count());
       
   472 
       
   473     return mSupportedInnerTypes;
       
   474 }
       
   475 
       
   476 void EapQtConfigInterfacePrivate::copyCertificateInfo(
       
   477     const RPointerArray<EapCertificateEntry>* const certEntries,
       
   478     QList<EapQtCertificateInfo>* const certInfos)
       
   479 {
       
   480     qDebug("EapQtConfigInterfacePrivate::copyCertificateInfo(), this = 0x%08x", this);
       
   481 
       
   482     Q_ASSERT(certEntries);
       
   483     Q_ASSERT(certInfos);
       
   484 
       
   485     certInfos->clear();
       
   486 
       
   487     EapQtCertificateInfo cert;
       
   488     TKeyIdentifier subjectKeyId;
       
   489     const TDes* text = 0;
       
   490     int ind = 0;
       
   491 
       
   492     for (ind = 0; ind < certEntries->Count(); ind++) {
       
   493 
       
   494         // cleanup cert
       
   495         cert.clear();
       
   496 
       
   497         EapCertificateEntry* certPtr = (*certEntries)[ind];
       
   498 
       
   499         qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo *** certificate starts *** ";
       
   500 
       
   501         if (certPtr->GetSubjectNamePresent() != EFalse) {
       
   502 
       
   503             text = certPtr->GetSubjectName();
       
   504             cert.setValue(EapQtCertificateInfo::SubjectName, QString::fromUtf16(text->Ptr(),
       
   505                 text->Length()));
       
   506 
       
   507             qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo SubjectName: "
       
   508                 << QString::fromUtf16(text->Ptr(), text->Length());
       
   509         }
       
   510         if (certPtr->GetIssuerNamePresent() != EFalse) {
       
   511 
       
   512             text = certPtr->GetIssuerName();
       
   513             cert.setValue(EapQtCertificateInfo::IssuerName, QString::fromUtf16(text->Ptr(),
       
   514                 text->Length()));
       
   515 
       
   516             qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo IssuerName: "
       
   517                 << QString::fromUtf16(text->Ptr(), text->Length());
       
   518         }
       
   519         if (certPtr->GetSerialNumberPresent() != EFalse) {
       
   520 
       
   521             text = certPtr->GetSerialNumber();
       
   522             cert.setValue(EapQtCertificateInfo::SerialNumber, QString::fromUtf16(text->Ptr(),
       
   523                 text->Length()));
       
   524 
       
   525             qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo SerialNumber: "
       
   526                 << QString::fromUtf16(text->Ptr(), text->Length());
       
   527         }
       
   528         if (certPtr->GetSubjectKeyIdPresent() != EFalse) {
       
   529 
       
   530             subjectKeyId = certPtr->GetSubjectKeyId();
       
   531             cert.setValue(EapQtCertificateInfo::SubjectKeyId, QByteArray(
       
   532                 reinterpret_cast<const char*> (subjectKeyId.Ptr()), subjectKeyId.Length()));
       
   533 
       
   534             qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo SubjectKeyId: "
       
   535                 << (QByteArray(reinterpret_cast<const char*> (subjectKeyId.Ptr()),
       
   536                     subjectKeyId.Length())).toHex();
       
   537         }
       
   538         if (certPtr->GetThumbprintPresent() != EFalse) {
       
   539 
       
   540             text = certPtr->GetThumbprint();
       
   541             cert.setValue(EapQtCertificateInfo::ThumbPrint, QString::fromUtf16(text->Ptr(),
       
   542                 text->Length()));
       
   543 
       
   544             qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo ThumbPrint: "
       
   545                 << QString::fromUtf16(text->Ptr(), text->Length());
       
   546         }
       
   547         if (certPtr->GetLabelPresent() != EFalse) {
       
   548 
       
   549             text = certPtr->GetLabel();
       
   550             cert.setValue(EapQtCertificateInfo::CertificateLabel, QString::fromUtf16(text->Ptr(),
       
   551                 text->Length()));
       
   552 
       
   553             qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo CertificateLabel: "
       
   554                 << QString::fromUtf16(text->Ptr(), text->Length());
       
   555         }
       
   556 
       
   557         qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo *** certificate ends *** ";
       
   558 
       
   559         certInfos->append(cert);
       
   560 
       
   561     }
       
   562 }
       
   563 
       
   564 bool EapQtConfigInterfacePrivate::fetchCertificates(QList<EapQtCertificateInfo>* const caInfos,
       
   565     QList<EapQtCertificateInfo>* const clientInfos)
       
   566 {
       
   567     qDebug("EapQtConfigInterfacePrivate::fetchCertificates(), this = 0x%08x", this);
       
   568 
       
   569     Q_ASSERT(caInfos != NULL || clientInfos != NULL);
       
   570     Q_ASSERT(!mEapGsIf.isNull());
       
   571 
       
   572     TInt err(KErrNone);
       
   573     RPointerArray<EapCertificateEntry> clientCerts;
       
   574     RPointerArray<EapCertificateEntry> caCerts;
       
   575 
       
   576     err = mEapGsIf->GetCertificateLists(clientCerts, caCerts);
       
   577     if (err != KErrNone) {
       
   578         qDebug("EapQtConfigInterfacePrivate - fetchCertificates failed: %d", err);
       
   579         caCerts.ResetAndDestroy();
       
   580         clientCerts.ResetAndDestroy();
       
   581         return false;
       
   582     }
       
   583 
       
   584     qDebug("user cert count: %d, CA cert count: %d", clientCerts.Count(), caCerts.Count());
       
   585 
       
   586     if (caInfos != NULL) {
       
   587         copyCertificateInfo(&caCerts, caInfos);
       
   588     }
       
   589     if (clientInfos != NULL) {
       
   590         copyCertificateInfo(&clientCerts, clientInfos);
       
   591     }
       
   592 
       
   593     caCerts.ResetAndDestroy();
       
   594     clientCerts.ResetAndDestroy();
       
   595     return true;
       
   596 }
       
   597 
       
   598 bool EapQtConfigInterfacePrivate::updateCertificates() {
       
   599 
       
   600     qDebug("EapQtConfigInterfacePrivate::updateCertificates(), this = 0x%08x", this);
       
   601 
       
   602     checkInstanceThrowing();
       
   603 
       
   604     // empty current state
       
   605     mCaCertificates.clear();
       
   606     mUserCertificates.clear();
       
   607 
       
   608     return fetchCertificates(&mCaCertificates, &mUserCertificates);
       
   609 }
       
   610 
       
   611 QList<EapQtCertificateInfo> EapQtConfigInterfacePrivate::certificateAuthorityCertificates()
       
   612 {
       
   613     qDebug("EapQtConfigInterfacePrivate::certificateAuthorityCertificates(), this = 0x%08x", this);
       
   614 
       
   615     checkInstanceThrowing();
       
   616 
       
   617     // update only if the list is empty
       
   618     if(mCaCertificates.length() == 0) {
       
   619         qDebug() << "EapQtConfigInterfacePrivate::certificateAuthorityCertificates() - updates certificate lists";
       
   620         updateCertificates();
       
   621     }
       
   622 
       
   623     return mCaCertificates;
       
   624 }
       
   625 
       
   626 QList<EapQtCertificateInfo> EapQtConfigInterfacePrivate::userCertificates()
       
   627 {
       
   628     qDebug("EapQtConfigInterfacePrivate::userCertificates(), this = 0x%08x", this);
       
   629 
       
   630     // use the CA certificates method, it will update both the lists
       
   631     // if CA list is empty
       
   632     (void) certificateAuthorityCertificates();
       
   633     return mUserCertificates;
       
   634 }
       
   635 
       
   636 void EapQtConfigInterfacePrivate::getEapTypeIf(const EapQtPluginHandle &pluginHandle)
       
   637 {
       
   638     qDebug("EapQtConfigInterfacePrivate::getEapTypeIf(), this = 0x%08x", this);
       
   639 
       
   640     // dig up the EAP type in TEapExpandedType format
       
   641     TEapExpandedType eapServerType;
       
   642     QByteArray eapType = pluginHandle.type().eapExpandedData();
       
   643     TInt err(KErrNone);
       
   644 
       
   645     qDebug() << "EapQtConfigInterfacePrivate - getEapTypeIf: wanted EAP type: " << eapType.toHex();
       
   646 
       
   647     // no need to check if this is successful,
       
   648     // CEapType::NewL call will handle errors
       
   649     (void) eapServerType.SetValue(eapType.data(), eapType.length());
       
   650 
       
   651     // slight optimization, load interface only if it does not exist or the EAP type changes
       
   652     if (mEapTypeIf.isNull() || mCurrentServerEapType != eapServerType) {
       
   653 
       
   654         qDebug("EapQtConfigInterfacePrivate - getEapTypeIf deletes previous instance");
       
   655 
       
   656         // delete previous instance
       
   657         mEapTypeIf.reset(NULL);
       
   658         mCurrentServerEapType = eapServerType;
       
   659 
       
   660         qDebug("EapQtConfigInterfacePrivate - getEapTypeIf calls CEapType::NewL()");
       
   661 
       
   662         // trap all leaves
       
   663         CEapType* tmp = NULL;
       
   664         TRAP(err, tmp = CEapType::NewL(mEapBearer, mEapDbIndex, mCurrentServerEapType));
       
   665         if (err != KErrNone) {
       
   666             qDebug(
       
   667                 "ERROR: EapQtConfigInterfacePrivate - getEapTypeIf CEapType::NewL failed with error: %d",
       
   668                 err);
       
   669             mCurrentServerEapType = *EapExpandedTypeNone.GetType();
       
   670         }
       
   671         mEapTypeIf.reset(tmp);
       
   672     }
       
   673 
       
   674     // always clear the tunnelling type state just in case some earlier call has set it
       
   675     if (!mEapTypeIf.isNull()) {
       
   676         mEapTypeIf->SetTunnelingType(*EapExpandedTypeNone.GetType());
       
   677     }
       
   678 
       
   679 }
       
   680 
       
   681 // in config:
       
   682 // if OuterType is defined, the configuration for pluginHandle is set inside this OuterType
       
   683 // if OuterType is not defined, pluginHandle is for an outer type
       
   684 // if InnerType is defined, the defined inner types in config are activated for pluginHandle
       
   685 // if InnerType is not defined, the pluginHandle does not activate any inner type (or they do not exist)
       
   686 bool EapQtConfigInterfacePrivate::saveConfiguration(const EapQtPluginHandle &pluginHandle,
       
   687     const EapQtConfig &config)
       
   688 {
       
   689     qDebug("EapQtConfigInterfacePrivate::saveConfiguration(), this = 0x%08x", this);
       
   690 
       
   691     checkInstanceThrowing();
       
   692 
       
   693     if (!mEapDbIndexValid) {
       
   694         qDebug() << "ERROR: Database reference not valid, call setConfigurationReference first!";
       
   695         return false;
       
   696     }
       
   697 
       
   698     // set tunneling type & check if the requested EAP is supported
       
   699     // if we are configuring outer type, OuterType == QVariant::Invalid or
       
   700     // EapQtPluginHandle::PluginUndefined
       
   701 
       
   702     EapQtPluginHandle tmpOuterHandle;
       
   703     QVariant varValue = config.value(EapQtConfig::OuterType);
       
   704     if (varValue != QVariant::Invalid && !(varValue.value<EapQtPluginHandle> () == EapQtPluginHandle::PluginUndefined)) {
       
   705         tmpOuterHandle = varValue.value<EapQtPluginHandle> ();
       
   706         // check if supported
       
   707         if(!isSupportedInnerType(tmpOuterHandle, pluginHandle)) {
       
   708             qDebug("ERROR: EapQtConfigInterfacePrivate::saveConfiguration() - not supported outer/inner type combination");
       
   709             return false;
       
   710         }
       
   711     }
       
   712     else {
       
   713         tmpOuterHandle = EapQtPluginHandle::PluginUndefined;
       
   714         // check if supported
       
   715         if(!isSupportedOuterType(pluginHandle)) {
       
   716             qDebug("ERROR: EapQtConfigInterfacePrivate::saveConfiguration() - not supported outer type");
       
   717             return false;
       
   718         }
       
   719     }
       
   720 
       
   721     getEapTypeIf(pluginHandle);
       
   722     if (mEapTypeIf.isNull()) {
       
   723         qDebug("ERROR: EapQtConfigInterfacePrivate::saveConfiguration() - getEapTypeIf failed");
       
   724         return false;
       
   725     }
       
   726 
       
   727     TEapExpandedType tmpOuterEap;
       
   728     tmpOuterEap.SetValue(tmpOuterHandle.type().eapExpandedData().data(),
       
   729         tmpOuterHandle.type().eapExpandedData().length());
       
   730 
       
   731     qDebug() << "EapQtConfigInterfacePrivate::saveConfiguration() - sets tunnelling type to: "
       
   732         << tmpOuterHandle.type().eapExpandedData().toHex();
       
   733 
       
   734     mEapTypeIf->SetTunnelingType(tmpOuterEap);
       
   735 
       
   736     // set EAP type here
       
   737     QByteArray eapType = pluginHandle.type().eapExpandedData();
       
   738 
       
   739     // copy config to EAP settings,
       
   740     // no need to check if this is successful,
       
   741     // SetConfigurationL call will handle errors
       
   742     EAPSettings eapSettings;
       
   743     (void) eapSettings.iEAPExpandedType.SetValue(eapType.data(), eapType.length());
       
   744 
       
   745     // copy the rest of the settings in the function
       
   746     copyToEapSettings(config, eapSettings);
       
   747     // store settings
       
   748     TRAPD(err, mEapTypeIf->SetConfigurationL(eapSettings));
       
   749     if (err != KErrNone) {
       
   750         qDebug("ERROR: EapQtConfigInterfacePrivate - saveConfiguration: SetConfigurationL failed");
       
   751         // clear the instance so that the next attempt starts from scratch
       
   752         mEapTypeIf.reset(NULL);
       
   753         mCurrentServerEapType = *EapExpandedTypeNone.GetType();
       
   754         return false;
       
   755     }
       
   756 
       
   757     return true;
       
   758 }
       
   759 
       
   760 // config must be empty when calling
       
   761 bool EapQtConfigInterfacePrivate::readConfiguration(const EapQtPluginHandle &outerHandle,
       
   762     const EapQtPluginHandle &pluginHandle, EapQtConfig &config)
       
   763 {
       
   764     qDebug("EapQtConfigInterfacePrivate::readConfiguration(), this = 0x%08x", this);
       
   765 
       
   766     // clear input
       
   767     config.clear();
       
   768 
       
   769     checkInstanceThrowing();
       
   770 
       
   771     if (!mEapDbIndexValid) {
       
   772         qDebug() << "ERROR: Database reference not valid, call setConfigurationReference first!";
       
   773         return false;
       
   774     }
       
   775 
       
   776     // check EAP type support
       
   777     if(!(outerHandle == EapQtPluginHandle::PluginUndefined)) {
       
   778         if(!isSupportedInnerType(outerHandle, pluginHandle)) {
       
   779             qDebug("ERROR: EapQtConfigInterfacePrivate::readConfiguration() - not supported outer/inner type combination");
       
   780             return false;
       
   781         }
       
   782     } else {
       
   783         if(!isSupportedOuterType(pluginHandle)) {
       
   784             qDebug("ERROR: EapQtConfigInterfacePrivate::readConfiguration() - not supported outer type");
       
   785             return false;
       
   786         }
       
   787     }
       
   788 
       
   789     getEapTypeIf(pluginHandle);
       
   790     if (mEapTypeIf.isNull()) {
       
   791         qDebug("ERROR: EapQtConfigInterfacePrivate::readConfiguration - getEapTypeIf failed");
       
   792         return false;
       
   793     }
       
   794 
       
   795     // set tunneling type
       
   796     // if we are configuring outer type, outerHandle == EapQtPluginHandle::PluginUndefined
       
   797     // and calling SetTunnelingType is also ok
       
   798     TEapExpandedType tmpEap;
       
   799     tmpEap.SetValue(outerHandle.type().eapExpandedData().data(),
       
   800         outerHandle.type().eapExpandedData().length());
       
   801 
       
   802     qDebug() << "EapQtConfigInterfacePrivate::readConfiguration - sets tunnelling type to: "
       
   803         << outerHandle.type().eapExpandedData().toHex();
       
   804 
       
   805     mEapTypeIf->SetTunnelingType(tmpEap);
       
   806 
       
   807     // always set OuterType,
       
   808     // set to EapQtPluginHandle::PluginUndefined if no outer type specified
       
   809     config.setValue(EapQtConfig::OuterType, qVariantFromValue(outerHandle));
       
   810 
       
   811     qDebug("EapQtConfigInterfacePrivate::readConfiguration - calls GetConfigurationL()");
       
   812 
       
   813     // trap all leaves
       
   814     EAPSettings eapSettings;
       
   815     TRAPD(err, mEapTypeIf->GetConfigurationL(eapSettings));
       
   816 
       
   817     // check if failed or something strange happened (incorrect EAP type settings received)  
       
   818     if (err != KErrNone || eapSettings.iEAPExpandedType != mCurrentServerEapType) {
       
   819         qDebug()
       
   820             << "ERROR: EapQtConfigInterfacePrivate - readConfiguration: GetConfigurationL failed"
       
   821             << "wanted EAP:" << pluginHandle.type().eapExpandedData().toHex()
       
   822             << "- got EAP vendor ID:" << eapSettings.iEAPExpandedType.GetVendorId()
       
   823             << ", vendor type" << eapSettings.iEAPExpandedType.GetVendorType() << ", error code:"
       
   824             << err;
       
   825         // clear the instance so that the next attempt starts from scratch
       
   826         mEapTypeIf.reset(NULL);
       
   827         mCurrentServerEapType = *EapExpandedTypeNone.GetType();
       
   828         // nothing to be set to config
       
   829         return false;
       
   830     }
       
   831     copyFromEapSettings(eapSettings, config);
       
   832     return true;
       
   833 }
       
   834 
       
   835 bool EapQtConfigInterfacePrivate::convertToBool(TBool value)
       
   836 {
       
   837     return (value != EFalse ? true : false);
       
   838 }
       
   839 
       
   840 TBool EapQtConfigInterfacePrivate::convertToTbool(bool value)
       
   841 {
       
   842     return (value ? ETrue : EFalse);
       
   843 }
       
   844 
       
   845 void EapQtConfigInterfacePrivate::copyToEapSettings(const EapQtConfig &config, EAPSettings &eapSettings)
       
   846 {
       
   847     qDebug("EapQtConfigInterfacePrivate::copyToEapSettings(), this = 0x%08x", this);
       
   848 
       
   849     int ind = 0;
       
   850 
       
   851     QVariant varValue = config.value(EapQtConfig::UsernameAutomatic);
       
   852     if (varValue.type() == QVariant::Bool) {
       
   853         eapSettings.iUseAutomaticUsernamePresent = ETrue;
       
   854         eapSettings.iUseAutomaticUsername = convertToTbool(varValue.toBool());
       
   855         qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings UsernameAutomatic: "
       
   856             << varValue.toBool();
       
   857     }
       
   858 
       
   859     varValue = config.value(EapQtConfig::AuthorityCertificateAutomatic);
       
   860     if (varValue.type() == QVariant::Bool) {
       
   861         eapSettings.iUseAutomaticCACertificatePresent = ETrue;
       
   862         eapSettings.iUseAutomaticCACertificate = convertToTbool(varValue.toBool());
       
   863         qDebug()
       
   864             << "EapQtConfigInterfacePrivate - copyToEapSettings AuthorityCertificateAutomatic: "
       
   865             << varValue.toBool();
       
   866     }
       
   867 
       
   868     varValue = config.value(EapQtConfig::Username);
       
   869     // do not copy if too large string
       
   870     if (varValue.type() == QVariant::String && varValue.toString().count() <= StringMaxLength) {
       
   871         // QString::utf16 returns a null terminated string
       
   872         eapSettings.iUsername.Copy(varValue.toString().utf16());
       
   873         eapSettings.iUsernamePresent = ETrue;
       
   874         qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings Username: "
       
   875             << varValue.toString();
       
   876     }
       
   877 
       
   878     varValue = config.value(EapQtConfig::PasswordPrompt);
       
   879     if (varValue.type() == QVariant::Bool) {
       
   880         eapSettings.iShowPassWordPromptPresent = ETrue;
       
   881         eapSettings.iShowPassWordPrompt = convertToTbool(varValue.toBool());
       
   882         qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings PasswordPrompt: "
       
   883             << varValue.toBool();
       
   884     }
       
   885 
       
   886     varValue = config.value(EapQtConfig::Password);
       
   887     // do not copy if too large string
       
   888     if (varValue.type() == QVariant::String && varValue.toString().count() <= StringMaxLength) {
       
   889         //QString::utf16 returns a null terminated string
       
   890         eapSettings.iPassword.Copy(varValue.toString().utf16());
       
   891         eapSettings.iPasswordPresent = ETrue;
       
   892         qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings Password: "
       
   893             << varValue.toString();
       
   894     }
       
   895 
       
   896     varValue = config.value(EapQtConfig::PasswordClear);
       
   897     if (varValue.type() == QVariant::Bool) {
       
   898         eapSettings.iPasswordExistPresent = ETrue;
       
   899         // eapSettings.iPasswordExist = false cleans the password from database, true does nothing
       
   900         eapSettings.iPasswordExist = convertToTbool(!varValue.toBool());
       
   901         qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings PasswordClear: "
       
   902             << varValue.toBool();
       
   903     }
       
   904 
       
   905     varValue = config.value(EapQtConfig::RealmAutomatic);
       
   906     if (varValue.type() == QVariant::Bool) {
       
   907         eapSettings.iUseAutomaticRealmPresent = ETrue;
       
   908         eapSettings.iUseAutomaticRealm = convertToTbool(varValue.toBool());
       
   909         qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings RealmAutomatic: "
       
   910             << varValue.toBool();
       
   911     }
       
   912 
       
   913     varValue = config.value(EapQtConfig::Realm);
       
   914     // do not copy if too large string
       
   915     if (varValue.type() == QVariant::String && varValue.toString().count() <= StringMaxLength) {
       
   916         // QString::utf16 returns a null terminated string
       
   917         eapSettings.iRealm.Copy(varValue.toString().utf16());
       
   918         eapSettings.iRealmPresent = ETrue;
       
   919         qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings Realm: "
       
   920             << varValue.toString();
       
   921     }
       
   922 
       
   923     varValue = config.value(EapQtConfig::UsePseudonyms);
       
   924     if (varValue.type() == QVariant::Bool) {
       
   925         eapSettings.iUsePseudonymsPresent = ETrue;
       
   926         eapSettings.iUsePseudonyms = convertToTbool(varValue.toBool());
       
   927         qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings UsePseudonyms: "
       
   928             << varValue.toBool();
       
   929     }
       
   930 
       
   931     varValue = config.value(EapQtConfig::VerifyServerRealm);
       
   932     if (varValue.type() == QVariant::Bool) {
       
   933         eapSettings.iVerifyServerRealmPresent = ETrue;
       
   934         eapSettings.iVerifyServerRealm = convertToTbool(varValue.toBool());
       
   935         qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings VerifyServerRealm: "
       
   936             << varValue.toBool();
       
   937     }
       
   938 
       
   939     varValue = config.value(EapQtConfig::ClientAuthenticationRequired);
       
   940     if (varValue.type() == QVariant::Bool) {
       
   941         eapSettings.iRequireClientAuthenticationPresent = ETrue;
       
   942         eapSettings.iRequireClientAuthentication = convertToTbool(varValue.toBool());
       
   943         qDebug()
       
   944             << "EapQtConfigInterfacePrivate - copyToEapSettings ClientAuthenticationRequired: "
       
   945             << varValue.toBool();
       
   946     }
       
   947 
       
   948     varValue = config.value(EapQtConfig::SessionValidityTime);
       
   949     if (varValue.type() == QVariant::UInt) {
       
   950         eapSettings.iSessionValidityTimePresent = ETrue;
       
   951         eapSettings.iSessionValidityTime = varValue.toUInt();
       
   952         qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings SessionValidityTime: "
       
   953             << varValue.toUInt();
       
   954     }
       
   955 
       
   956     varValue = config.value(EapQtConfig::PeapVersion0Allowed);
       
   957     if (varValue.type() == QVariant::Bool) {
       
   958         eapSettings.iPEAPVersionsPresent = ETrue;
       
   959         eapSettings.iPEAPv0Allowed = convertToTbool(varValue.toBool());
       
   960         qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings PeapVersion0Allowed: "
       
   961             << varValue.toBool();
       
   962     } else {
       
   963         // in any other case disable PEAP version;
       
   964         // no need to set eapSettings.iPEAPVersionsPresent,
       
   965         // it will be set if one of the other PEAP versions is enabled,
       
   966         // otherwise this setting is redundant and can be ignored
       
   967         eapSettings.iPEAPv0Allowed = EFalse;
       
   968     }
       
   969 
       
   970     varValue = config.value(EapQtConfig::PeapVersion1Allowed);
       
   971     if (varValue.type() == QVariant::Bool) {
       
   972         eapSettings.iPEAPVersionsPresent = ETrue;
       
   973         eapSettings.iPEAPv1Allowed = convertToTbool(varValue.toBool());
       
   974         qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings PeapVersion1Allowed: "
       
   975             << varValue.toBool();
       
   976     } else {
       
   977         // in any other case disable PEAP version;
       
   978         // no need to set eapSettings.iPEAPVersionsPresent,
       
   979         // it will be set if one of the other PEAP versions is enabled,
       
   980         // otherwise this setting is redundant and can be ignored
       
   981         eapSettings.iPEAPv1Allowed = EFalse;
       
   982     }
       
   983 
       
   984     varValue = config.value(EapQtConfig::PeapVersion2Allowed);
       
   985     if (varValue.type() == QVariant::Bool) {
       
   986         eapSettings.iPEAPVersionsPresent = ETrue;
       
   987         eapSettings.iPEAPv2Allowed = convertToTbool(varValue.toBool());
       
   988         qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings PeapVersion2Allowed: "
       
   989             << varValue.toBool();
       
   990     } else {
       
   991         // in any other case disable PEAP version;
       
   992         // no need to set eapSettings.iPEAPVersionsPresent,
       
   993         // it will be set if one of the other PEAP versions is enabled,
       
   994         // otherwise this setting is redundant and can be ignored
       
   995         eapSettings.iPEAPv2Allowed = EFalse;
       
   996     }
       
   997 
       
   998     varValue = config.value(EapQtConfig::ProvisioningModeAuthenticated);
       
   999     if (varValue.type() == QVariant::Bool) {
       
  1000         eapSettings.iAuthProvModeAllowedPresent = ETrue;
       
  1001         eapSettings.iAuthProvModeAllowed = convertToTbool(varValue.toBool());
       
  1002         qDebug()
       
  1003             << "EapQtConfigInterfacePrivate - copyToEapSettings ProvisioningModeAuthenticated: "
       
  1004             << varValue.toBool();
       
  1005     }
       
  1006 
       
  1007     varValue = config.value(EapQtConfig::ProvisioningModeUnauthenticated);
       
  1008     if (varValue.type() == QVariant::Bool) {
       
  1009         eapSettings.iUnauthProvModeAllowedPresent = ETrue;
       
  1010         eapSettings.iUnauthProvModeAllowed = convertToTbool(varValue.toBool());
       
  1011         qDebug()
       
  1012             << "EapQtConfigInterfacePrivate - copyToEapSettings ProvisioningModeUnauthenticated: "
       
  1013             << varValue.toBool();
       
  1014     }
       
  1015 
       
  1016     varValue = config.value(EapQtConfig::PACGroupReference);
       
  1017     // do not copy if too large string
       
  1018     if (varValue.type() == QVariant::String && varValue.toString().count() <= StringMaxLength) {
       
  1019         eapSettings.iPACGroupReference.Copy(varValue.toString().utf16());
       
  1020         eapSettings.iPACGroupReferencePresent = ETrue;
       
  1021         qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings PACGroupReference: "
       
  1022             << varValue.toString();
       
  1023     }
       
  1024 
       
  1025     varValue = config.value(EapQtConfig::WarnADHPNoPAC);
       
  1026     if (varValue.type() == QVariant::Bool) {
       
  1027         eapSettings.iWarnADHPNoPACPresent = ETrue;
       
  1028         eapSettings.iWarnADHPNoPAC = convertToTbool(varValue.toBool());
       
  1029         qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings WarnADHPNoPAC: "
       
  1030             << varValue.toBool();
       
  1031     }
       
  1032 
       
  1033     varValue = config.value(EapQtConfig::WarnADHPNoMatchingPAC);
       
  1034     if (varValue.type() == QVariant::Bool) {
       
  1035         eapSettings.iWarnADHPNoMatchingPACPresent = ETrue;
       
  1036         eapSettings.iWarnADHPNoMatchingPAC = convertToTbool(varValue.toBool());
       
  1037         qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings WarnADHPNoMatchingPAC: "
       
  1038             << varValue.toBool();
       
  1039     }
       
  1040 
       
  1041     varValue = config.value(EapQtConfig::WarnNotDefaultServer);
       
  1042     if (varValue.type() == QVariant::Bool) {
       
  1043         eapSettings.iWarnNotDefaultServerPresent = ETrue;
       
  1044         eapSettings.iWarnNotDefaultServer = convertToTbool(varValue.toBool());
       
  1045         qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings WarnNotDefaultServer: "
       
  1046             << varValue.toBool();
       
  1047     }
       
  1048 
       
  1049     varValue = config.value(EapQtConfig::UseIdentityPrivacy);
       
  1050     if (varValue.type() == QVariant::Bool) {
       
  1051         eapSettings.iUseIdentityPrivacyPresent = ETrue;
       
  1052         eapSettings.iUseIdentityPrivacy = convertToTbool(varValue.toBool());
       
  1053         qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings UseIdentityPrivacy: "
       
  1054             << varValue.toBool();
       
  1055     }
       
  1056 
       
  1057     varValue = config.value(EapQtConfig::InnerType);
       
  1058     if (varValue.type() == QVariant::List) {
       
  1059 
       
  1060         // not need to set disable inner types
       
  1061         // EAP server takes care of them internally
       
  1062 
       
  1063         qDebug() << "EapQtConfigInterfacePrivate::copyToEapSettings() - InnerType present";
       
  1064 
       
  1065         QList<QVariant> varList = varValue.toList();
       
  1066         TEapExpandedType tmpEap;
       
  1067         EapQtPluginHandle tmpHandle;
       
  1068         TUint err(KErrNone);
       
  1069 
       
  1070         for (ind = 0; ind < varList.count(); ind++) {
       
  1071             if (varList[ind].canConvert<EapQtPluginHandle> ()) {
       
  1072                 // set to true only if at least one item is ok
       
  1073                 eapSettings.iEnabledEncapsulatedEAPExpandedTypesPresent = ETrue;
       
  1074 
       
  1075                 tmpHandle = varList[ind].value<EapQtPluginHandle> ();
       
  1076                 tmpEap.SetValue(tmpHandle.type().eapExpandedData().data(),
       
  1077                     tmpHandle.type().eapExpandedData().length());
       
  1078                 err = eapSettings.iEnabledEncapsulatedEAPExpandedTypes.Append(tmpEap);
       
  1079                 if(err != KErrNone)
       
  1080                 {
       
  1081                     qDebug() << "ERROR: EapQtConfigInterfacePrivate::copyToEapSettings() - RArray::Append failed for inner types";
       
  1082                     eapSettings.iEnabledEncapsulatedEAPExpandedTypes.Reset();
       
  1083                     // no dynamic memory allocated for tmpEap, just continue with
       
  1084                     // the rest of the settings; EapSettings takes care of deallocations in its destructor
       
  1085                     break;
       
  1086                 }
       
  1087 
       
  1088                 qDebug()
       
  1089                     << "EapQtConfigInterfacePrivate::copyToEapSettings() - Added to InnerType: "
       
  1090                     << tmpHandle.type().eapExpandedData().toHex();
       
  1091             }
       
  1092         }
       
  1093     }
       
  1094 
       
  1095     varValue = config.value(EapQtConfig::CipherSuites);
       
  1096     if (varValue.type() == QVariant::List) {
       
  1097 
       
  1098         qDebug() << "EapQtConfigInterfacePrivate::copyToEapSettings() - CipherSuites present";
       
  1099         QList<QVariant> varCiphers = varValue.toList();
       
  1100 
       
  1101         // clears the ciphersuite configuration if the provided list is empty
       
  1102         eapSettings.iCipherSuitesPresent = ETrue;
       
  1103         TUint err(KErrNone);
       
  1104 
       
  1105         for (ind = 0; ind < varCiphers.count(); ind++) {
       
  1106             // check that the item is of correct type (int also accepted to not be too strict)
       
  1107             if (varCiphers[ind].type() == QVariant::UInt || varCiphers[ind].type() == QVariant::Int) {
       
  1108 
       
  1109                 err = eapSettings.iCipherSuites.Append(varCiphers[ind].toUInt());
       
  1110                 if(err != KErrNone)
       
  1111                 {
       
  1112                     qDebug() << "ERROR: EapQtConfigInterfacePrivate::copyToEapSettings() - RArray::Append failed for ciphersuites";
       
  1113                     eapSettings.iCipherSuites.Reset();
       
  1114                     // continue with the rest of the settings, no dynamic
       
  1115                     // memory allocated for varCiphers[ind].toUInt()
       
  1116                     break;
       
  1117                 }
       
  1118 
       
  1119                 qDebug(
       
  1120                     "EapQtConfigInterfacePrivate::copyToEapSettings() - CipherSuites at %d: 0x%08x",
       
  1121                     ind, varCiphers[ind].toUInt());
       
  1122             }
       
  1123         }
       
  1124     }
       
  1125 
       
  1126     // set always to true to support clearing previously configured CA/user certificates
       
  1127     // if the EAP method in question does not use certificates,
       
  1128     // EAP server will ignore the setting;
       
  1129     // CA/user certificates get cleared if EapQtConfig::Authority/UserCertificate is QVariant::Invalid or
       
  1130     // the provided lists are empty
       
  1131     eapSettings.iCertificatesPresent = ETrue;
       
  1132 
       
  1133     varValue = config.value(EapQtConfig::AuthorityCertificate);
       
  1134     if (varValue.type() == QVariant::List) {
       
  1135 
       
  1136         qDebug()
       
  1137             << "EapQtConfigInterfacePrivate::copyToEapSettings() - AuthorityCertificate present";
       
  1138 
       
  1139         QList<QVariant> varCerts = varValue.toList();
       
  1140         for (ind = 0; ind < varCerts.count(); ind++) {
       
  1141             // check that the item is of correct type
       
  1142             if (varCerts[ind].canConvert<EapQtCertificateInfo> ()) {
       
  1143                 appendCertificateInfo(true, varCerts[ind].value<EapQtCertificateInfo> (),
       
  1144                     &(eapSettings.iCertificates));
       
  1145                 qDebug()
       
  1146                     << "EapQtConfigInterfacePrivate::copyToEapSettings() - AuthorityCertificate appended";
       
  1147             }
       
  1148         }
       
  1149     }
       
  1150 
       
  1151     varValue = config.value(EapQtConfig::UserCertificate);
       
  1152     if (varValue.type() == QVariant::List) {
       
  1153 
       
  1154         qDebug() << "EapQtConfigInterfacePrivate::copyToEapSettings() - UserCertificate present";
       
  1155 
       
  1156         QList<QVariant> varCerts = varValue.toList();
       
  1157         for (ind = 0; ind < varCerts.count(); ind++) {
       
  1158             // check that the item is of correct type
       
  1159             if (varCerts[ind].canConvert<EapQtCertificateInfo> ()) {
       
  1160                 appendCertificateInfo(false, varCerts[ind].value<EapQtCertificateInfo> (),
       
  1161                     &(eapSettings.iCertificates));
       
  1162                 qDebug()
       
  1163                     << "EapQtConfigInterfacePrivate::copyToEapSettings() - AuthorityCertificate appended";
       
  1164             }
       
  1165         }
       
  1166     }
       
  1167 
       
  1168 }
       
  1169 
       
  1170 // caller takes care of deallocating resulting data in certList
       
  1171 void EapQtConfigInterfacePrivate::appendCertificateInfo(bool isCaCertificate,
       
  1172     const EapQtCertificateInfo& certInfo, RPointerArray<EapCertificateEntry>* const certList)
       
  1173 {
       
  1174     qDebug("EapQtConfigInterfacePrivate::appendCertificateInfo(), this = 0x%08x", this);
       
  1175 
       
  1176     Q_ASSERT(certList);
       
  1177 
       
  1178     // use scoped pointer to make sure memory is not leaked in failures
       
  1179     QScopedPointer<EapCertificateEntry> certEntry(new EapCertificateEntry);
       
  1180 
       
  1181     // set certificate enabled in EAP settings
       
  1182     certEntry->SetIsEnabledPresent();
       
  1183     certEntry->SetIsEnabled(ETrue);
       
  1184 
       
  1185     if (isCaCertificate) {
       
  1186         qDebug("EapQtConfigInterfacePrivate::appendCertificateInfo() - CA certificate");
       
  1187         certEntry->SetCertType(EapCertificateEntry::ECA);
       
  1188     }
       
  1189     else {
       
  1190         qDebug("EapQtConfigInterfacePrivate::appendCertificateInfo() - Client certificate");
       
  1191         certEntry->SetCertType(EapCertificateEntry::EUser);
       
  1192     }
       
  1193 
       
  1194     qDebug("EapQtConfigInterfacePrivate::appendCertificateInfo() - *** Adding cert data");
       
  1195 
       
  1196     TBuf<KGeneralStringMaxLength> certText;
       
  1197 
       
  1198     QVariant varValue = certInfo.value(EapQtCertificateInfo::SubjectName);
       
  1199     if (varValue.type() == QVariant::String && varValue.toString().count() <= StringMaxLength) {
       
  1200         certEntry->SetSubjectNamePresent();
       
  1201         certText.Copy(varValue.toString().utf16());
       
  1202         certEntry->SetSubjectName(certText);
       
  1203 
       
  1204         qDebug() << "EapQtConfigInterfacePrivate::appendCertificateInfo() - SubjectName: "
       
  1205             << varValue.toString();
       
  1206     }
       
  1207 
       
  1208     varValue = certInfo.value(EapQtCertificateInfo::IssuerName);
       
  1209     if (varValue.type() == QVariant::String && varValue.toString().count() <= StringMaxLength) {
       
  1210         certEntry->SetIssuerNamePresent();
       
  1211         certText.Copy(varValue.toString().utf16());
       
  1212         certEntry->SetIssuerName(certText);
       
  1213 
       
  1214         qDebug() << "EapQtConfigInterfacePrivate::appendCertificateInfo() - IssuerName: "
       
  1215             << varValue.toString();
       
  1216     }
       
  1217 
       
  1218     varValue = certInfo.value(EapQtCertificateInfo::SerialNumber);
       
  1219     if (varValue.type() == QVariant::String && varValue.toString().count() <= StringMaxLength) {
       
  1220         certEntry->SetSerialNumberPresent();
       
  1221         certText.Copy(varValue.toString().utf16());
       
  1222         certEntry->SetSerialNumber(certText);
       
  1223 
       
  1224         qDebug() << "EapQtConfigInterfacePrivate::appendCertificateInfo() - SerialNumber: "
       
  1225             << varValue.toString();
       
  1226     }
       
  1227 
       
  1228     TCertLabel certLabel;
       
  1229 
       
  1230     varValue = certInfo.value(EapQtCertificateInfo::CertificateLabel);
       
  1231     if (varValue.type() == QVariant::String && varValue.toString().count() <= CertLabelMaxLength) {
       
  1232         certEntry->SetLabelPresent();
       
  1233         certLabel.Copy(varValue.toString().utf16());
       
  1234         certEntry->SetLabel(certLabel);
       
  1235 
       
  1236         qDebug() << "EapQtConfigInterfacePrivate::appendCertificateInfo() - CertificateLabel: "
       
  1237             << varValue.toString();
       
  1238     }
       
  1239 
       
  1240     TBuf<KThumbprintMaxLength> thumbPrint;
       
  1241 
       
  1242     varValue = certInfo.value(EapQtCertificateInfo::ThumbPrint);
       
  1243     if (varValue.type() == QVariant::String && varValue.toString().count()
       
  1244         <= CertThumbprintMaxLength) {
       
  1245         certEntry->SetThumbprintPresent();
       
  1246         thumbPrint.Copy(varValue.toString().utf16());
       
  1247         certEntry->SetThumbprint(thumbPrint);
       
  1248 
       
  1249         qDebug() << "EapQtConfigInterfacePrivate::appendCertificateInfo() - ThumbPrint: "
       
  1250             << varValue.toString();
       
  1251     }
       
  1252 
       
  1253     TKeyIdentifier keyId;
       
  1254 
       
  1255     varValue = certInfo.value(EapQtCertificateInfo::SubjectKeyId);
       
  1256     if (varValue.type() == QVariant::ByteArray && varValue.toByteArray().count()
       
  1257         <= CertSubjectKeyIdLength) {
       
  1258         certEntry->SetSubjectKeyIdPresent();
       
  1259         keyId.Copy(reinterpret_cast<unsigned char*> (varValue.toByteArray().data()),
       
  1260             varValue.toByteArray().size());
       
  1261         certEntry->SetSubjectKeyId(keyId);
       
  1262 
       
  1263         qDebug() << "EapQtConfigInterfacePrivate::appendCertificateInfo() - SubjectKeyId: "
       
  1264             << varValue.toByteArray().toHex();
       
  1265     }
       
  1266 
       
  1267     TUint err = certList->Append(certEntry.data());
       
  1268     if (err != KErrNone) {
       
  1269         qDebug() << "ERROR: EapQtConfigInterfacePrivate::appendCertificateInfo()"
       
  1270             << "- RPointerArray::Append failed for certificate entry";
       
  1271         // scoped certEntry pointer deleted automatically
       
  1272         // no need to touch the array, it is handled by the caller
       
  1273     }
       
  1274     else {
       
  1275         qDebug() << "EapQtConfigInterfacePrivate::appendCertificateInfo()"
       
  1276             << "- *** certificate appended to list";
       
  1277         // remove the ownerhsip from scoped pointer, entry owned by the array now
       
  1278         (void) certEntry.take();
       
  1279     }
       
  1280 
       
  1281     // EapSettings destructor takes care of deallocating the array entries
       
  1282 }
       
  1283 
       
  1284 void EapQtConfigInterfacePrivate::copyFromEapSettings(EAPSettings &eapSettings, EapQtConfig &config)
       
  1285 {
       
  1286     qDebug("EapQtConfigInterfacePrivate::copyFromEapSettings(), this = 0x%08x", this);
       
  1287 
       
  1288     int ind = 0;
       
  1289 
       
  1290     // automatic username
       
  1291     if (eapSettings.iUseAutomaticUsernamePresent) {
       
  1292         config.setValue(EapQtConfig::UsernameAutomatic, convertToBool(
       
  1293             eapSettings.iUseAutomaticUsername));
       
  1294         qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings UsernameAutomatic: "
       
  1295             << config.value(EapQtConfig::UsernameAutomatic).toBool();
       
  1296     }
       
  1297 
       
  1298     // automatic CA certificate
       
  1299     if (eapSettings.iUseAutomaticCACertificatePresent) {
       
  1300         config.setValue(EapQtConfig::AuthorityCertificateAutomatic, convertToBool(
       
  1301             eapSettings.iUseAutomaticCACertificate));
       
  1302         qDebug()
       
  1303             << "EapQtConfigInterfacePrivate - copyFromEapSettings AuthorityCertificateAutomatic: "
       
  1304             << config.value(EapQtConfig::AuthorityCertificateAutomatic).toBool();
       
  1305     }
       
  1306 
       
  1307     // username
       
  1308     if (eapSettings.iUsernamePresent) {
       
  1309         config.setValue(EapQtConfig::Username, QString::fromUtf16(eapSettings.iUsername.Ptr(),
       
  1310             eapSettings.iUsername.Length()));
       
  1311         qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings Username: " << config.value(
       
  1312             EapQtConfig::Username).toString();
       
  1313     }
       
  1314 
       
  1315     // password existence check, password itself is write-only, cannot be read
       
  1316     if (eapSettings.iPasswordExistPresent) {
       
  1317         // report to caller if password exists in the database
       
  1318         config.setValue(EapQtConfig::PasswordStored, convertToBool(eapSettings.iPasswordExist));
       
  1319 
       
  1320         qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings PasswordStored: "
       
  1321             << config.value(EapQtConfig::PasswordStored).toBool();
       
  1322     }
       
  1323 
       
  1324     // password prompt
       
  1325     if (eapSettings.iShowPassWordPromptPresent) {
       
  1326         config.setValue(EapQtConfig::PasswordPrompt, convertToBool(eapSettings.iShowPassWordPrompt));
       
  1327 
       
  1328         qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings PasswordPrompt: "
       
  1329             << config.value(EapQtConfig::PasswordPrompt).toBool();
       
  1330     }
       
  1331 
       
  1332     // automatic realm
       
  1333     if (eapSettings.iUseAutomaticRealmPresent) {
       
  1334         config.setValue(EapQtConfig::RealmAutomatic, convertToBool(eapSettings.iUseAutomaticRealm));
       
  1335         qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings RealmAutomatic: "
       
  1336             << config.value(EapQtConfig::RealmAutomatic).toBool();
       
  1337     }
       
  1338 
       
  1339     // realm
       
  1340     if (eapSettings.iRealmPresent) {
       
  1341         config.setValue(EapQtConfig::Realm, QString::fromUtf16(eapSettings.iRealm.Ptr(),
       
  1342             eapSettings.iRealm.Length()));
       
  1343         qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings Realm: " << config.value(
       
  1344             EapQtConfig::Realm).toString();
       
  1345     }
       
  1346 
       
  1347     // server name
       
  1348     if (eapSettings.iVerifyServerRealmPresent) {
       
  1349         config.setValue(EapQtConfig::VerifyServerRealm, convertToBool(
       
  1350             eapSettings.iVerifyServerRealm));
       
  1351         qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings VerifyServerRealm: "
       
  1352             << config.value(EapQtConfig::VerifyServerRealm).toBool();
       
  1353     }
       
  1354 
       
  1355     // pseudonym
       
  1356     if (eapSettings.iUsePseudonymsPresent) {
       
  1357         config.setValue(EapQtConfig::UsePseudonyms, convertToBool(eapSettings.iUsePseudonyms));
       
  1358 
       
  1359         qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings UsePseudonyms: "
       
  1360             << config.value(EapQtConfig::UsePseudonyms).toBool();
       
  1361     }
       
  1362 
       
  1363     // policy: server must require client authentication
       
  1364     if (eapSettings.iRequireClientAuthenticationPresent) {
       
  1365         config.setValue(EapQtConfig::ClientAuthenticationRequired, convertToBool(
       
  1366             eapSettings.iRequireClientAuthentication));
       
  1367 
       
  1368         qDebug()
       
  1369             << "EapQtConfigInterfacePrivate - copyFromEapSettings ClientAuthenticationRequired: "
       
  1370             << config.value(EapQtConfig::ClientAuthenticationRequired).toBool();
       
  1371     }
       
  1372 
       
  1373     // session validity time
       
  1374     if (eapSettings.iSessionValidityTimePresent) {
       
  1375         config.setValue(EapQtConfig::SessionValidityTime, eapSettings.iSessionValidityTime);
       
  1376 
       
  1377         qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings SessionValidityTime: "
       
  1378             << config.value(EapQtConfig::SessionValidityTime).toUInt();
       
  1379     }
       
  1380 
       
  1381     // TLS ciphersuites
       
  1382     if (eapSettings.iCipherSuitesPresent) {
       
  1383         QList<QVariant> ciphers; // QVariant has a constructor for uint
       
  1384         for (ind = 0; ind < eapSettings.iCipherSuites.Count(); ind++) {
       
  1385             ciphers.append(eapSettings.iCipherSuites[ind]);
       
  1386             qDebug("EapQtConfigInterfacePrivate - copyFromEapSettings CipherSuites at %d: 0x%08x",
       
  1387                 ind, ciphers[ind].toUInt());
       
  1388         }
       
  1389         config.setValue(EapQtConfig::CipherSuites, ciphers);
       
  1390     }
       
  1391 
       
  1392     // certificates
       
  1393     if (eapSettings.iCertificatesPresent) {
       
  1394 
       
  1395         QList<EapQtCertificateInfo> caCerts;
       
  1396         QList<EapQtCertificateInfo> clientCerts;
       
  1397         RPointerArray<EapCertificateEntry> serverCaCerts;
       
  1398         RPointerArray<EapCertificateEntry> serverClientCerts;
       
  1399 
       
  1400         // separate CA and client certs to their own lists
       
  1401         for (ind = 0; ind < eapSettings.iCertificates.Count(); ind++) {
       
  1402 
       
  1403             qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings certificates, "
       
  1404                 << "cert type: " << eapSettings.iCertificates[ind]->GetCertType() << ", enabled: "
       
  1405                 << convertToBool(eapSettings.iCertificates[ind]->GetIsEnabled());
       
  1406 
       
  1407             // only enabled certificates are reported
       
  1408             if (eapSettings.iCertificates[ind]->GetCertType() == EapCertificateEntry::EUser
       
  1409                 && eapSettings.iCertificates[ind]->GetIsEnabled() != EFalse) {
       
  1410                 // no need to check the return value for failures,
       
  1411                 // serverClientCerts does not own the pointed data,
       
  1412                 // eapSettings owns and deallocates it
       
  1413                 (void) serverClientCerts.Append(eapSettings.iCertificates[ind]);
       
  1414             }
       
  1415             // only enabled certificates are reported
       
  1416             else if (eapSettings.iCertificates[ind]->GetCertType() == EapCertificateEntry::ECA
       
  1417                 && eapSettings.iCertificates[ind]->GetIsEnabled() != EFalse) {
       
  1418                 // no need to check the return value for failures,
       
  1419                 // serverCaCerts does not own the pointed data,
       
  1420                 // eapSettings owns and deallocates it
       
  1421                 (void) serverCaCerts.Append(eapSettings.iCertificates[ind]);
       
  1422             }
       
  1423             else {
       
  1424                 qDebug()
       
  1425                     << "WARNING: EapQtConfigInterfacePrivate - copyFromEapSettings certificates, "
       
  1426                     << "unknown certificate type in the list or certificate not enabled";
       
  1427             }
       
  1428         }
       
  1429 
       
  1430         // copy to lists of our type
       
  1431         qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings AuthorityCertificates";
       
  1432         copyCertificateInfo(&serverCaCerts, &caCerts);
       
  1433         qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings UserCertificates";
       
  1434         copyCertificateInfo(&serverClientCerts, &clientCerts);
       
  1435 
       
  1436         // reset the arrays, data is owned by EapSettings.h,
       
  1437         // must not be destroyed here
       
  1438         serverCaCerts.Reset();
       
  1439         serverClientCerts.Reset();
       
  1440 
       
  1441         // we still need to convert QList<EapQtCertificateInfo> to QList<QVariant>
       
  1442         // to be able to store to config
       
  1443         QVariant tmp;
       
  1444         QList<QVariant> varCaCerts;
       
  1445         QList<QVariant> varClientCerts;
       
  1446 
       
  1447         for (ind = 0; ind < caCerts.count(); ind++) {
       
  1448             tmp.setValue(caCerts[ind]);
       
  1449             varCaCerts.append(tmp);
       
  1450         }
       
  1451         for (ind = 0; ind < clientCerts.count(); ind++) {
       
  1452             tmp.setValue(clientCerts[ind]);
       
  1453             varClientCerts.append(tmp);
       
  1454         }
       
  1455 
       
  1456         // finally copy to config
       
  1457         config.setValue(EapQtConfig::AuthorityCertificate, varCaCerts);
       
  1458         config.setValue(EapQtConfig::UserCertificate, varClientCerts);
       
  1459     }
       
  1460 
       
  1461     // PEAP specific
       
  1462     if (eapSettings.iPEAPVersionsPresent) {
       
  1463         config.setValue(EapQtConfig::PeapVersion0Allowed, convertToBool(eapSettings.iPEAPv0Allowed));
       
  1464         config.setValue(EapQtConfig::PeapVersion1Allowed, convertToBool(eapSettings.iPEAPv1Allowed));
       
  1465         config.setValue(EapQtConfig::PeapVersion2Allowed, convertToBool(eapSettings.iPEAPv2Allowed));
       
  1466 
       
  1467         qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings PeapVersion0Allowed: "
       
  1468             << config.value(EapQtConfig::PeapVersion0Allowed).toBool();
       
  1469         qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings PeapVersion1Allowed: "
       
  1470             << config.value(EapQtConfig::PeapVersion1Allowed).toBool();
       
  1471         qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings PeapVersion2Allowed: "
       
  1472             << config.value(EapQtConfig::PeapVersion2Allowed).toBool();
       
  1473     }
       
  1474 
       
  1475     // TLS privacy
       
  1476     if (eapSettings.iUseIdentityPrivacyPresent) {
       
  1477         config.setValue(EapQtConfig::UseIdentityPrivacy, convertToBool(
       
  1478             eapSettings.iUseIdentityPrivacy));
       
  1479 
       
  1480         qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings UseIdentityPrivacy: "
       
  1481             << config.value(EapQtConfig::UseIdentityPrivacy).toBool();
       
  1482     }
       
  1483 
       
  1484     // EAP-FAST specific
       
  1485     if (eapSettings.iAuthProvModeAllowedPresent) {
       
  1486         config.setValue(EapQtConfig::ProvisioningModeAuthenticated, convertToBool(
       
  1487             eapSettings.iAuthProvModeAllowed));
       
  1488 
       
  1489         qDebug()
       
  1490             << "EapQtConfigInterfacePrivate - copyFromEapSettings ProvisioningModeAuthenticated: "
       
  1491             << config.value(EapQtConfig::ProvisioningModeAuthenticated).toBool();
       
  1492     }
       
  1493     if (eapSettings.iUnauthProvModeAllowedPresent) {
       
  1494         config.setValue(EapQtConfig::ProvisioningModeUnauthenticated, convertToBool(
       
  1495             eapSettings.iUnauthProvModeAllowed));
       
  1496 
       
  1497         qDebug()
       
  1498             << "EapQtConfigInterfacePrivate - copyFromEapSettings ProvisioningModeUnauthenticated: "
       
  1499             << config.value(EapQtConfig::ProvisioningModeUnauthenticated).toBool();
       
  1500     }
       
  1501     if (eapSettings.iWarnADHPNoPACPresent) {
       
  1502         config.setValue(EapQtConfig::WarnADHPNoPAC, convertToBool(eapSettings.iWarnADHPNoPAC));
       
  1503 
       
  1504         qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings WarnADHPNoPAC: "
       
  1505             << config.value(EapQtConfig::WarnADHPNoPAC).toBool();
       
  1506     }
       
  1507     if (eapSettings.iWarnADHPNoMatchingPACPresent) {
       
  1508         config.setValue(EapQtConfig::WarnADHPNoMatchingPAC, convertToBool(
       
  1509             eapSettings.iWarnADHPNoMatchingPAC));
       
  1510 
       
  1511         qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings WarnADHPNoMatchingPAC: "
       
  1512             << config.value(EapQtConfig::WarnADHPNoMatchingPAC).toBool();
       
  1513     }
       
  1514     if (eapSettings.iWarnNotDefaultServerPresent) {
       
  1515         config.setValue(EapQtConfig::WarnNotDefaultServer, convertToBool(
       
  1516             eapSettings.iWarnNotDefaultServer));
       
  1517 
       
  1518         qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings WarnNotDefaultServer: "
       
  1519             << config.value(EapQtConfig::WarnNotDefaultServer).toBool();
       
  1520     }
       
  1521     if (eapSettings.iPACGroupReferencePresent) {
       
  1522         config.setValue(EapQtConfig::PACGroupReference, QString::fromUtf16(
       
  1523             eapSettings.iPACGroupReference.Ptr(), eapSettings.iPACGroupReference.Length()));
       
  1524         qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings PACGroupReference: "
       
  1525             << config.value(EapQtConfig::PACGroupReference).toString();
       
  1526     }
       
  1527 
       
  1528     // enabled inner EAPs
       
  1529     if (eapSettings.iEnabledEncapsulatedEAPExpandedTypesPresent) {
       
  1530 
       
  1531         qDebug("EapQtConfigInterfacePrivate - copyFromEapSettings InnerType, enabled count %d",
       
  1532             eapSettings.iEnabledEncapsulatedEAPExpandedTypes.Count());
       
  1533 
       
  1534         QList<QByteArray> innerEapsOn;
       
  1535         appendEapTypes(&(eapSettings.iEnabledEncapsulatedEAPExpandedTypes), &innerEapsOn);
       
  1536 
       
  1537         // convert to QList<QVariant> to be able to store to config
       
  1538         QVariant varTmp;
       
  1539         QList<QVariant> varInnerEapsOn;
       
  1540         int dummy = 0;
       
  1541 
       
  1542         for (ind = 0; ind < innerEapsOn.count(); ind++) {
       
  1543             // report only EAPs which do have an UI plugin
       
  1544             if (isUiSupported(innerEapsOn[ind], dummy)) {
       
  1545                 // create plugin handle from EAP type with constructors
       
  1546                 // calls: EapQtExpandedEapType(const QByteArray data) -> EapQtPluginHandle(EapQtExpandedEapType type)
       
  1547                 varTmp.setValue(EapQtPluginHandle(EapQtExpandedEapType(innerEapsOn[ind])));
       
  1548                 varInnerEapsOn.append(varTmp);
       
  1549                 qDebug()
       
  1550                     << "EapQtConfigInterfacePrivate - copyFromEapSettings InnerType: added EAP: "
       
  1551                     << innerEapsOn[ind].toHex();
       
  1552             }
       
  1553         }
       
  1554 
       
  1555         // copy to config
       
  1556         config.setValue(EapQtConfig::InnerType, varInnerEapsOn);
       
  1557     }
       
  1558 
       
  1559     // disabled inner EAPs
       
  1560     if (eapSettings.iDisabledEncapsulatedEAPExpandedTypesPresent) {
       
  1561         // setting is not needed, enabled are enough
       
  1562         qDebug(
       
  1563             "EapQtConfigInterfacePrivate - copyFromEapSettings InnerType: disabled count %d (not needed for anything here)",
       
  1564             eapSettings.iDisabledEncapsulatedEAPExpandedTypes.Count());
       
  1565     }
       
  1566 
       
  1567 }
       
  1568 
       
  1569 QList<EapQtPluginHandle> EapQtConfigInterfacePrivate::selectedOuterTypes()
       
  1570 {
       
  1571     qDebug("EapQtConfigInterfacePrivate::selectedOuterTypes(), this = 0x%08x", this);
       
  1572 
       
  1573     checkInstanceThrowing();
       
  1574 
       
  1575     if (!mEapDbIndexValid) {
       
  1576         qDebug() << "ERROR: Database reference not valid, call setConfigurationReference first!";
       
  1577         return QList<EapQtPluginHandle> ();
       
  1578     }
       
  1579 
       
  1580     // call to make sure the members (mOuterEapsOn and mSupportedOuterTypes) are up-to-date
       
  1581     (void) supportedOuterTypes();
       
  1582 
       
  1583     QList<EapQtPluginHandle> selectedOuterTypes;
       
  1584 
       
  1585     QList<QByteArray> tmpEaps;
       
  1586     appendEapTypes(&mOuterEapsOn, &tmpEaps);
       
  1587 
       
  1588     // report only the ones that also have an UI, i.e. listed in mSupportedOuterTypes
       
  1589     for (int ind = 0; ind < mSupportedOuterTypes.count(); ind++) {
       
  1590         if (tmpEaps.contains(mSupportedOuterTypes[ind].pluginHandle().type().eapExpandedData())) {
       
  1591             selectedOuterTypes.append(mSupportedOuterTypes[ind].pluginHandle());
       
  1592         }
       
  1593     }
       
  1594 
       
  1595     qDebug("EapQtConfigInterfacePrivate - selected outer type count: %d",
       
  1596         selectedOuterTypes.count());
       
  1597 
       
  1598     return selectedOuterTypes;
       
  1599 }
       
  1600 
       
  1601 bool EapQtConfigInterfacePrivate::isSupportedOuterType(const EapQtPluginHandle &handle)
       
  1602 {
       
  1603     qDebug("EapQtConfigInterfacePrivate::isSupportedOuterType(), this = 0x%08x", this);
       
  1604 
       
  1605     checkInstanceThrowing();
       
  1606 
       
  1607     // check if mSupportedOuterTypes is up-to-date
       
  1608     if (mSupportedOuterTypes.count() <= 0) {
       
  1609         // update mSupportedOuterTypes
       
  1610         (void) supportedOuterTypes();
       
  1611     }
       
  1612 
       
  1613     bool ret = false;
       
  1614     for (int ind = 0; ind < mSupportedOuterTypes.count(); ind++) {
       
  1615         if (mSupportedOuterTypes[ind].pluginHandle() == handle) {
       
  1616             ret = true;
       
  1617         }
       
  1618     }
       
  1619     return ret;
       
  1620 }
       
  1621 
       
  1622 bool EapQtConfigInterfacePrivate::setSelectedOuterTypes(
       
  1623     const QList<EapQtPluginHandle> &outerHandles)
       
  1624 {
       
  1625     qDebug("EapQtConfigInterfacePrivate::setSelectedOuterTypes()");
       
  1626 
       
  1627     checkInstanceThrowing();
       
  1628 
       
  1629     if (!mEapDbIndexValid || mEapGsIf.isNull()) {
       
  1630         qDebug()
       
  1631             << "ERROR: Database reference not valid (or mEapGsIf is NULL), call setConfigurationReference first!";
       
  1632         return false;
       
  1633     }
       
  1634 
       
  1635     // check if mSupportedOuterTypes is up-to-date
       
  1636     if (mSupportedOuterTypes.count() <= 0) {
       
  1637         // update mSupportedOuterTypes
       
  1638         (void) supportedOuterTypes();
       
  1639     }
       
  1640 
       
  1641     // clear arrays
       
  1642     mOuterEapsOn.Reset();
       
  1643     mOuterEapsOff.Reset();
       
  1644 
       
  1645     // pick only the supported ones from outerHandles
       
  1646     TEapExpandedType tmpEap;
       
  1647     TUint err(KErrNone);
       
  1648     for (int ind = 0; ind < mSupportedOuterTypes.count(); ind++) {
       
  1649         if (outerHandles.contains(mSupportedOuterTypes[ind].pluginHandle())) {
       
  1650 
       
  1651             // convert to TEapExpandedType
       
  1652             tmpEap.SetValue(
       
  1653                 mSupportedOuterTypes[ind].pluginHandle().type().eapExpandedData().data(),
       
  1654                 mSupportedOuterTypes[ind].pluginHandle().type().eapExpandedData().length());
       
  1655 
       
  1656             // add to mOuterEapsOn
       
  1657             err = mOuterEapsOn.Append(tmpEap);
       
  1658             if(err != KErrNone)
       
  1659             {
       
  1660                 qDebug() << "ERROR: EapQtConfigInterfacePrivate - setSelectedOuterTypes RArray::Append failed";
       
  1661                 // reset the array, no dynamic memory allocated for tmpEap
       
  1662                 mOuterEapsOn.Reset();
       
  1663                 return false;
       
  1664             }
       
  1665 
       
  1666             qDebug()
       
  1667                 << "EapQtConfigInterfacePrivate - setSelectedOuterTypes adding to enabledOuterHandles: "
       
  1668                 << mSupportedOuterTypes[ind].pluginHandle().type().eapExpandedData().toHex();
       
  1669         }
       
  1670     }
       
  1671 
       
  1672     bool ret = true;
       
  1673 
       
  1674     // set selection to EAP server, no need to have correct content in mOuterEapsOff,  
       
  1675     // EAP server handles it, mOuterEapsOn is only important
       
  1676     err = mEapGsIf->SetEapMethods(mOuterEapsOn, mOuterEapsOff);
       
  1677     if (err != KErrNone) {
       
  1678         qDebug("EapQtConfigInterfacePrivate::setSelectedOuterTypes() - SetEapMethods failed: %d",
       
  1679             err);
       
  1680         // nothing we can do to recover, just exit
       
  1681         ret = false;
       
  1682     }
       
  1683     return ret;
       
  1684 }
       
  1685 
       
  1686 bool EapQtConfigInterfacePrivate::isSupportedInnerType(const EapQtPluginHandle &outerHandle,
       
  1687     const EapQtPluginHandle &innerHandle)
       
  1688 {
       
  1689     qDebug("EapQtConfigInterfacePrivate::isSupportedInnerType(), this = 0x%08x", this);
       
  1690 
       
  1691     checkInstanceThrowing();
       
  1692 
       
  1693     // update mSupportedInnerTypes
       
  1694     (void) supportedInnerTypes(outerHandle);
       
  1695 
       
  1696     for (int ind = 0; ind < mSupportedInnerTypes.count(); ind++) {
       
  1697         if (mSupportedInnerTypes[ind].pluginHandle() == innerHandle) {
       
  1698             return true;
       
  1699         }
       
  1700     }
       
  1701     return false;
       
  1702 }
       
  1703 
       
  1704 bool EapQtConfigInterfacePrivate::deleteConfiguration()
       
  1705 {
       
  1706     qDebug("EapQtConfigInterfacePrivate::deleteConfiguration(), this = 0x%08x", this);
       
  1707 
       
  1708     checkInstanceThrowing();
       
  1709 
       
  1710     if (!mEapDbIndexValid || mEapGsIf.isNull()) {
       
  1711         qDebug()
       
  1712             << "ERROR: Database reference not valid (or mEapGsIf is NULL), call setConfigurationReference first!";
       
  1713         return false;
       
  1714     }
       
  1715 
       
  1716     bool ret = true;
       
  1717     TInt err = mEapGsIf->DeleteAllEapSettings();
       
  1718     if (err != KErrNone) {
       
  1719         ret = false;
       
  1720     }
       
  1721     return ret;
       
  1722 }
       
  1723 
       
  1724 void EapQtConfigInterfacePrivate::loadPlugins()
       
  1725 {
       
  1726     qDebug("EapQtConfigInterfacePrivate::loadPlugins(), this = 0x%08x", this);
       
  1727 
       
  1728     checkInstanceThrowing();
       
  1729 
       
  1730     // plugin directory defined in cpeapplugininterface.h
       
  1731     QDir pluginsDir(CpEapPluginInterfacePluginDirectory);
       
  1732     foreach( QString fileName, pluginsDir.entryList(QDir::Files) )
       
  1733         {
       
  1734             QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
       
  1735             QObject *tmp = loader.instance();
       
  1736             if (tmp) {
       
  1737                 CpEapPluginInterface *plugin = qobject_cast<CpEapPluginInterface*> (tmp);
       
  1738                 if (plugin) {
       
  1739                     mPlugins.append(plugin);
       
  1740                 }
       
  1741             }
       
  1742         }
       
  1743 
       
  1744     // collect UI plugin infos
       
  1745     QList<CpEapPluginInterface*>::iterator iter;
       
  1746     for (iter = mPlugins.begin(); iter != mPlugins.end(); ++iter) {
       
  1747         mPluginInfos.append((*iter)->pluginInfo());
       
  1748     }
       
  1749 
       
  1750     // sort the UI plugins according to their order number
       
  1751     qSort(mPluginInfos.begin(), mPluginInfos.end(), EapQtConfigInterfacePrivate::pluginLessThan);
       
  1752 
       
  1753     qDebug("EapQtConfigInterfacePrivate - loadPlugins: supported EAP plugin count: %d",
       
  1754         mPluginInfos.count());
       
  1755 }
       
  1756 
       
  1757 bool EapQtConfigInterfacePrivate::pluginLessThan(
       
  1758     const EapQtPluginInfo &plugin1,
       
  1759     const EapQtPluginInfo &plugin2)
       
  1760 {
       
  1761     return plugin1.orderNumber() < plugin2.orderNumber();
       
  1762 }
       
  1763 
       
  1764 CpBaseSettingView *EapQtConfigInterfacePrivate::uiInstance(const EapQtPluginHandle &outerHandle,
       
  1765     const EapQtPluginHandle &pluginHandle)
       
  1766 {
       
  1767     qDebug("EapQtConfigInterfacePrivate::uiInstance(), this = 0x%08x", this);
       
  1768 
       
  1769     checkInstanceThrowing();
       
  1770 
       
  1771     // if outer type UI is requested, outerHandle must be undefined and pluginHandle
       
  1772     // must be supported as outer type
       
  1773     if (outerHandle == EapQtPluginHandle::PluginUndefined) {
       
  1774         if (!isSupportedOuterType(pluginHandle)) {
       
  1775             qDebug() << "ERROR: EapQtConfigInterfacePrivate::uiInstance() -"
       
  1776                 << "plugin not supported as outer type";
       
  1777             return NULL;
       
  1778         }
       
  1779     }
       
  1780     else {
       
  1781         // outerHandle defined, pluginHandle must be supported inside outerHandle
       
  1782         if (!isSupportedInnerType(outerHandle, pluginHandle)) {
       
  1783             qDebug() << "ERROR: EapQtConfigInterfacePrivate::uiInstance() -"
       
  1784                 << "plugin not supported as the inner type of the specified outer type";
       
  1785             return NULL;
       
  1786         }
       
  1787     }
       
  1788 
       
  1789     if (mTranslator.isNull()) {
       
  1790         // install translations for EAP UI plugins
       
  1791         mTranslator.reset(new HbTranslator(eapTranslationFile));
       
  1792     }
       
  1793 
       
  1794     // go through all interfaces (dlls)
       
  1795     QList<CpEapPluginInterface*>::iterator iter;
       
  1796     for (iter = mPlugins.begin(); iter != mPlugins.end(); ++iter) {
       
  1797         QList<EapQtPluginInfo> plugins;
       
  1798         plugins.append((*iter)->pluginInfo());
       
  1799 
       
  1800         // go through all plugings inside the interface implementation
       
  1801         QList<EapQtPluginInfo>::iterator j;
       
  1802         for (j = plugins.begin(); j != plugins.end(); ++j) {
       
  1803             if ((*j).pluginHandle() == pluginHandle) {
       
  1804                 qDebug("EapQtConfigInterfacePrivate::uiInstance() - found plugin");
       
  1805                 // indicate configured IAP to plugin
       
  1806                 (*iter)->setSettingsReference(getEapBearer(), mIapId);
       
  1807                 return (*iter)->uiInstance(outerHandle, *j);
       
  1808             }
       
  1809         }
       
  1810 
       
  1811     }
       
  1812     qDebug("ERROR: EapQtConfigInterfacePrivate::uiInstance() - plugin not found");
       
  1813     return NULL;
       
  1814 }
       
  1815 
       
  1816 EapQtConfigInterface::EapBearerType EapQtConfigInterfacePrivate::getEapBearer()
       
  1817 {
       
  1818     EapQtConfigInterface::EapBearerType ret(EapQtConfigInterface::EapBearerTypeWlan);
       
  1819 
       
  1820     switch (mEapBearer) {
       
  1821     case EVpn:
       
  1822         ret = EapQtConfigInterface::EapBearerTypeVpn;
       
  1823         break;
       
  1824     default:
       
  1825         ret = EapQtConfigInterface::EapBearerTypeWlan;
       
  1826         break;
       
  1827     }
       
  1828     return ret;
       
  1829 }
       
  1830 
       
  1831 EapQtValidator *EapQtConfigInterfacePrivate::validatorEap(const EapQtExpandedEapType &type,
       
  1832     const EapQtConfig::SettingsId id)
       
  1833 {
       
  1834     qDebug("EapQtConfigInterfacePrivate::validatorEap(), this = 0x%08x", this);
       
  1835 
       
  1836     qDebug() << "EapQtConfigInterfacePrivate::validatorEap() - requested EAP: "
       
  1837         << type.eapExpandedData().toHex();
       
  1838     qDebug() << "EapQtConfigInterfacePrivate::validatorEap() - setting: " << id;
       
  1839 
       
  1840     EapQtValidator *ret = NULL;
       
  1841 
       
  1842     switch (id) {
       
  1843 
       
  1844     case EapQtConfig::Username:
       
  1845         switch (type.type()) {
       
  1846         case EapQtExpandedEapType::TypeEapAka:
       
  1847         case EapQtExpandedEapType::TypeEapFast:
       
  1848         case EapQtExpandedEapType::TypeEapGtc:
       
  1849         case EapQtExpandedEapType::TypeLeap:
       
  1850         case EapQtExpandedEapType::TypeEapMschapv2:
       
  1851         case EapQtExpandedEapType::TypePeap:
       
  1852         case EapQtExpandedEapType::TypeEapSim:
       
  1853         case EapQtExpandedEapType::TypeEapTls:
       
  1854         case EapQtExpandedEapType::TypeEapTtls:
       
  1855         case EapQtExpandedEapType::TypePap:
       
  1856         case EapQtExpandedEapType::TypePlainMschapv2:
       
  1857             ret = new EapQtValidatorUsername(type);
       
  1858             break;
       
  1859         default:
       
  1860             ret = NULL;
       
  1861         }
       
  1862         break;
       
  1863 
       
  1864     case EapQtConfig::Password:
       
  1865         switch (type.type()) {
       
  1866         case EapQtExpandedEapType::TypeEapGtc:
       
  1867         case EapQtExpandedEapType::TypeLeap:
       
  1868         case EapQtExpandedEapType::TypeEapMschapv2:
       
  1869         case EapQtExpandedEapType::TypePap:
       
  1870         case EapQtExpandedEapType::TypePlainMschapv2:
       
  1871             ret = new EapQtValidatorPassword(type);
       
  1872             break;
       
  1873         default:
       
  1874             ret = NULL;
       
  1875         }
       
  1876         break;
       
  1877 
       
  1878     case EapQtConfig::Realm:
       
  1879         switch (type.type()) {
       
  1880         case EapQtExpandedEapType::TypeEapAka:
       
  1881         case EapQtExpandedEapType::TypeEapFast:
       
  1882         case EapQtExpandedEapType::TypePeap:
       
  1883         case EapQtExpandedEapType::TypeEapSim:
       
  1884         case EapQtExpandedEapType::TypeEapTls:
       
  1885         case EapQtExpandedEapType::TypeEapTtls:
       
  1886             ret = new EapQtValidatorRealm(type);
       
  1887             break;
       
  1888         default:
       
  1889             ret = NULL;
       
  1890         }
       
  1891         break;
       
  1892 
       
  1893     default:
       
  1894         ret = NULL;
       
  1895 
       
  1896     }
       
  1897 
       
  1898     qDebug() << "EapQtConfigInterfacePrivate::validatorEap() - is returning NULL: " << (ret == NULL);
       
  1899 
       
  1900     return ret;
       
  1901 }
       
  1902 
       
  1903 bool EapQtConfigInterfacePrivate::readPacStoreConfiguration(EapQtPacStoreConfig& /* config */)
       
  1904 {
       
  1905     // not supported
       
  1906     return false;
       
  1907 }
       
  1908 
       
  1909 bool EapQtConfigInterfacePrivate::savePacStoreConfiguration(const EapQtPacStoreConfig& /* config */)
       
  1910 {
       
  1911     // not supported
       
  1912     return false;
       
  1913 }
       
  1914 
       
  1915 EapQtValidator *EapQtConfigInterfacePrivate::validatorPacStore(
       
  1916     const EapQtPacStoreConfig::PacStoreSettings id)
       
  1917 {
       
  1918     qDebug("EapQtConfigInterfacePrivate::validatorPacStore(), this = 0x%08x", this);
       
  1919 
       
  1920     EapQtValidator *ret = NULL;
       
  1921 
       
  1922     switch (id) {
       
  1923     case EapQtPacStoreConfig::PacStorePassword:
       
  1924         ret = new EapQtValidatorPacStorePassword();
       
  1925         break;
       
  1926     case EapQtPacStoreConfig::PacStorePasswordConfirmation:
       
  1927         ret = new EapQtValidatorPacStorePasswordConfirm();
       
  1928         break;
       
  1929     default:
       
  1930         ret = NULL;
       
  1931     }
       
  1932 
       
  1933     return ret;
       
  1934 }