securitysettings/cpeapuiplugins/cpeaptlsmethodsui/src/cpeaptlsmethodsui.cpp
changeset 52 c23bdf5a328a
parent 39 fe6b6762fccd
equal deleted inserted replaced
51:e863583e6720 52:c23bdf5a328a
    15  *   Control Panel QT UI for TLS-based EAP methods configuration
    15  *   Control Panel QT UI for TLS-based EAP methods configuration
    16  *
    16  *
    17  */
    17  */
    18 
    18 
    19 /*
    19 /*
    20  * %version: 24 %
    20  * %version: 38 %
    21  */
    21  */
    22 
    22 
    23 // System includes
    23 // System includes
    24 #include <HbDataForm>
    24 #include <HbDataForm>
    25 #include <HbDataFormModel>
    25 #include <HbDataFormModel>
    26 #include <HbDataFormViewItem>
    26 #include <HbDataFormViewItem>
    27 #include <HbParameterLengthLimiter>
    27 #include <HbParameterLengthLimiter>
    28 #include <HbMessageBox> 
    28 #include <HbMessageBox>
       
    29 #include <HbInputDialog>
    29 #include <HbAction>
    30 #include <HbAction>
    30 #include <HbLineEdit>
    31 #include <HbLineEdit>
    31 #include <cpsettingformitemdata.h>
    32 #include <cpsettingformitemdata.h>
    32 #include <cpitemdatahelper.h>
    33 #include <cpitemdatahelper.h>
    33 #include <eapqtvalidator.h>
    34 #include <eapqtvalidator.h>
    34 #include <eapqtexpandedeaptype.h>
    35 #include <eapqtexpandedeaptype.h>
    35 #include <eapqtcertificateinfo.h>
    36 #include <eapqtcertificateinfo.h>
       
    37 #include <eapqtpacstoreconfig.h>
    36 #include <cppluginutility.h>
    38 #include <cppluginutility.h>
    37 
    39 
    38 // User includes
    40 // User includes
    39 #include "cpeapciphersuiteui.h"
    41 #include "cpeapciphersuiteui.h"
    40 #include "cpeaptlsmethodsui.h"
    42 #include "cpeaptlsmethodsui.h"
       
    43 #include "cpeappacstoreui.h"
    41 #include "cpeaptlsmethodsinnereapui.h"
    44 #include "cpeaptlsmethodsinnereapui.h"
    42 
    45 
    43 /*!
    46 /*!
    44  * \class CpEapTlsMethodsUi
    47  * \class CpEapTlsMethodsUi
    45  * \brief Implementes TLS based methods configuration ui. 
    48  * \brief Implementes TLS based methods configuration ui. 
    59 static const int DefaultIndex = 0;
    62 static const int DefaultIndex = 0;
    60 /*!
    63 /*!
    61  * Index of 'Not in use'in certificate selection lists.
    64  * Index of 'Not in use'in certificate selection lists.
    62  */
    65  */
    63 static const int NotInUseIndex = 0;
    66 static const int NotInUseIndex = 0;
       
    67 /*!
       
    68  * First item of the list
       
    69  */
       
    70 static const int FirstItem = 0;
       
    71 /*
       
    72  * Second item of the list
       
    73  */
       
    74 static const int SecondItem = 1;
       
    75 /*!
       
    76  * Shift by reason of 'Not in use'
       
    77  */
       
    78 static const int NotInUseShift = 1;
    64 
    79 
    65 // ======== LOCAL FUNCTIONS ========
    80 // ======== LOCAL FUNCTIONS ========
    66 
    81 
    67 // ======== MEMBER FUNCTIONS ========
    82 // ======== MEMBER FUNCTIONS ========
    68 
    83 
    69 /*!
    84 /*!
    70  * Constructor.
    85  * Constructor.
    71  * 
    86  * 
    72  * @param bearer        Bearer type of the accessed configuration.
    87  * @param [in] bearer        Bearer type of the accessed configuration.
    73  * @param iapId         IAP ID of the accessed configuration.
    88  * @param [in] iapId         IAP ID of the accessed configuration.
    74  * @param plugin        Plugin.
    89  * @param [in] plugin        Plugin.
    75  * @param outerHandle   Outer handle.
    90  * @param [in] outerHandle   Outer handle.
    76  */
    91  */
    77 
    92 
    78 CpEapTlsMethodsUi::CpEapTlsMethodsUi(
    93 CpEapTlsMethodsUi::CpEapTlsMethodsUi(
    79     const EapQtConfigInterface::EapBearerType bearer,
    94     const EapQtConfigInterface::EapBearerType bearer,
    80     const int iapId,
    95     const int iapId,
    89         mGroupItem(NULL),
   104         mGroupItem(NULL),
    90         mUsernameAutomatic(NULL),
   105         mUsernameAutomatic(NULL),
    91         mUsername(NULL),
   106         mUsername(NULL),
    92         mRealmAutomatic(NULL),
   107         mRealmAutomatic(NULL),
    93         mRealm(NULL),
   108         mRealm(NULL),
       
   109         mUserCertificate(NULL),
    94         mCaCertAutomatic(NULL),
   110         mCaCertAutomatic(NULL),
    95         mCaCert(NULL),
   111         mCaCert(NULL),
    96         mPeapVersion(NULL),
   112         mPeapVersion(NULL),
       
   113         mAuthProvisioning(NULL),
       
   114         mUnauthProvisioning(NULL),
       
   115         mTlsPrivacy(NULL),
    97         mInnerEapType(NULL),
   116         mInnerEapType(NULL),
       
   117         mSecondInnerEapType(NULL),
       
   118         mSecondEapEntry(NULL),
       
   119         mGroupItemPacStore(NULL),
    98         mGroupItemCs(NULL),
   120         mGroupItemCs(NULL),
    99         mCurrentUserCert(0),
   121         mCurrentUserCert(0),
   100         mCurrentAuthorityCert(0),
   122         mCurrentAuthorityCert(0),
   101         mCurrentPeapVersion(0),
   123         mCurrentPeapVersion(0),
   102         mCurrentInnerPlugin(0),
   124         mCurrentInnerPlugin(0),
   103         mInnerEapMschapv2(0),
   125         mCurrentSecondInnerPlugin(0),
   104         mInnerEapGtc(0),
   126         mInnerEapMschapv2(-1),
   105         mDefaultPluginInUse(false)
   127         mInnerEapGtc(-1),
       
   128         mSecondInnerEapGtc(0),
       
   129         mDefaultPluginInUse(false),
       
   130         mInnerEapMschapv2Only(false)
   106 {
   131 {
   107     qDebug("CpEapTlsMethodsUi::CpEapTlsMethodsUi()");
   132     qDebug("CpEapTlsMethodsUi::CpEapTlsMethodsUi()");
   108 
   133 
   109     // IAP must be valid in construction (check includes
   134     // IAP must be valid in construction (check includes
   110     // EapQtConfigInterface::IapIdUndefined)
   135     // EapQtConfigInterface::IapIdUndefined)
   111     if (iapId < 0) {
   136     if (iapId < 0) {
   112         QT_THROW(std::bad_alloc());
   137         QT_THROW(std::bad_alloc());
   113         // scoped pointer gets deleted automaticaly on exception
   138         // scoped pointer gets deleted automaticaly on exception
   114     }
   139     }
       
   140     setObjectName("CpEapTlsMethodsUi");
   115 
   141 
   116     // Get EAP config interface
   142     // Get EAP config interface
   117     mConfigIf.reset(new EapQtConfigInterface(bearer, iapId));
   143     mConfigIf.reset(new EapQtConfigInterface(bearer, iapId));
   118     
   144     
   119     // Request supported inner EAP types
   145     // Request supported inner EAP types
   140  * 
   166  * 
   141  * @return pointer to inner UI instance
   167  * @return pointer to inner UI instance
   142  */
   168  */
   143 CpBaseSettingView *CpEapTlsMethodsUi::innerUiInstance()
   169 CpBaseSettingView *CpEapTlsMethodsUi::innerUiInstance()
   144 {
   170 {
       
   171     if (mInnerEapMschapv2Only) {
       
   172         // Only EAP-MSCHAPv2 in Inner EAP type list
       
   173         return mConfigIf->uiInstance(mPluginInfo.pluginHandle(),
       
   174             mPlugins.at(mInnerEapMschapv2).pluginHandle());       
       
   175     } else {
       
   176         return mConfigIf->uiInstance(mPluginInfo.pluginHandle(),
       
   177             mPlugins.at(mCurrentInnerPlugin).pluginHandle());        
       
   178     }
       
   179 }
       
   180 
       
   181 /*!
       
   182  * Calls inner UI instance
       
   183  * 
       
   184  * @return pointer to inner UI instance
       
   185  */
       
   186 CpBaseSettingView *CpEapTlsMethodsUi::secondInnerUiInstance()
       
   187 {
       
   188     // Second inner EAP type can be only EAP-GTC
       
   189     Q_ASSERT(mCurrentSecondInnerPlugin == mSecondInnerEapGtc);
   145     return mConfigIf->uiInstance(mPluginInfo.pluginHandle(),
   190     return mConfigIf->uiInstance(mPluginInfo.pluginHandle(),
   146         mPlugins.at(mCurrentInnerPlugin).pluginHandle());
   191         mPlugins.at(mInnerEapGtc).pluginHandle());
   147 }
   192 }
   148 
   193 
   149 /*!
   194 /*!
   150  * Creates TLS based methods UI and initilizes settings read via
   195  * Creates TLS based methods UI and initilizes settings read via
   151  * EapQtConfigInterface
   196  * EapQtConfigInterface
   161         qDebug("CpEapTlsMethodsUi::createUi - read configuration failed.");
   206         qDebug("CpEapTlsMethodsUi::createUi - read configuration failed.");
   162     }
   207     }
   163     
   208     
   164     // Construct TLS based methods settings UI
   209     // Construct TLS based methods settings UI
   165     mForm = new HbDataForm();
   210     mForm = new HbDataForm();
       
   211     mForm->setObjectName("CpEapTlsMethodsUiForm");
   166     this->setWidget(mForm);
   212     this->setWidget(mForm);
       
   213     
   167     CpPluginUtility::addCpItemPrototype(mForm);
   214     CpPluginUtility::addCpItemPrototype(mForm);
       
   215     
   168     mModel = new HbDataFormModel(mForm);
   216     mModel = new HbDataFormModel(mForm);
       
   217     mModel->setObjectName("CpEapTlsMethodsUiModel");
   169     
   218     
   170     // Create settings group
   219     // Create settings group
   171     mGroupItem = new HbDataFormModelItem(HbDataFormModelItem::GroupItem,
   220     mGroupItem = new HbDataFormModelItem(
       
   221         HbDataFormModelItem::GroupItem,
   172         HbParameterLengthLimiter(
   222         HbParameterLengthLimiter(
   173             hbTrId("txt_occ_subhead_eap_module_settings")).arg(
   223             "txt_occ_subhead_eap_module_settings").arg(
   174             mPluginInfo.localizationId()));
   224                 mPluginInfo.localizationId()));
       
   225     
       
   226     mGroupItem->setContentWidgetData("objectName", "CpEapTlsMethodsUiGroupItem");
   175     mModel->appendDataFormItem(mGroupItem);
   227     mModel->appendDataFormItem(mGroupItem);
   176 
   228 
   177     // The parameter given as 0 is a HbDataForm pointer, not parent
   229     // The parameter given as 0 is a HbDataForm pointer, not parent
   178     mItemDataHelper = new CpItemDataHelper(0);
   230     mItemDataHelper = new CpItemDataHelper(0);
   179     mItemDataHelper->setParent(this);
   231     mItemDataHelper->setParent(this);
   180 
   232 
   181     // Create method specific UI
   233     // Create method specific UI
   182     if (mPluginInfo.pluginHandle() == EapQtPluginHandle::PluginEapTls) {
   234     if (mPluginInfo.pluginHandle() == EapQtPluginHandle::PluginEapTls) {
   183         createTlsUi();
   235         createTlsUi();
   184     }
   236     } else if (mPluginInfo.pluginHandle() == EapQtPluginHandle::PluginEapTtls) {
   185     else if (mPluginInfo.pluginHandle() == EapQtPluginHandle::PluginEapTtls) {
       
   186         createTtlsUi();
   237         createTtlsUi();
   187     }
   238     } else if (mPluginInfo.pluginHandle() == EapQtPluginHandle::PluginPeap) {
   188     else if (mPluginInfo.pluginHandle() == EapQtPluginHandle::PluginPeap) {
       
   189         createPeapUi();
   239         createPeapUi();
   190     }
   240     } else if (mPluginInfo.pluginHandle() == EapQtPluginHandle::PluginEapFast) {
   191     else {
   241         createFastUi();
       
   242     } else {
   192         qDebug("CpEapTlsMethodsUi::createUi() - unknown EAP method");
   243         qDebug("CpEapTlsMethodsUi::createUi() - unknown EAP method");
   193     }
   244     }
   194     
   245     
   195     // Load cipher suites view
   246     // Load cipher suites view
   196     QVariant variant;
   247     QVariant variant;
   200 
   251 
   201     mItemDataHelper->bindToForm(mForm);
   252     mItemDataHelper->bindToForm(mForm);
   202     mForm->setModel(mModel);
   253     mForm->setModel(mModel);
   203 
   254 
   204     // Connect signal to add validators
   255     // Connect signal to add validators
   205     bool connected = connect(mForm, SIGNAL( itemShown(const QModelIndex&) ), this,
   256     bool connected = connect(
       
   257         mForm, 
       
   258         SIGNAL( itemShown(const QModelIndex&) ), 
       
   259         this,
   206         SLOT( setValidator(const QModelIndex) ));
   260         SLOT( setValidator(const QModelIndex) ));
   207     Q_ASSERT(connected); 
   261     Q_ASSERT(connected); 
   208     
   262     
   209     // Expand TLS based method settings group
   263     // Expand TLS based method settings group
   210     mForm->setExpanded(mModel->indexFromItem(mGroupItem), true);
   264     mForm->setExpanded(mModel->indexFromItem(mGroupItem), true);
       
   265     
       
   266     // If EAP-FAST expand also PAC store group
       
   267     if (mPluginInfo.pluginHandle() == EapQtPluginHandle::PluginEapFast) {
       
   268         mForm->setExpanded(mModel->indexFromItem(mGroupItemPacStore), true);    
       
   269     }
   211 }
   270 }
   212 
   271 
   213 /*!
   272 /*!
   214  * Creates EAP-TLS settings UI
   273  * Creates EAP-TLS settings UI
   215  */
   274  */
   261     // according PEAP version
   320     // according PEAP version
   262     if (mDefaultPluginInUse) {
   321     if (mDefaultPluginInUse) {
   263         defaultInnerPlugin();
   322         defaultInnerPlugin();
   264     }
   323     }
   265 }
   324 }
       
   325 
       
   326 /*!
       
   327  * Creates EAP-FAST settings UI
       
   328  */
       
   329 void CpEapTlsMethodsUi::createFastUi()
       
   330 {
       
   331     qDebug("CpEapTlsMethodsUi::createFastUi()");
       
   332     
       
   333     // Create provisioning selection
       
   334     createProvisioning();
       
   335     
       
   336     // Create common TLS settings componenets
       
   337     createAuthorityCerts();
       
   338     createUserCerts();
       
   339     createUsername();
       
   340     createRealm();
       
   341     
       
   342     // Create TLS privacy
       
   343     createTlsPrivacy();
       
   344     
       
   345     // Create Inner Eap type selection comboBox and configuration button
       
   346     createInnerMethod();
       
   347   
       
   348     // Create second Inner EAP type
       
   349     createSecondInnerMethod();
       
   350     
       
   351     // Create PAC store group
       
   352     createPacStoreGroup();
       
   353     
       
   354     // Dim fields according the provisioning mode (parameter not used)
       
   355     provisioningModeChanged(Qt::Checked);
       
   356     // Dim Second inner EAP type configure button if 'Not in use' selected
       
   357     secondInnerEapTypeChanged(mCurrentSecondInnerPlugin);
       
   358 }
       
   359 
   266 /*!
   360 /*!
   267  * Creates Username group:
   361  * Creates Username group:
   268  * Generate automatically checkBox and username lineEdit
   362  * Generate automatically checkBox and username lineEdit
   269  */
   363  */
   270 void CpEapTlsMethodsUi::createUsername()
   364 void CpEapTlsMethodsUi::createUsername()
   271 {
   365 {
   272     qDebug("CpEapTlsMethodsUi::createUsername()");
   366     qDebug("CpEapTlsMethodsUi::createUsername()");
   273     // UsernameAutomatic
   367     // UsernameAutomatic
   274     mUsernameAutomatic = new CpSettingFormItemData(HbDataFormModelItem::CheckBoxItem, hbTrId(
   368     mUsernameAutomatic = new CpSettingFormItemData(
   275         "txt_occ_setlabel_user_name"));
   369         HbDataFormModelItem::CheckBoxItem, 
   276     mUsernameAutomatic->setContentWidgetData("text", hbTrId(
   370         hbTrId("txt_occ_setlabel_user_name"));
   277         "txt_occ_setlabel_user_name_val_generate_automatica"));
   371     mGroupItem->appendChild(mUsernameAutomatic);
       
   372     
       
   373     mUsernameAutomatic->setContentWidgetData(
       
   374         "objectName", 
       
   375         "CpEapTlsMethodsUiUsernameAutomatic"); 
       
   376     mUsernameAutomatic->setContentWidgetData(
       
   377         "text", 
       
   378         hbTrId("txt_occ_setlabel_user_name_val_generate_automatica"));
       
   379     
   278     // Initialize the value from EapQtConfig
   380     // Initialize the value from EapQtConfig
   279     // Generate username automatically is selected by default
   381     // Generate username automatically is selected by default
   280     mUsernameAutomatic->setContentWidgetData("checkState", boolToCheckState(mEapConfig.value(
   382     mUsernameAutomatic->setContentWidgetData(
   281         EapQtConfig::UsernameAutomatic).toBool()));
   383         "checkState", 
       
   384         boolToCheckState(mEapConfig.value(EapQtConfig::UsernameAutomatic).toBool()));
       
   385     
   282     // Connect signal to disable/enable username when usernameAutomatic changed   
   386     // Connect signal to disable/enable username when usernameAutomatic changed   
   283     mForm->addConnection(mUsernameAutomatic, SIGNAL(stateChanged(int)), this,
   387     mForm->addConnection(
       
   388         mUsernameAutomatic, 
       
   389         SIGNAL(stateChanged(int)), 
       
   390         this,
   284         SLOT(usernameAutomaticChanged(int)));
   391         SLOT(usernameAutomaticChanged(int)));
   285     mGroupItem->appendChild(mUsernameAutomatic);
       
   286 
   392 
   287     //Username
   393     //Username
   288     mUsername = new CpSettingFormItemData(HbDataFormModelItem::TextItem, hbTrId(
   394     mUsername = new CpSettingFormItemData(
   289         "txt_occ_setlabel_user_name"));
   395         HbDataFormModelItem::TextItem, 
       
   396         hbTrId("txt_occ_setlabel_user_name"));
       
   397     mGroupItem->appendChild(mUsername);    
       
   398     mUsername->setContentWidgetData("objectName", "CpEapTlsMethodsUiUsername");
   290     mUsername->setContentWidgetData("text", mEapConfig.value(EapQtConfig::Username));
   399     mUsername->setContentWidgetData("text", mEapConfig.value(EapQtConfig::Username));
       
   400     
   291     // Dim username if usernameAutomatic selected
   401     // Dim username if usernameAutomatic selected
   292     usernameAutomaticChanged(mUsernameAutomatic->contentWidgetData("checkState") == Qt::Checked);
   402     usernameAutomaticChanged(mUsernameAutomatic->contentWidgetData("checkState") == Qt::Checked);
   293     mGroupItem->appendChild(mUsername);
       
   294 }
   403 }
   295 
   404 
   296 /*!
   405 /*!
   297  * Creates Realm group:
   406  * Creates Realm group:
   298  * Generate automatically checkBox and realm lineEdit
   407  * Generate automatically checkBox and realm lineEdit
   299  */
   408  */
   300 void CpEapTlsMethodsUi::createRealm()
   409 void CpEapTlsMethodsUi::createRealm()
   301 {
   410 {
   302     qDebug("CpEapTlsMethodsUi::createRealm()");
   411     qDebug("CpEapTlsMethodsUi::createRealm()");
   303     // RealmAutomatic
   412     // RealmAutomatic
   304     mRealmAutomatic = new CpSettingFormItemData(HbDataFormModelItem::CheckBoxItem, hbTrId(
   413     mRealmAutomatic = new CpSettingFormItemData(
   305         "txt_occ_setlabel_realm"));
   414         HbDataFormModelItem::CheckBoxItem, 
   306     mRealmAutomatic->setContentWidgetData("text", hbTrId(
   415         hbTrId("txt_occ_setlabel_realm"));
   307         "txt_occ_setlabel_realm_val_generate_automatically"));
   416     mGroupItem->appendChild(mRealmAutomatic);
       
   417     
       
   418     mRealmAutomatic->setContentWidgetData("objectName", "CpEapTlsMethodsUiRealmAutomatic");
       
   419     mRealmAutomatic->setContentWidgetData(
       
   420         "text", 
       
   421         hbTrId("txt_occ_setlabel_realm_val_generate_automatically"));
       
   422     
   308     // Initialize the value from EapQtConfig
   423     // Initialize the value from EapQtConfig
   309     // Generate realm automatically is selected by default
   424     // Generate realm automatically is selected by default
   310     mRealmAutomatic->setContentWidgetData("checkState", boolToCheckState(mEapConfig.value(
   425     mRealmAutomatic->setContentWidgetData(
   311         EapQtConfig::RealmAutomatic).toBool()));
   426         "checkState", 
       
   427         boolToCheckState(mEapConfig.value(EapQtConfig::RealmAutomatic).toBool()));
       
   428     
   312     // connect signal to disable/enable realm when realmAutomatic changed 
   429     // connect signal to disable/enable realm when realmAutomatic changed 
   313     mForm->addConnection(mRealmAutomatic, SIGNAL(stateChanged(int)), this,
   430     mForm->addConnection(
       
   431         mRealmAutomatic, 
       
   432         SIGNAL(stateChanged(int)), 
       
   433         this,
   314         SLOT(realmAutomaticChanged(int)));
   434         SLOT(realmAutomaticChanged(int)));
   315     mGroupItem->appendChild(mRealmAutomatic);
       
   316 
   435 
   317     //Realm
   436     //Realm
   318     mRealm = new CpSettingFormItemData(HbDataFormModelItem::TextItem, hbTrId(
   437     mRealm = new CpSettingFormItemData(
   319         "txt_occ_setlabel_realm"));
   438         HbDataFormModelItem::TextItem, 
       
   439         hbTrId("txt_occ_setlabel_realm"));
       
   440     mGroupItem->appendChild(mRealm); 
       
   441     
       
   442     mRealm->setContentWidgetData("objectName", "CpEapTlsMethodsUiRealm");
   320     mRealm->setContentWidgetData("text", mEapConfig.value(EapQtConfig::Realm));
   443     mRealm->setContentWidgetData("text", mEapConfig.value(EapQtConfig::Realm));
       
   444     
   321     // Dim realm if realmAutomatic selected
   445     // Dim realm if realmAutomatic selected
   322     realmAutomaticChanged(mRealmAutomatic->contentWidgetData("checkState") == Qt::Checked);
   446     realmAutomaticChanged(mRealmAutomatic->contentWidgetData("checkState") == Qt::Checked);
   323     mGroupItem->appendChild(mRealm); 
       
   324 }
   447 }
   325 
   448 
   326 /*!
   449 /*!
   327  * Creates User certificate selection comboBox
   450  * Creates User certificate selection comboBox
   328  */
   451  */
   329 void CpEapTlsMethodsUi::createUserCerts()
   452 void CpEapTlsMethodsUi::createUserCerts()
   330 {
   453 {
   331     qDebug("CpEapTlsMethodsUi::createUserCerts()");
   454     qDebug("CpEapTlsMethodsUi::createUserCerts()");
   332     // Create User certificate comboBox
   455     // Create User certificate comboBox
   333     CpSettingFormItemData *userCertList = new CpSettingFormItemData(
   456     mUserCertificate = new CpSettingFormItemData(
   334         HbDataFormModelItem::ComboBoxItem, 
   457         HbDataFormModelItem::ComboBoxItem, 
   335         hbTrId("txt_occ_setlabel_user_certificate"));
   458         hbTrId("txt_occ_setlabel_user_certificate"));
       
   459     mGroupItem->appendChild(mUserCertificate);
       
   460     
       
   461     mUserCertificate->setContentWidgetData("objectName", "CpEapTlsMethodsUiUserCertSelector");
   336     
   462     
   337     // Stored certificate
   463     // Stored certificate
   338     QList<QVariant> storedCertsList = mEapConfig.value(EapQtConfig::UserCertificate).toList();
   464     QList<QVariant> storedCertsList = mEapConfig.value(EapQtConfig::UserCertificate).toList();
   339     EapQtCertificateInfo storedCert;
   465     EapQtCertificateInfo storedCert;
   340     if (!storedCertsList.empty() && storedCertsList[0].canConvert<EapQtCertificateInfo> ()) {
   466     if (!storedCertsList.empty() && storedCertsList[FirstItem].canConvert<EapQtCertificateInfo> ()) {
   341         // Stored certificate found, index is still unknown 
   467         // Stored certificate found, index is still unknown 
   342         storedCert = storedCertsList[0].value<EapQtCertificateInfo> ();
   468         storedCert = storedCertsList[FirstItem].value<EapQtCertificateInfo> ();
   343         mCurrentUserCert = UnknownIndex;
   469         mCurrentUserCert = UnknownIndex;
   344     }
   470     } else {
   345     else {
       
   346         // no stored certificate, use 'not in use'
   471         // no stored certificate, use 'not in use'
   347         mCurrentUserCert = DefaultIndex;
   472         mCurrentUserCert = DefaultIndex;
   348     }
   473     }
   349 
   474 
   350     // User certificates found from system
   475     // User certificates found from system
   358     for (int i = 0; i < mUserCerts.count(); ++i) {
   483     for (int i = 0; i < mUserCerts.count(); ++i) {
   359         items << mUserCerts.at(i).value(EapQtCertificateInfo::CertificateLabel).toString();
   484         items << mUserCerts.at(i).value(EapQtCertificateInfo::CertificateLabel).toString();
   360         if (mCurrentUserCert == UnknownIndex 
   485         if (mCurrentUserCert == UnknownIndex 
   361             && storedCert.value(EapQtCertificateInfo::SubjectKeyId)
   486             && storedCert.value(EapQtCertificateInfo::SubjectKeyId)
   362             == mUserCerts.at(i).value(EapQtCertificateInfo::SubjectKeyId)) {
   487             == mUserCerts.at(i).value(EapQtCertificateInfo::SubjectKeyId)) {
   363             mCurrentUserCert = i + 1;
   488             mCurrentUserCert = i + NotInUseShift;
   364         }
   489         }
   365     }
   490     }
   366     if (mCurrentUserCert == UnknownIndex) {
   491     if (mCurrentUserCert == UnknownIndex) {
   367         // Stored certificate not found in the certificate list
   492         // Stored certificate not found in the certificate list
   368         qDebug("CpEapTlsMethodsUi::createUserCerts() - stored certificate not in the list");
   493         qDebug("CpEapTlsMethodsUi::createUserCerts() - stored certificate not in the list");
   369         mCurrentUserCert = DefaultIndex;
   494         mCurrentUserCert = DefaultIndex;
   370     }
   495     }
   371     
   496     
   372     // Initialize comboBox
   497     // Initialize comboBox
   373     userCertList->setContentWidgetData("items", items);
   498     mUserCertificate->setContentWidgetData("items", items);
   374     userCertList->setContentWidgetData("currentIndex", mCurrentUserCert);
   499     mUserCertificate->setContentWidgetData("currentIndex", mCurrentUserCert);
   375     
   500     
   376     // Get info when user certificate selection has been changed
   501     // Get info when user certificate selection has been changed
   377     mForm->addConnection(userCertList, SIGNAL(currentIndexChanged(int)), this,
   502     mForm->addConnection(mUserCertificate, SIGNAL(currentIndexChanged(int)), this,
   378         SLOT(userCertChanged(int)));
   503         SLOT(userCertChanged(int)));
   379     mGroupItem->appendChild(userCertList);
       
   380 }
   504 }
   381 
   505 
   382 /*!
   506 /*!
   383  * Creates Authority certs group:
   507  * Creates Authority certs group:
   384  * Select automatically check box and certificate comboBox
   508  * Select automatically check box and certificate comboBox
   385  */
   509  */
   386 void CpEapTlsMethodsUi::createAuthorityCerts()
   510 void CpEapTlsMethodsUi::createAuthorityCerts()
   387 {
   511 {
   388     qDebug("CpEapTlsMethodsUi::createAuthorityCerts()");
   512     qDebug("CpEapTlsMethodsUi::createAuthorityCerts()");
   389     // Select Authority Certificate Automatically
   513     // Select Authority Certificate Automatically
   390     mCaCertAutomatic = new CpSettingFormItemData(HbDataFormModelItem::CheckBoxItem, hbTrId(
   514     mCaCertAutomatic = new CpSettingFormItemData(
   391         "txt_occ_setlabel_authority_certificate"));
   515         HbDataFormModelItem::CheckBoxItem, 
   392     mCaCertAutomatic->setContentWidgetData("text", hbTrId(
   516         hbTrId("txt_occ_setlabel_authority_certificate"));
   393         "txt_occ_setlabel_authority_certificate_val_select"));
   517     mGroupItem->appendChild(mCaCertAutomatic);
       
   518     
       
   519     mCaCertAutomatic->setContentWidgetData("objectName", "CpEapTlsMethodsUiCaCertAutomatic");
       
   520     mCaCertAutomatic->setContentWidgetData(
       
   521         "text", 
       
   522         hbTrId("txt_occ_setlabel_authority_certificate_val_select"));
       
   523     
   394     // Initialize the value from EapQtConfig
   524     // Initialize the value from EapQtConfig
   395     // Select CA Cert automatically is selected by default
   525     // Select CA Cert automatically is selected by default
   396     mCaCertAutomatic->setContentWidgetData("checkState", boolToCheckState(mEapConfig.value(
   526     mCaCertAutomatic->setContentWidgetData(
   397         EapQtConfig::AuthorityCertificateAutomatic).toBool()));
   527         "checkState", 
       
   528         boolToCheckState(mEapConfig.value(EapQtConfig::AuthorityCertificateAutomatic).toBool()));
       
   529     
   398     // connect signal to disable/enable CA cert when CaCertAutomatic changed 
   530     // connect signal to disable/enable CA cert when CaCertAutomatic changed 
   399     mForm->addConnection(mCaCertAutomatic, SIGNAL(stateChanged(int)), this,
   531     mForm->addConnection(
       
   532         mCaCertAutomatic, 
       
   533         SIGNAL(stateChanged(int)), 
       
   534         this,
   400         SLOT(authorityCertAutomaticChanged(int)));
   535         SLOT(authorityCertAutomaticChanged(int)));
   401     mGroupItem->appendChild(mCaCertAutomatic);
       
   402     
   536     
   403     // Authority certificate comboBox
   537     // Authority certificate comboBox
   404     mCaCert = new CpSettingFormItemData(HbDataFormModelItem::ComboBoxItem, 
   538     mCaCert = new CpSettingFormItemData(
       
   539         HbDataFormModelItem::ComboBoxItem, 
   405         hbTrId("txt_occ_setlabel_authority_certificate"));
   540         hbTrId("txt_occ_setlabel_authority_certificate"));
       
   541     mGroupItem->appendChild(mCaCert);
       
   542     
       
   543     mCaCert->setContentWidgetData("objectName", "CpEapTlsMethodsUiCaCertSelector");
   406     
   544     
   407     // Stored certificate from EAP configuration
   545     // Stored certificate from EAP configuration
   408     QList<QVariant> storedCertsList = mEapConfig.value(EapQtConfig::AuthorityCertificate).toList();
   546     QList<QVariant> storedCertsList = mEapConfig.value(EapQtConfig::AuthorityCertificate).toList();
   409     EapQtCertificateInfo storedCert;
   547     EapQtCertificateInfo storedCert;
   410     if (!storedCertsList.empty() && storedCertsList[0].canConvert<EapQtCertificateInfo> ()) {
   548     if (!storedCertsList.empty() && storedCertsList[FirstItem].canConvert<EapQtCertificateInfo> ()) {
   411         // Stored certificate found, index is still unknown 
   549         // Stored certificate found, index is still unknown 
   412         storedCert = storedCertsList[0].value<EapQtCertificateInfo> ();
   550         storedCert = storedCertsList[FirstItem].value<EapQtCertificateInfo> ();
   413         mCurrentAuthorityCert = UnknownIndex;
   551         mCurrentAuthorityCert = UnknownIndex;
   414     }
   552     } else {
   415     else {
       
   416         // no selected certificate, use 'not in use'
   553         // no selected certificate, use 'not in use'
   417         mCurrentAuthorityCert = DefaultIndex;
   554         mCurrentAuthorityCert = DefaultIndex;
   418     }
   555     }
   419 
   556 
   420     // Authority certificates found from system
   557     // Authority certificates found from system
   428     for (int i = 0; i < mAuthorityCerts.count(); ++i) {
   565     for (int i = 0; i < mAuthorityCerts.count(); ++i) {
   429         items << mAuthorityCerts.at(i).value(EapQtCertificateInfo::CertificateLabel).toString();
   566         items << mAuthorityCerts.at(i).value(EapQtCertificateInfo::CertificateLabel).toString();
   430         if (mCurrentAuthorityCert == UnknownIndex 
   567         if (mCurrentAuthorityCert == UnknownIndex 
   431             && storedCert.value(EapQtCertificateInfo::SubjectKeyId)
   568             && storedCert.value(EapQtCertificateInfo::SubjectKeyId)
   432             == mAuthorityCerts.at(i).value(EapQtCertificateInfo::SubjectKeyId)) {
   569             == mAuthorityCerts.at(i).value(EapQtCertificateInfo::SubjectKeyId)) {
   433             mCurrentAuthorityCert = i + 1;
   570             mCurrentAuthorityCert = i + NotInUseShift;
   434         }
   571         }
   435     }
   572     }
   436     if (mCurrentAuthorityCert == UnknownIndex) {
   573     if (mCurrentAuthorityCert == UnknownIndex) {
   437         // Selected certificate not found in the certificate list
   574         // Selected certificate not found in the certificate list
   438         mCurrentAuthorityCert = DefaultIndex;
   575         mCurrentAuthorityCert = DefaultIndex;
   441     // Initialize Authority certificates comboBox
   578     // Initialize Authority certificates comboBox
   442     mCaCert->setContentWidgetData("items", items);
   579     mCaCert->setContentWidgetData("items", items);
   443     mCaCert->setContentWidgetData("currentIndex", mCurrentAuthorityCert);
   580     mCaCert->setContentWidgetData("currentIndex", mCurrentAuthorityCert);
   444     
   581     
   445     // Get info when authority certificate selection has been changed
   582     // Get info when authority certificate selection has been changed
   446     mForm->addConnection(mCaCert, SIGNAL(currentIndexChanged(int)), this,
   583     mForm->addConnection(
       
   584         mCaCert, 
       
   585         SIGNAL(currentIndexChanged(int)), 
       
   586         this,
   447         SLOT(authorityCertChanged(int)));
   587         SLOT(authorityCertChanged(int)));
       
   588     
   448     // Dim authority certificate if select automatically checked
   589     // Dim authority certificate if select automatically checked
   449     authorityCertAutomaticChanged(mCaCertAutomatic->contentWidgetData("checkState") == Qt::Checked);
   590     authorityCertAutomaticChanged(mCaCertAutomatic->contentWidgetData("checkState") == Qt::Checked);
   450     mGroupItem->appendChild(mCaCert);
       
   451 }
   591 }
   452 
   592 
   453 /*!
   593 /*!
   454  * Creates PEAP version selection comboBox
   594  * Creates PEAP version selection comboBox
   455  */
   595  */
   458     qDebug("CpEapTlsMethodsUi::createPeapVersion()");
   598     qDebug("CpEapTlsMethodsUi::createPeapVersion()");
   459     // Create PEAP version comboBox
   599     // Create PEAP version comboBox
   460     mPeapVersion = new CpSettingFormItemData(
   600     mPeapVersion = new CpSettingFormItemData(
   461         HbDataFormModelItem::ComboBoxItem, 
   601         HbDataFormModelItem::ComboBoxItem, 
   462         hbTrId("txt_occ_setlabel_peap_version"));
   602         hbTrId("txt_occ_setlabel_peap_version"));
       
   603     mGroupItem->appendChild(mPeapVersion);
       
   604     
       
   605     mPeapVersion->setContentWidgetData("objectName", "CpEapTlsMethodsUiPeapVersionSelector");
   463     
   606     
   464     // Add items to comboBox List
   607     // Add items to comboBox List
   465     QStringList items;
   608     QStringList items;
   466     items << hbTrId("txt_occ_setlabel_peap_version_val_peapv0")
   609     items << hbTrId("txt_occ_setlabel_peap_version_val_peapv0")
   467         << hbTrId("txt_occ_setlabel_peap_version_val_peapv1")
   610         << hbTrId("txt_occ_setlabel_peap_version_val_peapv1")
   471     // Initialize PEAP version from EAP configuration
   614     // Initialize PEAP version from EAP configuration
   472     if (mEapConfig.value(EapQtConfig::PeapVersion0Allowed).toBool()
   615     if (mEapConfig.value(EapQtConfig::PeapVersion0Allowed).toBool()
   473         && mEapConfig.value(EapQtConfig::PeapVersion1Allowed).toBool()) {
   616         && mEapConfig.value(EapQtConfig::PeapVersion1Allowed).toBool()) {
   474         // PEAPv0 or PEAPv1
   617         // PEAPv0 or PEAPv1
   475         mCurrentPeapVersion = PeapVersionBoth;
   618         mCurrentPeapVersion = PeapVersionBoth;
   476     }
   619     } else if (mEapConfig.value(EapQtConfig::PeapVersion1Allowed).toBool()) {
   477     else if (mEapConfig.value(EapQtConfig::PeapVersion1Allowed).toBool()) {
       
   478         // PEAPv1
   620         // PEAPv1
   479         mCurrentPeapVersion = PeapVersion1;
   621         mCurrentPeapVersion = PeapVersion1;
   480     }
   622     } else if (mEapConfig.value(EapQtConfig::PeapVersion0Allowed).toBool()) {
   481     else if (mEapConfig.value(EapQtConfig::PeapVersion0Allowed).toBool()) {
       
   482         // PEAPv0
   623         // PEAPv0
   483         mCurrentPeapVersion = PeapVersion0;
   624         mCurrentPeapVersion = PeapVersion0;
   484     }
   625     } else {
   485     else {
       
   486         qDebug("CpEapTlsMethodsUi::createPeapVersion() - unknown version");    
   626         qDebug("CpEapTlsMethodsUi::createPeapVersion() - unknown version");    
   487         // Set default (PEAPv0 or PEAPv1)
   627         // Set default (PEAPv0 or PEAPv1)
   488         mCurrentPeapVersion = PeapVersionBoth;
   628         mCurrentPeapVersion = PeapVersionBoth;
   489     }
   629     }
   490     mPeapVersion->setContentWidgetData("currentIndex", mCurrentPeapVersion);
   630     mPeapVersion->setContentWidgetData("currentIndex", mCurrentPeapVersion);
   491 
   631 
   492     // Get info when PEAP version selection has been changed
   632     // Get info when PEAP version selection has been changed
   493     mForm->addConnection(mPeapVersion, SIGNAL(currentIndexChanged(int)), this,
   633     mForm->addConnection(
       
   634         mPeapVersion, 
       
   635         SIGNAL(currentIndexChanged(int)), 
       
   636         this,
   494         SLOT(peapVersionChanged(int)));
   637         SLOT(peapVersionChanged(int)));
   495     mGroupItem->appendChild(mPeapVersion);
   638 }
       
   639 
       
   640 /*!
       
   641  * Creates authenticated and unauthenticated provisioning checkBoxes.
       
   642  */
       
   643 void CpEapTlsMethodsUi::createProvisioning()
       
   644 {
       
   645     qDebug("CpEapTlsMethodsUi::createProvisioning()");
       
   646     // Authenticated provisioning
       
   647     mAuthProvisioning = new CpSettingFormItemData(
       
   648         HbDataFormModelItem::CheckBoxItem, 
       
   649         hbTrId("txt_occ_setlabel_authenticated_provisioning"));
       
   650     mGroupItem->appendChild(mAuthProvisioning);
       
   651     
       
   652     mAuthProvisioning->setContentWidgetData(
       
   653         "objectName", 
       
   654         "CpEapTlsMethodsUiAuthProvisioning");
       
   655     mAuthProvisioning->setContentWidgetData(
       
   656         "text", 
       
   657         hbTrId("txt_occ_setlabel_val_provisioning_enabled"));
       
   658     
       
   659     // Initialize the value from EapQtConfig
       
   660     mAuthProvisioning->setContentWidgetData(
       
   661         "checkState", 
       
   662         boolToCheckState(mEapConfig.value(
       
   663         EapQtConfig::ProvisioningModeAuthenticated).toBool()));
       
   664     // Connect signal to disable/enable username when usernameAutomatic changed   
       
   665     mForm->addConnection(mAuthProvisioning, SIGNAL(stateChanged(int)), this,
       
   666         SLOT(provisioningModeChanged(int)));
       
   667     
       
   668     // Unauthenticated provisioning
       
   669     mUnauthProvisioning = new CpSettingFormItemData(
       
   670         HbDataFormModelItem::CheckBoxItem, 
       
   671         hbTrId("txt_occ_setlabel_unauthenticated_provisioning"));
       
   672     mGroupItem->appendChild(mUnauthProvisioning); 
       
   673     
       
   674     mUnauthProvisioning->setContentWidgetData(
       
   675         "objectName", 
       
   676         "CpEapTlsMethodsUiUnauthProvisioning");
       
   677     mUnauthProvisioning->setContentWidgetData(
       
   678         "text", 
       
   679         hbTrId("txt_occ_setlabel_val_provisioning_enabled"));
       
   680     
       
   681     // Initialize the value from EapQtConfig
       
   682     mUnauthProvisioning->setContentWidgetData(
       
   683         "checkState", 
       
   684         boolToCheckState(mEapConfig.value(
       
   685         EapQtConfig::ProvisioningModeUnauthenticated).toBool()));
       
   686     // Connect signal to disable/enable username when usernameAutomatic changed   
       
   687     mForm->addConnection(mUnauthProvisioning, SIGNAL(stateChanged(int)), this,
       
   688         SLOT(provisioningModeChanged(int)));
       
   689 }
       
   690 
       
   691 /*!
       
   692  * Creates TLS privacy selection comboBox
       
   693  */
       
   694 void CpEapTlsMethodsUi::createTlsPrivacy()
       
   695 {
       
   696     qDebug("CpEapTlsMethodsUi::createTlsPrivacy()");
       
   697     // Create TLS privacy comboBox
       
   698     mTlsPrivacy = new CpSettingFormItemData(
       
   699         HbDataFormModelItem::ComboBoxItem, 
       
   700         hbTrId("txt_occ_setlabel_tls_privacy"));
       
   701     mGroupItem->appendChild(mTlsPrivacy);
       
   702     
       
   703     mTlsPrivacy->setContentWidgetData(
       
   704         "objectName", 
       
   705         "CpEapTlsMethodsUiTlsPrivacy");
       
   706     
       
   707     // Add items to comboBox List
       
   708     QStringList items;
       
   709     items << hbTrId("txt_occ_setlabel_tls_privacy_val_off")
       
   710         << hbTrId("txt_occ_setlabel_tls_privacy_val_on");
       
   711     mTlsPrivacy->setContentWidgetData("items", items);
       
   712     
       
   713     // Initialize TLS privacy from EAP configuration
       
   714     if (mEapConfig.value(EapQtConfig::UseIdentityPrivacy).toBool()) {
       
   715         mTlsPrivacy->setContentWidgetData("currentIndex", TlsPrivacyOn);
       
   716     } else {
       
   717         mTlsPrivacy->setContentWidgetData("currentIndex", TlsPrivacyOff);
       
   718     }
   496 }
   719 }
   497 
   720 
   498 /*!
   721 /*!
   499  * Creates inner EAP type selection comboBox and configure button
   722  * Creates inner EAP type selection comboBox and configure button
   500  */
   723  */
   503     qDebug("CpEapTlsMethodsUi::createInnerMethod()");
   726     qDebug("CpEapTlsMethodsUi::createInnerMethod()");
   504     // Create inner EAP type selection combo box
   727     // Create inner EAP type selection combo box
   505     createEapSelector();
   728     createEapSelector();
   506     // Create 'configure inner EAP type' button
   729     // Create 'configure inner EAP type' button
   507     EapInnerMethodEntryItemData *eapEntry = NULL;
   730     EapInnerMethodEntryItemData *eapEntry = NULL;
   508     eapEntry = new EapInnerMethodEntryItemData(this, *mItemDataHelper,
   731     eapEntry = new EapInnerMethodEntryItemData(
   509         hbTrId("txt_occ_button_inner_eap_type"));
   732         this, 
       
   733         *mItemDataHelper,
       
   734         hbTrId("txt_occ_button_inner_eap_type"),
       
   735         false);
       
   736     
       
   737     eapEntry->setContentWidgetData("objectName", "CpEapTlsMethodsUiInnerTypeItem");
       
   738     
   510     mGroupItem->appendChild(eapEntry);    
   739     mGroupItem->appendChild(eapEntry);    
   511 }
   740 }
   512 
   741 
   513 /*!
   742 /*!
   514  * Creates Combo box for inner EAP type selection
   743  * Creates Combo box for inner EAP type selection
   516 void CpEapTlsMethodsUi::createEapSelector()
   745 void CpEapTlsMethodsUi::createEapSelector()
   517 {
   746 {
   518     mInnerEapType = new CpSettingFormItemData(
   747     mInnerEapType = new CpSettingFormItemData(
   519         HbDataFormModelItem::ComboBoxItem, 
   748         HbDataFormModelItem::ComboBoxItem, 
   520         hbTrId("txt_occ_setlabel_inner_eap_type"));
   749         hbTrId("txt_occ_setlabel_inner_eap_type"));
   521 
   750     mGroupItem->appendChild(mInnerEapType);
       
   751     
       
   752     mInnerEapType->setContentWidgetData("objectName", "CpEapTlsMethodsUiInnerTypeSelector");
       
   753     
   522     // Selected inner EAP type stored into the database
   754     // Selected inner EAP type stored into the database
   523     QList<QVariant> currentEapList = mEapConfig.value(EapQtConfig::InnerType).toList();
   755     QList<QVariant> currentEapList = mEapConfig.value(EapQtConfig::InnerType).toList();
   524     EapQtPluginHandle readInnerEap;
   756     EapQtPluginHandle readInnerEap;
   525     if (!currentEapList.empty() && currentEapList[0].canConvert<EapQtPluginHandle> ()) {
   757     if (!currentEapList.empty() && currentEapList[FirstItem].canConvert<EapQtPluginHandle> ()) {
   526         readInnerEap = currentEapList[0].value<EapQtPluginHandle> ();
   758         readInnerEap = currentEapList[FirstItem].value<EapQtPluginHandle> ();
   527         mCurrentInnerPlugin = UnknownIndex;
   759         mCurrentInnerPlugin = UnknownIndex;
   528     }
   760     } else {
   529     else {
       
   530         // no selected inner EAP type, use the first one
   761         // no selected inner EAP type, use the first one
   531         mCurrentInnerPlugin = DefaultIndex;
   762         mCurrentInnerPlugin = DefaultIndex;
   532         mDefaultPluginInUse = true;
   763         mDefaultPluginInUse = true;
   533     }
   764     }
   534     
   765     
   535     QStringList items;
       
   536     for (int i = 0; i < mPlugins.count(); ++i) {
   766     for (int i = 0; i < mPlugins.count(); ++i) {
   537         // Add certificate to comboBox list
   767         // Add certificate to comboBox list
   538         items << mPlugins.at(i).localizationId();
   768         mInnerEapItems << mPlugins.at(i).localizationId();
   539         if (mCurrentInnerPlugin == UnknownIndex && readInnerEap.pluginId() 
   769         if (mCurrentInnerPlugin == UnknownIndex && readInnerEap.pluginId() 
   540             == mPlugins.at(i).pluginHandle().pluginId()) {
   770             == mPlugins.at(i).pluginHandle().pluginId()) {
   541             // Store index of selected certificate
   771             // Store index of selected certificate
   542             mCurrentInnerPlugin = i;
   772             mCurrentInnerPlugin = i;
   543         }
   773         }
   544         if (mPlugins.at(i).pluginHandle().pluginId() == EapQtPluginHandle::PluginEapMschapv2) {
   774         if (mPlugins.at(i).pluginHandle().pluginId() == EapQtPluginHandle::PluginEapMschapv2) {
   545             // Store index of EAP-MSCHAPv2 (used as default with PEAP and unauthenticated FAST)
   775             // Store index of EAP-MSCHAPv2 (used as default with PEAP and unauthenticated FAST)
   546             mInnerEapMschapv2 = i;
   776             mInnerEapMschapv2 = i;
   547         }
   777             mMschapv2Items << mPlugins.at(i).localizationId();
   548         else if (mPlugins.at(i).pluginHandle().pluginId() == EapQtPluginHandle::PluginEapGtc) {
   778         } else if (mPlugins.at(i).pluginHandle().pluginId() == EapQtPluginHandle::PluginEapGtc) {
   549             // Store index of EAP-GTC (Used as default with PEAPv1)
   779             // Store index of EAP-GTC (Used as default with PEAPv1)
   550             mInnerEapGtc = i;
   780             mInnerEapGtc = i;
   551         }
   781         }
   552     }
   782     }
   553     if (mCurrentInnerPlugin == UnknownIndex) {
   783     if (mCurrentInnerPlugin == UnknownIndex) {
   554         // Selected inner EAP type not found
   784         // Selected inner EAP type not found
   555         mCurrentInnerPlugin = DefaultIndex;
   785         mCurrentInnerPlugin = DefaultIndex;
   556         mDefaultPluginInUse = true;      
   786         mDefaultPluginInUse = true;      
   557     }
   787     }
   558     
   788     
   559     mInnerEapType->setContentWidgetData("items", items);
   789     mInnerEapType->setContentWidgetData("items", mInnerEapItems);
   560     mInnerEapType->setContentWidgetData("currentIndex", mCurrentInnerPlugin);
   790     mInnerEapType->setContentWidgetData("currentIndex", mCurrentInnerPlugin);
   561     
   791     
   562     mForm->addConnection(mInnerEapType, SIGNAL(currentIndexChanged(int)), this,
   792     mForm->addConnection(mInnerEapType, SIGNAL(currentIndexChanged(int)), this,
   563         SLOT(innerEapTypeChanged(int)));
   793         SLOT(innerEapTypeChanged(int)));
   564     
   794 }
   565     mGroupItem->appendChild(mInnerEapType);
   795 
       
   796 /*!
       
   797  * Creates second inner EAP type selection comboBox and configure button
       
   798  */
       
   799 void CpEapTlsMethodsUi::createSecondInnerMethod()
       
   800 {
       
   801     qDebug("CpEapTlsMethodsUi::createSecondInnerMethod()");
       
   802     // Create second inner EAP type selection combo box
       
   803     createSecondEapSelector();
       
   804     // Create 'configure inner EAP type' button
       
   805     mSecondEapEntry = new EapInnerMethodEntryItemData(
       
   806         this, 
       
   807         *mItemDataHelper,
       
   808         hbTrId("txt_occ_button_inner_eap_type"),
       
   809         true);
       
   810     
       
   811     mSecondEapEntry->setContentWidgetData("objectName", "CpEapTlsMethodsUiSecondInnerTypeItem");
       
   812     
       
   813     mGroupItem->appendChild(mSecondEapEntry);    
       
   814 }
       
   815 
       
   816 /*!
       
   817  * Creates Combo box for second inner EAP type selection
       
   818  */
       
   819 void CpEapTlsMethodsUi::createSecondEapSelector()
       
   820 {
       
   821     mSecondInnerEapType = new CpSettingFormItemData(
       
   822         HbDataFormModelItem::ComboBoxItem, 
       
   823         hbTrId("txt_occ_setlabel_second_inner_eap_type"));
       
   824     mGroupItem->appendChild(mSecondInnerEapType);
       
   825     
       
   826     mSecondInnerEapType->setContentWidgetData("objectName", "CpEapTlsMethodsUiSecondInnerTypeSelector");
       
   827 
       
   828     // Selected inner EAP type stored into the database
       
   829     QList<QVariant> currentEapList = mEapConfig.value(EapQtConfig::InnerType).toList();
       
   830     EapQtPluginHandle readInnerEap;
       
   831     if (currentEapList.count() > SecondItem && currentEapList[SecondItem].canConvert<EapQtPluginHandle> ()) {
       
   832         readInnerEap = currentEapList[SecondItem].value<EapQtPluginHandle> ();
       
   833         mCurrentSecondInnerPlugin = UnknownIndex;
       
   834     } else {
       
   835         // no selected inner EAP type, use the 'Not in use'
       
   836         mCurrentSecondInnerPlugin = NotInUseIndex;
       
   837     }
       
   838  
       
   839     // Add 'Not in use' and EAP-GTC into the combobox list
       
   840     QStringList items;
       
   841     items << hbTrId("txt_occ_setlabel_second_inner_eap_val_not_in_use");
       
   842     if (mInnerEapGtc >= 0) {
       
   843         // EAP-GTC plugin is found, add it as the second item of the list
       
   844         mSecondInnerEapGtc = SecondItem;
       
   845         items << mPlugins.at(mInnerEapGtc).localizationId();
       
   846         if (readInnerEap.pluginId() 
       
   847             == mPlugins.at(mInnerEapGtc).pluginHandle().pluginId()) {
       
   848             mCurrentSecondInnerPlugin = mSecondInnerEapGtc;
       
   849         }
       
   850     }
       
   851 
       
   852     if (mCurrentSecondInnerPlugin == UnknownIndex) {
       
   853         // Selected inner EAP type not found
       
   854         mCurrentSecondInnerPlugin = NotInUseIndex;     
       
   855     }
       
   856     
       
   857     mSecondInnerEapType->setContentWidgetData("items", items);
       
   858     mSecondInnerEapType->setContentWidgetData("currentIndex", mCurrentSecondInnerPlugin);
       
   859     
       
   860     mForm->addConnection(mSecondInnerEapType, SIGNAL(currentIndexChanged(int)), this,
       
   861         SLOT(secondInnerEapTypeChanged(int)));
       
   862 }
       
   863 
       
   864 /*!
       
   865  * Creates PAC store group
       
   866  */
       
   867 void CpEapTlsMethodsUi::createPacStoreGroup()
       
   868 {
       
   869     qDebug("CpEapTlsMethodsUi::createPacStoreGroup()");
       
   870     
       
   871     mPacStoreUi = new CpEapPacStoreUi(mConfigIf.data());
       
   872     mGroupItemPacStore = mPacStoreUi->uiInstance(
       
   873         *mItemDataHelper);
       
   874  
       
   875     mGroupItemPacStore->setContentWidgetData("objectName", "CpEapTlsMethodsUiPacStoreGroupItem");
       
   876     mModel->appendDataFormItem(mGroupItemPacStore);
   566 }
   877 }
   567 
   878 
   568 /*!
   879 /*!
   569  * Adds validators.
   880  * Adds validators.
   570  * 
   881  * 
   571  * @param modelIndex Model index
   882  * @param [in] modelIndex   Model index
   572  */
   883  */
   573 void CpEapTlsMethodsUi::setValidator(const QModelIndex modelIndex)
   884 void CpEapTlsMethodsUi::setValidator(const QModelIndex modelIndex)
   574 {
   885 {
   575     qDebug("CpEapTlsMethodsUi::itemActivated");
   886     qDebug("CpEapTlsMethodsUi::itemActivated");
   576 
   887 
   578         (mForm->itemByIndex(modelIndex));
   889         (mForm->itemByIndex(modelIndex));
   579     HbDataFormModelItem *modelItem = mModel->itemFromIndex(modelIndex);
   890     HbDataFormModelItem *modelItem = mModel->itemFromIndex(modelIndex);
   580     
   891     
   581     if (modelItem == mUsername) {
   892     if (modelItem == mUsername) {
   582         // When username lineEdit is activated (shown) first time, validator is added
   893         // When username lineEdit is activated (shown) first time, validator is added
   583         mValidatorUsername.reset(mConfigIf->validatorEap(mPluginInfo.pluginHandle().type(),
   894         mValidatorUsername.reset(
   584             EapQtConfig::Username));
   895             mConfigIf->validatorEap(
       
   896                 mPluginInfo.pluginHandle().type(),
       
   897                 EapQtConfig::Username));
       
   898         
   585         HbLineEdit *edit = qobject_cast<HbLineEdit *> (viewItem->dataItemContentWidget());
   899         HbLineEdit *edit = qobject_cast<HbLineEdit *> (viewItem->dataItemContentWidget());
   586         mValidatorUsername->updateEditor(edit);
   900         mValidatorUsername->updateEditor(edit);
   587     }
   901     } else if (modelItem == mRealm) {
   588     else if (modelItem == mRealm) {
       
   589         // When realm lineEdit is activated (shown) first time, validator is added
   902         // When realm lineEdit is activated (shown) first time, validator is added
   590         mValidatorRealm.reset(mConfigIf->validatorEap(mPluginInfo.pluginHandle().type(),
   903         mValidatorRealm.reset(
       
   904             mConfigIf->validatorEap(
       
   905                 mPluginInfo.pluginHandle().type(),
   591                 EapQtConfig::Realm));
   906                 EapQtConfig::Realm));
       
   907         
   592         HbLineEdit *edit = qobject_cast<HbLineEdit *> (viewItem->dataItemContentWidget());
   908         HbLineEdit *edit = qobject_cast<HbLineEdit *> (viewItem->dataItemContentWidget());
   593         mValidatorRealm->updateEditor(edit);
   909         mValidatorRealm->updateEditor(edit);
   594     }
   910     }
   595 }
   911 }
   596 
   912 
   598  * Sets default Inner EAP method according PEAP version
   914  * Sets default Inner EAP method according PEAP version
   599  */
   915  */
   600 void CpEapTlsMethodsUi::defaultInnerPlugin()
   916 void CpEapTlsMethodsUi::defaultInnerPlugin()
   601 {
   917 {
   602     qDebug("CpEapTlsMethodsUi::defaultInnerPlugin()");
   918     qDebug("CpEapTlsMethodsUi::defaultInnerPlugin()");
   603     if (mCurrentPeapVersion == PeapVersion1) {
   919     if (mCurrentPeapVersion == PeapVersion1 && mInnerEapGtc >= 0) {
   604         mInnerEapType->setContentWidgetData("currentIndex", mInnerEapGtc);
   920         mInnerEapType->setContentWidgetData("currentIndex", mInnerEapGtc);
   605         mCurrentInnerPlugin = mInnerEapGtc;
   921         mCurrentInnerPlugin = mInnerEapGtc;
   606     }
   922     } else if (mInnerEapMschapv2 >= 0){
   607     else {
       
   608         mInnerEapType->setContentWidgetData("currentIndex", mInnerEapMschapv2);
   923         mInnerEapType->setContentWidgetData("currentIndex", mInnerEapMschapv2);
   609         mCurrentInnerPlugin = mInnerEapMschapv2;
   924         mCurrentInnerPlugin = mInnerEapMschapv2;
   610     }  
   925     } else {
       
   926         // Both EAP-GTC and EAP-MSCHAPv2 should always be supported
       
   927         // so here should never come
       
   928         qDebug("CpEapTlsMethodsUi::defaultInnerPlugin(): No suitable inner EAP type");
       
   929     }
   611 }
   930 }
   612 
   931 
   613 /*!
   932 /*!
   614  * Stores the index of selected user certificate
   933  * Stores the index of selected user certificate
   615  * 
   934  * 
   616  * @param value Index of selected certificate.
   935  * @param [in] value  Index of selected certificate.
   617  */
   936  */
   618 void CpEapTlsMethodsUi::userCertChanged(int value)
   937 void CpEapTlsMethodsUi::userCertChanged(int value)
   619 {
   938 {
   620     qDebug("CpEapTlsMethodsUi::userCertChanged()");
   939     qDebug("CpEapTlsMethodsUi::userCertChanged()");
   621     mCurrentUserCert = value;
   940     mCurrentUserCert = value;
   622 }
   941 }
   623 
   942 
   624 /*!
   943 /*!
   625  * Stores the index of selected authority certificate
   944  * Stores the index of selected authority certificate
   626  * 
   945  * 
   627  * @param value Index of selected certificate.
   946  * @param [in] value  Index of selected certificate.
   628  */
   947  */
   629 void CpEapTlsMethodsUi::authorityCertChanged(int value)
   948 void CpEapTlsMethodsUi::authorityCertChanged(int value)
   630 {
   949 {
   631     qDebug("CpEapTlsMethodsUi::authorityCertChanged()");
   950     qDebug("CpEapTlsMethodsUi::authorityCertChanged()");
   632     mCurrentAuthorityCert = value;
   951     mCurrentAuthorityCert = value;
   633 }
   952 }
   634 
   953 
   635 /*!
   954 /*!
   636  * Stores the index of selected PEAP version
   955  * Stores the index of selected PEAP version
   637  * 
   956  * 
   638  * @param value Index of selected PEAP version.
   957  * @param [in] value  Index of selected PEAP version.
   639  */
   958  */
   640 void CpEapTlsMethodsUi::peapVersionChanged(int value)
   959 void CpEapTlsMethodsUi::peapVersionChanged(int value)
   641 {
   960 {
   642     qDebug("CpEapTlsMethodsUi::peapVersionChanged()");
   961     qDebug("CpEapTlsMethodsUi::peapVersionChanged()");
   643     mCurrentPeapVersion = value;
   962     mCurrentPeapVersion = value;
   645 }
   964 }
   646 
   965 
   647 /*!
   966 /*!
   648  * Stores the index of selected inner EAP type
   967  * Stores the index of selected inner EAP type
   649  * 
   968  * 
   650  * @param value Index of selected ineer EAP type.
   969  * @param [in] value  Index of selected inner EAP type.
   651  */
   970  */
   652 void CpEapTlsMethodsUi::innerEapTypeChanged(int value)
   971 void CpEapTlsMethodsUi::innerEapTypeChanged(int value)
   653 {
   972 {
   654     qDebug("CpEapTlsMethodsUi::innerEapTypeChanged()");
   973     qDebug("CpEapTlsMethodsUi::innerEapTypeChanged()");
   655     mCurrentInnerPlugin = value;
   974     if (!mInnerEapMschapv2Only) {
       
   975         mCurrentInnerPlugin = value; 
       
   976     }
       
   977     if (mPluginInfo.pluginHandle() == EapQtPluginHandle::PluginEapFast) {
       
   978         // If Inner EAP typ is EAP-MSCHAPv2 the second inner EAP type
       
   979         // is EAP-GTC by default otherwise 'Not in use'
       
   980         if (mInnerEapMschapv2Only || mCurrentInnerPlugin == mInnerEapMschapv2) {
       
   981             mSecondInnerEapType->setContentWidgetData(
       
   982                 "currentIndex", mSecondInnerEapGtc);
       
   983         } else {
       
   984             mSecondInnerEapType->setContentWidgetData(
       
   985                 "currentIndex", NotInUseIndex);                
       
   986         }
       
   987         if (mInnerEapMschapv2Only) {
       
   988             mSecondInnerEapType->setContentWidgetData("enabled", true);
       
   989         } else {
       
   990             mSecondInnerEapType->setContentWidgetData("enabled", false);
       
   991         }
       
   992     }
       
   993 }
       
   994 
       
   995 /*!
       
   996  * Stores the index of selected second inner EAP type and
       
   997  * dims the 'Configure inner EAP type' button if 'Not in use' has been selected
       
   998  * 
       
   999  * @param [in] value  Index of selected second inner EAP type.
       
  1000  */
       
  1001 void CpEapTlsMethodsUi::secondInnerEapTypeChanged(int value)
       
  1002 {
       
  1003     qDebug("CpEapTlsMethodsUi::secondInerEapTypeChanged()");
       
  1004     mCurrentSecondInnerPlugin = value;
       
  1005     if (value == NotInUseIndex || !mSecondInnerEapType->contentWidgetData("enabled").toBool()) {
       
  1006         // If 'Not in use' selected 'Configure inner EAP type' button is dimmed
       
  1007         mSecondEapEntry->setContentWidgetData("enabled", false);
       
  1008     } else {
       
  1009         // If EAP-GTC selected 'Configure inner EAP type' button is available
       
  1010         mSecondEapEntry->setContentWidgetData("enabled", true);
       
  1011     }
   656 }
  1012 }
   657 
  1013 
   658 /*!
  1014 /*!
   659  * Dims the username if generate username automatically has been selected.
  1015  * Dims the username if generate username automatically has been selected.
   660  * 
  1016  * 
   661  * @param state Tells is generate automatically checked.
  1017  * @param [in] state  Tells is username generate automatically checked.
   662  */
  1018  */
   663 void CpEapTlsMethodsUi::usernameAutomaticChanged(int state)
  1019 void CpEapTlsMethodsUi::usernameAutomaticChanged(int state)
   664 {
  1020 {
   665     qDebug("CpEapTlsMethodsUi::usernameAutomaticChanged");
  1021     qDebug("CpEapTlsMethodsUi::usernameAutomaticChanged");
   666 
  1022 
   668 }
  1024 }
   669 
  1025 
   670 /*!
  1026 /*!
   671  * Dims the realm if generate realm automatically has been selected.
  1027  * Dims the realm if generate realm automatically has been selected.
   672  * 
  1028  * 
   673  * @param state Tells is generate automatically checked.
  1029  * @param [in] state  Tells is realm generate automatically checked.
   674  */
  1030  */
   675 void CpEapTlsMethodsUi::realmAutomaticChanged(int state)
  1031 void CpEapTlsMethodsUi::realmAutomaticChanged(int state)
   676 {
  1032 {
   677     qDebug("CpEapTlsMethodsUi::realmAutomaticChanged");
  1033     qDebug("CpEapTlsMethodsUi::realmAutomaticChanged");
   678 
  1034 
   680 }
  1036 }
   681 
  1037 
   682 /*!
  1038 /*!
   683  * Dims the authority certificate if select caCert automatically has been selected.
  1039  * Dims the authority certificate if select caCert automatically has been selected.
   684  * 
  1040  * 
   685  * @param state Tells is select automatically checked.
  1041  * @param [in] state  Tells is authority certificate select automatically checked.
   686  */
  1042  */
   687 void CpEapTlsMethodsUi::authorityCertAutomaticChanged(int state)
  1043 void CpEapTlsMethodsUi::authorityCertAutomaticChanged(int state)
   688 {
  1044 {
   689     qDebug("CpEapTlsMethodsUi::authorityCertAutomaticChanged");
  1045     qDebug("CpEapTlsMethodsUi::authorityCertAutomaticChanged");
   690 
  1046 
   691     mCaCert->setContentWidgetData("enabled", !checkStateToBool(state));
  1047     mCaCert->setContentWidgetData("enabled", !checkStateToBool(state));
   692 }
  1048 }
   693 
  1049 
   694 /*!
  1050 /*!
       
  1051  * Dims all fields except inner EAP types and provisionig modes 
       
  1052  * if Unauthenticated provisioning mode is selected
       
  1053  * and Authenticated provisioning is not selceted
       
  1054  *
       
  1055  *  @param [in] state  Obsolete parameter, not needed
       
  1056  */
       
  1057 void CpEapTlsMethodsUi::provisioningModeChanged(int state)
       
  1058 {
       
  1059     qDebug("CpEapTlsMethodsUi::provisioningModeChanged");
       
  1060     
       
  1061     Q_UNUSED(state);
       
  1062     
       
  1063     // If only unauthenticated provisioning is selected all fields are dimmed 
       
  1064     // except the first (EAP-MSCHAPv2) and the second (EAP-GTC) inner EAP type 
       
  1065     // settings and authenticated provisioning can be selected
       
  1066     // Else all fields are available
       
  1067     if (mUnauthProvisioning->contentWidgetData(
       
  1068             "checkState") == Qt::Checked
       
  1069         && mAuthProvisioning->contentWidgetData(
       
  1070             "checkState") == Qt::Unchecked) {
       
  1071         mCaCertAutomatic->setContentWidgetData("enabled", false);
       
  1072         mCaCert->setContentWidgetData("enabled", false);
       
  1073         mUserCertificate->setContentWidgetData("enabled", false);
       
  1074         mUsernameAutomatic->setContentWidgetData("enabled", false);
       
  1075         mUsername->setContentWidgetData("enabled", false);
       
  1076         mRealmAutomatic->setContentWidgetData("enabled", false);
       
  1077         mRealm->setContentWidgetData("enabled", false);
       
  1078         mTlsPrivacy->setContentWidgetData("enabled", false);
       
  1079         mInnerEapMschapv2Only = true;
       
  1080         mSecondInnerEapType->setContentWidgetData("enabled", true);
       
  1081         mSecondEapEntry->setContentWidgetData("enabled", true);
       
  1082         mInnerEapType->setContentWidgetData("items", mMschapv2Items);
       
  1083     } else {
       
  1084         mCaCertAutomatic->setContentWidgetData("enabled", true);
       
  1085         mCaCert->setContentWidgetData("enabled", !checkStateToBool(
       
  1086             mCaCertAutomatic->contentWidgetData("checkState").toInt()));
       
  1087         mUserCertificate->setContentWidgetData("enabled", true);
       
  1088         mUsernameAutomatic->setContentWidgetData("enabled", true);
       
  1089         mUsername->setContentWidgetData("enabled", !checkStateToBool(
       
  1090             mUsernameAutomatic->contentWidgetData("checkState").toInt()));
       
  1091         mRealmAutomatic->setContentWidgetData("enabled", true);
       
  1092         mRealm->setContentWidgetData("enabled", !checkStateToBool(
       
  1093             mRealmAutomatic->contentWidgetData("checkState").toInt()));
       
  1094         mTlsPrivacy->setContentWidgetData("enabled", true);
       
  1095         if (mUnauthProvisioning->contentWidgetData(
       
  1096             "checkState") == Qt::Checked) {
       
  1097             // When Unauthenticated provisioning is selected only EAP-MSCHAPv2 is
       
  1098             // supported as first inner EAP type. Second inner EAP type is available
       
  1099             mInnerEapMschapv2Only = true;
       
  1100             mSecondInnerEapType->setContentWidgetData("enabled", true);
       
  1101             mSecondEapEntry->setContentWidgetData("enabled", true);
       
  1102             mInnerEapType->setContentWidgetData("items", mMschapv2Items);
       
  1103 
       
  1104         } else {
       
  1105             // When Unauthenticated provisioning is not selected all inner EAP
       
  1106             // types are shown in the first inner EAP type list and 
       
  1107             // the second inner EAP type is dimmed
       
  1108             mInnerEapMschapv2Only = false;
       
  1109             mForm->removeConnection(mInnerEapType, SIGNAL(currentIndexChanged(int)), this,
       
  1110                 SLOT(innerEapTypeChanged(int)));
       
  1111             mInnerEapType->setContentWidgetData("items", mInnerEapItems);
       
  1112             mForm->addConnection(mInnerEapType, SIGNAL(currentIndexChanged(int)), this,
       
  1113                 SLOT(innerEapTypeChanged(int)));
       
  1114             mInnerEapType->setContentWidgetData("currentIndex", mCurrentInnerPlugin);
       
  1115             mSecondInnerEapType->setContentWidgetData("enabled", false);
       
  1116             mSecondEapEntry->setContentWidgetData("enabled", false);
       
  1117         }
       
  1118     }
       
  1119 }
       
  1120 
       
  1121 /*!
       
  1122  * Slot for close the view after confirmed.
       
  1123  * 
       
  1124  * @param [in] action  User action
       
  1125  */
       
  1126 void CpEapTlsMethodsUi::incompletedSettingsConfirmed(int action)
       
  1127 {
       
  1128     qDebug("CpEapTlsMethodsUi::incompletedSettingsConfirmed()");
       
  1129     if (action == HbMessageBox::Yes) {
       
  1130         // User Clicked Yes
       
  1131         // Close view
       
  1132         qDebug("CpEapTlsMethodsUi::incompletedSettingsConfirmed(): YES");
       
  1133         emit aboutToClose();
       
  1134     } else{
       
  1135         // User Clicked No
       
  1136         // Don't close the view
       
  1137         Q_ASSERT(action == HbMessageBox::No);
       
  1138         qDebug("CpEapTlsMethodsUi::incompletedSettingsConfirmed(): NO");  
       
  1139     }
       
  1140 }
       
  1141 
       
  1142 /*!
       
  1143  * Slot for close the view after user has been informed.
       
  1144  * 
       
  1145  * @param [in] action  User action
       
  1146  */
       
  1147 void CpEapTlsMethodsUi::unableToSaveSettingsClosed(int action)
       
  1148 {
       
  1149     qDebug("CpEapTlsMethodsUi::unableToSaveSettingsClosed()");
       
  1150     if (action == HbMessageBox::Ok) {
       
  1151         // User Clicked Ok
       
  1152         // Close view
       
  1153         qDebug("CpEapTlsMethodsUi::unableToSaveSettingsClosed(): OK");
       
  1154         emit aboutToClose();
       
  1155     }    
       
  1156 }
       
  1157 
       
  1158 /*!
   695  * Converts check box state to boolean.
  1159  * Converts check box state to boolean.
   696  * 
  1160  * 
   697  * @param state Check box state
  1161  * @param [in] state  Check box state
   698  * 
  1162  * 
   699  * @return true if Check box is checked, false otherwise.
  1163  * @return true if Check box is checked, false otherwise.
   700  */
  1164  */
   701 bool CpEapTlsMethodsUi::checkStateToBool(const int state)
  1165 bool CpEapTlsMethodsUi::checkStateToBool(const int state)
   702 {
  1166 {
   704 }
  1168 }
   705 
  1169 
   706 /*!
  1170 /*!
   707  * Converts boolean to check box state.
  1171  * Converts boolean to check box state.
   708  * 
  1172  * 
   709  * @param state Tells is check box checked.
  1173  * @param [in] state  Tells is check box checked.
   710  * 
  1174  * 
   711  * @return Qt check state
  1175  * @return Qt check state
   712  */
  1176  */
   713 int CpEapTlsMethodsUi::boolToCheckState(const bool state)
  1177 int CpEapTlsMethodsUi::boolToCheckState(const bool state)
   714 {
  1178 {
   733         // Store settings
  1197         // Store settings
   734         if (storeSettings()){
  1198         if (storeSettings()){
   735             qDebug("CpEapTlsMethodsUi::close - Settings stored, close view");
  1199             qDebug("CpEapTlsMethodsUi::close - Settings stored, close view");
   736             // Close view
  1200             // Close view
   737             CpBaseSettingView::close();   
  1201             CpBaseSettingView::close();   
   738         }
  1202         } else {
   739         else {
       
   740             qDebug("CpEapTlsMethodsUi::close - Store settings failed, prompt warning");
  1203             qDebug("CpEapTlsMethodsUi::close - Store settings failed, prompt warning");
   741             // Store failed. Show error note to user
  1204             // Store failed. Show error note to user
   742             QScopedPointer<HbMessageBox> infoBox;
  1205             HbMessageBox *warningBox = new HbMessageBox(HbMessageBox::MessageTypeWarning);
   743             infoBox.reset(new HbMessageBox(
  1206             warningBox->setObjectName("CpEapTlsMethodsUiStoreFailedWarning");
   744                 HbMessageBox::MessageTypeWarning));
  1207             warningBox->setText(hbTrId("txt_occ_info_unable_to_save_setting"));
   745             infoBox->setText(hbTrId("txt_occ_info_unable_to_save_setting"));
  1208             warningBox->setAttribute(Qt::WA_DeleteOnClose);
   746             infoBox->clearActions();
  1209             warningBox->setStandardButtons(HbMessageBox::Ok);
   747             // Connect 'OK'-button to CpBaseSettingView 'aboutToClose'-signal
  1210             warningBox->open(this,SLOT(unableToSaveSettingsClosed(int)));
   748             HbAction *okAction = new HbAction(hbTrId("txt_common_button_ok"));
       
   749             infoBox->addAction(okAction);
       
   750             bool connected = connect(
       
   751                 okAction,
       
   752                 SIGNAL(triggered()),
       
   753                 this,
       
   754                 SIGNAL(aboutToClose()));
       
   755             Q_ASSERT(connected);
       
   756             infoBox->open();
       
   757             infoBox.take();
       
   758         }
  1211         }
   759     }
  1212     } else {
   760     else {
       
   761         qDebug("CpEapTlsMethodsUi::close - validation failed. Prompt question.");
  1213         qDebug("CpEapTlsMethodsUi::close - validation failed. Prompt question.");
   762 
  1214 
   763         // Validate failed. Request user to exit anyway
  1215         // Validate failed. Request user to exit anyway
   764         QScopedPointer<HbMessageBox> messageBox;
  1216         HbMessageBox *questionBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
   765         messageBox.reset(new HbMessageBox(
  1217         questionBox->setObjectName("CpEapTlsMethodsUiExitWithoutSavingQuestion");
   766             HbMessageBox::MessageTypeQuestion));
  1218         questionBox->setText(hbTrId("txt_occ_info_incomplete_details_return_without_sa"));
   767         messageBox->setAttribute(Qt::WA_DeleteOnClose);
  1219         questionBox->setAttribute(Qt::WA_DeleteOnClose);
   768         messageBox->setText(hbTrId("txt_occ_info_incomplete_details_return_without_sa"));
  1220         questionBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
   769         messageBox->clearActions();
  1221         questionBox->open(this,SLOT(incompletedSettingsConfirmed(int)));
   770         // Connect 'YES'-button to CpBaseSettingView 'aboutToClose'-signal
       
   771         HbAction *okAction = new HbAction(hbTrId("txt_common_button_yes"));
       
   772         messageBox->addAction(okAction);
       
   773         bool connected = connect(
       
   774             okAction,
       
   775             SIGNAL(triggered()),
       
   776             this,
       
   777             SIGNAL(aboutToClose()));
       
   778         Q_ASSERT(connected);
       
   779         // Clicking 'NO'-button does nothing
       
   780         HbAction *cancelAction = new HbAction(hbTrId("txt_common_button_no"));
       
   781         messageBox->addAction(cancelAction);
       
   782         messageBox->setTimeout(HbPopup::NoTimeout);
       
   783         messageBox->open();
       
   784         messageBox.take();
       
   785     }
  1222     }
   786 }
  1223 }
   787 
  1224 
   788 /*!
  1225 /*!
   789  * Validates settings configuration.
  1226  * Validates settings configuration.
   848  * @return true if OK, false otherwise.
  1285  * @return true if OK, false otherwise.
   849  */
  1286  */
   850 bool CpEapTlsMethodsUi::validateAuthorityCertificate()
  1287 bool CpEapTlsMethodsUi::validateAuthorityCertificate()
   851 {
  1288 {
   852     bool status = false;
  1289     bool status = false;
   853     //true if select automatically is checked or certificate is selected
  1290     if (mPluginInfo.pluginHandle() == EapQtPluginHandle::PluginEapFast) {
   854     if (mCaCertAutomatic->contentWidgetData("checkState") == Qt::Checked
  1291         // Always true for EAP-FAST
   855         || mCurrentAuthorityCert > NotInUseIndex) {
       
   856         status = true;
  1292         status = true;
       
  1293     } else {    
       
  1294         //true if select automatically is checked or certificate is selected
       
  1295         if (mCaCertAutomatic->contentWidgetData("checkState") == Qt::Checked
       
  1296             || mCurrentAuthorityCert > NotInUseIndex) {
       
  1297             status = true;
       
  1298         }
   857     }
  1299     }
   858     qDebug("CpEapTlsMethodsUi::validateAuthorityCertificate()- status: %d", status);
  1300     qDebug("CpEapTlsMethodsUi::validateAuthorityCertificate()- status: %d", status);
   859     return status;
  1301     return status;
   860 }
  1302 }
   861 
  1303 
   894 }
  1336 }
   895 
  1337 
   896 /*!
  1338 /*!
   897  * Write PEAP specific values into the EAP configuration
  1339  * Write PEAP specific values into the EAP configuration
   898  * 
  1340  * 
   899  * @param eapConfig
  1341  * @param [out] eapConfig  EAP configuration settings
   900  */
  1342  */
   901 void CpEapTlsMethodsUi::setPeapVersion(EapQtConfig &eapConfig)
  1343 void CpEapTlsMethodsUi::setPeapVersion(EapQtConfig &eapConfig)
   902 {
  1344 {
   903     qDebug("CpEapTlsMethodsUi::setPeapVersion()");
  1345     qDebug("CpEapTlsMethodsUi::setPeapVersion()");
   904     if (mCurrentPeapVersion == PeapVersion0) {
  1346     if (mCurrentPeapVersion == PeapVersion0) {
   905         eapConfig.setValue(EapQtConfig::PeapVersion0Allowed, true);
  1347         eapConfig.setValue(EapQtConfig::PeapVersion0Allowed, true);
   906         eapConfig.setValue(EapQtConfig::PeapVersion1Allowed, false);
  1348         eapConfig.setValue(EapQtConfig::PeapVersion1Allowed, false);
   907     }
  1349     } else if (mCurrentPeapVersion == PeapVersion1) {
   908     else if (mCurrentPeapVersion == PeapVersion1) {
       
   909         eapConfig.setValue(EapQtConfig::PeapVersion0Allowed, false);
  1350         eapConfig.setValue(EapQtConfig::PeapVersion0Allowed, false);
   910         eapConfig.setValue(EapQtConfig::PeapVersion1Allowed, true);            
  1351         eapConfig.setValue(EapQtConfig::PeapVersion1Allowed, true);            
   911     }
  1352     } else {
   912     else {
       
   913         Q_ASSERT(mCurrentPeapVersion == PeapVersionBoth);
  1353         Q_ASSERT(mCurrentPeapVersion == PeapVersionBoth);
   914         eapConfig.setValue(EapQtConfig::PeapVersion0Allowed, true);
  1354         eapConfig.setValue(EapQtConfig::PeapVersion0Allowed, true);
   915         eapConfig.setValue(EapQtConfig::PeapVersion1Allowed, true);            
  1355         eapConfig.setValue(EapQtConfig::PeapVersion1Allowed, true);            
   916     }    
  1356     }    
   917 }
  1357 }
   918 
  1358 
   919 /*!
  1359 /*!
       
  1360  * Write FAST specific values into the EAP configuration
       
  1361  * 
       
  1362  * @param [out] eapConfig  EAP configuration settings
       
  1363  */
       
  1364 void CpEapTlsMethodsUi::setFastSettings(EapQtConfig &eapConfig)
       
  1365 {
       
  1366     qDebug("CpEapTlsMethodsUi::setFastSettings()");
       
  1367     // Provisioning Mode
       
  1368     eapConfig.setValue(
       
  1369         EapQtConfig::ProvisioningModeAuthenticated,
       
  1370         checkStateToBool(mAuthProvisioning->contentWidgetData(
       
  1371             "checkState").toInt()));
       
  1372     eapConfig.setValue(
       
  1373         EapQtConfig::ProvisioningModeUnauthenticated,
       
  1374         checkStateToBool(mUnauthProvisioning->contentWidgetData(
       
  1375             "checkState").toInt()));
       
  1376     
       
  1377     // TLS privacy
       
  1378     if (mTlsPrivacy->contentWidgetData("currentIndex") == TlsPrivacyOn) {
       
  1379         eapConfig.setValue(EapQtConfig::UseIdentityPrivacy, true);
       
  1380     } else {
       
  1381         eapConfig.setValue(EapQtConfig::UseIdentityPrivacy, false);
       
  1382     }
       
  1383 }
       
  1384 
       
  1385 /*!
   920  * Stores settings given via TLS based methods setting UI
  1386  * Stores settings given via TLS based methods setting UI
   921  * 
  1387  * 
   922  * @return false if saving failed, true otherwise
  1388  * @return false if saving failed, true otherwise
   923  */
  1389  */
   924 bool CpEapTlsMethodsUi::storeSettings()
  1390 bool CpEapTlsMethodsUi::storeSettings()
   927 
  1393 
   928     EapQtConfig eapConfig;
  1394     EapQtConfig eapConfig;
   929 
  1395 
   930     // Store common settings
  1396     // Store common settings
   931     qDebug("CpEapTlsMethodsUi::storeSettings - Common settings");
  1397     qDebug("CpEapTlsMethodsUi::storeSettings - Common settings");
   932     eapConfig.setValue(EapQtConfig::OuterType, qVariantFromValue(mOuterHandle));
  1398     eapConfig.setValue(
   933     eapConfig.setValue(EapQtConfig::UsernameAutomatic, checkStateToBool(
  1399         EapQtConfig::OuterType, 
   934         mUsernameAutomatic->contentWidgetData("checkState").toInt()));
  1400         qVariantFromValue(mOuterHandle));
   935     eapConfig.setValue(EapQtConfig::Username, mUsername->contentWidgetData("text"));
  1401     
   936     eapConfig.setValue(EapQtConfig::RealmAutomatic, checkStateToBool(
  1402     eapConfig.setValue(
   937         mRealmAutomatic->contentWidgetData("checkState").toInt()));
  1403         EapQtConfig::UsernameAutomatic, 
   938     eapConfig.setValue(EapQtConfig::Realm, mRealm->contentWidgetData("text"));
  1404         checkStateToBool(mUsernameAutomatic->contentWidgetData("checkState").toInt()));
       
  1405     
       
  1406     eapConfig.setValue(
       
  1407         EapQtConfig::Username, 
       
  1408         mUsername->contentWidgetData("text"));
       
  1409     
       
  1410     eapConfig.setValue(
       
  1411         EapQtConfig::RealmAutomatic, 
       
  1412         checkStateToBool(mRealmAutomatic->contentWidgetData("checkState").toInt()));
       
  1413     
       
  1414     eapConfig.setValue(
       
  1415         EapQtConfig::Realm, 
       
  1416         mRealm->contentWidgetData("text"));
   939 
  1417 
   940     // User certificate
  1418     // User certificate
   941     qDebug("CpEapTlsMethodsUi::storeSettings - User certificate");
  1419     qDebug("CpEapTlsMethodsUi::storeSettings - User certificate");
   942     if (mCurrentUserCert > NotInUseIndex) {
  1420     if (mCurrentUserCert > NotInUseIndex) {
   943         QList<QVariant> userCerts;
  1421         QList<QVariant> userCerts;
   959     }    
  1437     }    
   960     
  1438     
   961     // Inner EAP method (Not valid for EAP-TLS)
  1439     // Inner EAP method (Not valid for EAP-TLS)
   962     if (!(mPluginInfo.pluginHandle() == EapQtPluginHandle::PluginEapTls)) {
  1440     if (!(mPluginInfo.pluginHandle() == EapQtPluginHandle::PluginEapTls)) {
   963         qDebug("CpEapTlsMethodsUi::storeSettings - Inner EAP method");
  1441         qDebug("CpEapTlsMethodsUi::storeSettings - Inner EAP method");
   964         QList<QVariant> innerEaps;
  1442         if (!mPlugins.isEmpty()) {
   965         innerEaps.append(qVariantFromValue(mPlugins.at(mCurrentInnerPlugin).pluginHandle()));
  1443             QList<QVariant> innerEaps;
   966         eapConfig.setValue(EapQtConfig::InnerType, innerEaps);
  1444             if (mInnerEapMschapv2Only) {
       
  1445                 innerEaps.append(qVariantFromValue(mPlugins.at(mInnerEapMschapv2).pluginHandle()));
       
  1446             } else {
       
  1447                 innerEaps.append(qVariantFromValue(mPlugins.at(mCurrentInnerPlugin).pluginHandle()));
       
  1448             }
       
  1449             if (mPluginInfo.pluginHandle() == EapQtPluginHandle::PluginEapFast){
       
  1450                 // Second inner eap can be 'Not in use' or EAP-GTC
       
  1451                 if (mCurrentSecondInnerPlugin != NotInUseIndex){
       
  1452                     innerEaps.append(qVariantFromValue(
       
  1453                         mPlugins.at(mInnerEapGtc).pluginHandle()));
       
  1454                 }
       
  1455             }
       
  1456             eapConfig.setValue(EapQtConfig::InnerType, innerEaps);
       
  1457         }
   967     }
  1458     }
   968 
  1459 
   969     // Cipher suites
  1460     // Cipher suites
   970     qDebug("CpEapTlsMethodsUi::storeSettings - Cipher suites");
  1461     qDebug("CpEapTlsMethodsUi::storeSettings - Cipher suites");
   971     eapConfig.setValue(EapQtConfig::CipherSuites, mGroupItemCs->ciphersuites());
  1462     eapConfig.setValue(EapQtConfig::CipherSuites, mGroupItemCs->ciphersuites());
   972     
  1463     
   973     // PEAP version (valid only for PEAP)
  1464 
   974     if (mPluginInfo.pluginHandle() == EapQtPluginHandle::PluginPeap) {
  1465     if (mPluginInfo.pluginHandle() == EapQtPluginHandle::PluginPeap) {
       
  1466         // PEAP version (valid only for PEAP)
   975         setPeapVersion(eapConfig);
  1467         setPeapVersion(eapConfig);
       
  1468     } else if (mPluginInfo.pluginHandle() == EapQtPluginHandle::PluginEapFast) {
       
  1469         // FAST specific settings
       
  1470         setFastSettings(eapConfig);
   976     }
  1471     }
   977     
  1472     
   978     // Save configuration
  1473     // Save configuration
   979     if (!mConfigIf->saveConfiguration(mPluginInfo.pluginHandle(), eapConfig)) {
  1474     if (!mConfigIf->saveConfiguration(mPluginInfo.pluginHandle(), eapConfig)) {
   980         qDebug("CpEapTlsMethodsUi::storeSettings - configuration saving failed.");
  1475         qDebug("CpEapTlsMethodsUi::storeSettings - configuration saving failed.");