wlanutilities/eapwizard/src/eapwizardpageoutertype.cpp
changeset 46 2fbd1d709fe7
child 43 72ebcbb64834
equal deleted inserted replaced
45:d9ec2b8c6bad 46:2fbd1d709fe7
       
     1 /*
       
     2  * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description: 
       
    15  *   EAP Wizard Page: Outer type selection
       
    16  *
       
    17  */
       
    18 
       
    19 // System includes
       
    20 #include <HbDocumentLoader>
       
    21 #include <HbMainWindow>
       
    22 #include <HbWidget>
       
    23 #include <HbRadioButtonList>
       
    24 #include <HbLabel>
       
    25 #include <eapqtpluginhandle.h>
       
    26 #include <eapqtplugininfo.h>
       
    27 #include <eapqtconfiginterface.h>
       
    28 #include <eapqtconfig.h>
       
    29 #include <eapqtpacstoreconfig.h>
       
    30 
       
    31 // User includes
       
    32 #include "wlanwizardhelper.h"
       
    33 #include "eapwizard_p.h"
       
    34 #include "eapwizardpageoutertype.h"
       
    35 
       
    36 /*!
       
    37    \class EapWizardPageOuterType
       
    38    \brief Implements EAP wizard page: Outer EAP type selection
       
    39  */
       
    40 
       
    41 // External function prototypes
       
    42 
       
    43 // Local constants
       
    44 
       
    45 // ======== LOCAL FUNCTIONS ========
       
    46 
       
    47 // ======== MEMBER FUNCTIONS ========
       
    48 
       
    49 
       
    50 /*!
       
    51    Constructor.
       
    52    
       
    53    @param [in] parent Pointer to EAP Wizard private implementation.
       
    54  */
       
    55 EapWizardPageOuterType::EapWizardPageOuterType(EapWizardPrivate* parent) :
       
    56     EapWizardPage(parent),
       
    57     mWidget(NULL),
       
    58     mRadio(NULL),
       
    59     mTitle(NULL),
       
    60     mDocumentLoader(NULL),    
       
    61     mValid(false)
       
    62 {
       
    63 }
       
    64 
       
    65 /*!
       
    66    Destructor.
       
    67  */
       
    68 EapWizardPageOuterType::~EapWizardPageOuterType()
       
    69 {
       
    70 }
       
    71 
       
    72 /*!
       
    73    See WlanWizardPage. 
       
    74  */
       
    75 HbWidget* EapWizardPageOuterType::initializePage()
       
    76 {
       
    77     if (!mWidget) {
       
    78         bool ok;
       
    79         mDocumentLoader.reset(
       
    80             new HbDocumentLoader(mWizard->wizardHelper()->mainWindow()));
       
    81         mDocumentLoader->load(":/docml/occ_eap_wizard_01_02_04.docml", &ok);
       
    82         Q_ASSERT(ok);
       
    83         
       
    84         loadDocmlSection(mWizard->wizardHelper()->mainWindow()->orientation());
       
    85         
       
    86         mWidget = qobject_cast<HbWidget*> (mDocumentLoader->findWidget("occ_eap_wizard_01"));
       
    87         Q_ASSERT(mWidget);
       
    88 
       
    89         mRadio = qobject_cast<HbRadioButtonList*> (mDocumentLoader->findWidget("list"));
       
    90         Q_ASSERT(mRadio);
       
    91 
       
    92         mTitle = qobject_cast<HbLabel*> (mDocumentLoader->findWidget("title"));
       
    93         Q_ASSERT(mTitle);
       
    94         
       
    95         mTitle->setPlainText(hbTrId("txt_occ_title_select_eap_type"));
       
    96 
       
    97         QStringList items;
       
    98         appendToList(items, EapQtPluginHandle::PluginPeap);
       
    99         appendToList(items, EapQtPluginHandle::PluginEapTtls);
       
   100         appendToList(items, EapQtPluginHandle::PluginEapTls);
       
   101         appendToList(items, EapQtPluginHandle::PluginEapFast);
       
   102         appendToList(items, EapQtPluginHandle::PluginLeap);
       
   103         appendToList(items, EapQtPluginHandle::PluginEapAka);
       
   104         appendToList(items, EapQtPluginHandle::PluginEapSim);
       
   105         mRadio->setItems(items);
       
   106 
       
   107         ok = connect(
       
   108             mRadio, SIGNAL(itemSelected(int)), 
       
   109             this, SLOT(itemSelected(int)));
       
   110         Q_ASSERT(ok);
       
   111         
       
   112         ok = connect(
       
   113             mWizard->wizardHelper()->mainWindow(), 
       
   114             SIGNAL(orientationChanged(Qt::Orientation)), 
       
   115             this, 
       
   116             SLOT(loadDocmlSection(Qt::Orientation)));
       
   117         Q_ASSERT(ok);
       
   118     }
       
   119     return mWidget;
       
   120 }
       
   121 
       
   122 /*!
       
   123    Loads the required orientation of docml.
       
   124    
       
   125    @param [in] orientation Orientation to be loaded. 
       
   126  */
       
   127 void EapWizardPageOuterType::loadDocmlSection(Qt::Orientation orientation)
       
   128 {
       
   129     EapWizardPage::loadDocmlSection(
       
   130         mDocumentLoader.data(),
       
   131         orientation,
       
   132         ":/docml/occ_eap_wizard_01_02_04.docml",
       
   133         "portrait_section",
       
   134         "landscape_section");
       
   135 }
       
   136 
       
   137 /*!
       
   138    See WlanWizardPage.
       
   139    
       
   140    @return next wizard page:
       
   141    - WlanWizardPage::PageProcessSettings: For EAP-AKA and EAP-SIM
       
   142    - EapWizardPage::PageCertificateCa: For PEAP, EAP-TLS and EAP-TTLS 
       
   143    - EapWizardPage::PageUsernamePassword: For LEAP and EAP-FAST (pac confirmed)
       
   144    - EapWizardPage::PageNewPacStorePassword: For EAP-FAST (no pac store)
       
   145    - EapWizardPage::PagePromptPacStorePassword: For EAP-FAST (confirm pac store)
       
   146  */
       
   147 int EapWizardPageOuterType::nextId() const
       
   148 {
       
   149     int id = WlanWizardPage::PageNone;
       
   150     EapQtPluginHandle::Plugin handle = 
       
   151         static_cast<EapQtPluginHandle::Plugin>(mEapTypes.at(mRadio->selected()));
       
   152     switch (handle) {
       
   153     case EapQtPluginHandle::PluginPeap:
       
   154     case EapQtPluginHandle::PluginEapTtls:
       
   155     case EapQtPluginHandle::PluginEapTls:
       
   156         id = EapWizardPage::PageCertificateCa;
       
   157         break;
       
   158 
       
   159     case EapQtPluginHandle::PluginEapFast:
       
   160         id = nextIdForEapFast();
       
   161         break;
       
   162         
       
   163     case EapQtPluginHandle::PluginLeap:
       
   164         id = EapWizardPage::PageUsernamePassword;
       
   165         break;
       
   166 
       
   167     default:
       
   168         Q_ASSERT(EapQtPluginHandle::PluginEapAka == handle ||
       
   169             EapQtPluginHandle::PluginEapSim == handle);   
       
   170         id = WlanWizardPage::PageProcessSettings;
       
   171         break;
       
   172     }
       
   173     
       
   174     mWizard->setConfigurations(EapWizardPrivate::OuterType, handle);
       
   175 
       
   176     return id;
       
   177 }
       
   178 
       
   179 /*!
       
   180    See WlanWizardPage.
       
   181    
       
   182    Validates the content of the page.
       
   183    
       
   184    @return true if content is valid.
       
   185  */
       
   186 bool EapWizardPageOuterType::showPage()
       
   187 {
       
   188     return mValid;
       
   189 }
       
   190 
       
   191 /*!
       
   192    Slot for itemSelected() signal from HbRadioButtonList.
       
   193    
       
   194    @param [in] index NOT USED.
       
   195  */
       
   196 void EapWizardPageOuterType::itemSelected(int index)
       
   197 {
       
   198     Q_UNUSED(index);
       
   199     mValid = true;
       
   200     mWizard->wizardHelper()->enableNextButton(mValid);
       
   201 }
       
   202 
       
   203 /*!
       
   204    Appends given method to radiobutton list if plugin (method) is supported
       
   205    
       
   206    @param [in,out] items the content of radiobutton list
       
   207    @param [in] pluginHandle EAP Type plugin handle to be added.
       
   208  */
       
   209 void EapWizardPageOuterType::appendToList(
       
   210     QStringList &items, int pluginHandle)
       
   211 {
       
   212     if (mWizard->eapConfigurationInterface()->isSupportedOuterType(
       
   213         (EapQtPluginHandle::Plugin)pluginHandle)) {
       
   214         items << mWizard->eapTypeToString(pluginHandle);
       
   215         mEapTypes.append(pluginHandle);
       
   216     }
       
   217 }
       
   218 
       
   219 /*
       
   220    Getter for next page id when outer eap type is EAP-FAST.
       
   221    
       
   222    @return Page ID.
       
   223  */
       
   224 int EapWizardPageOuterType::nextIdForEapFast() const
       
   225 {
       
   226     int pageId;
       
   227     
       
   228     mWizard->setConfigurations(EapWizardPrivate::InnerType,
       
   229         EapQtPluginHandle::PluginEapMschapv2);
       
   230     
       
   231     EapQtPacStoreConfig pacStoreConf;
       
   232     int pacStoreState = EapQtPacStoreConfig::PacStoreStateStoreNotExists;
       
   233     
       
   234     if (mWizard->eapConfigurationInterface()->readPacStoreConfiguration(pacStoreConf)) {
       
   235         pacStoreState = pacStoreConf.value(EapQtPacStoreConfig::PacStoreState).toInt();   
       
   236     } else {
       
   237         pacStoreConf.clear();
       
   238         pacStoreConf.setValue(EapQtPacStoreConfig::PacStoreReset, true);
       
   239         mWizard->eapConfigurationInterface()->savePacStoreConfiguration(pacStoreConf);
       
   240     }
       
   241     
       
   242     mWizard->setConfigurations(EapWizardPrivate::PacStoreState, pacStoreState);
       
   243     
       
   244     switch (pacStoreState) {
       
   245     case EapQtPacStoreConfig::PacStoreStateStoreNotExists:
       
   246         pageId = EapWizardPage::PageNewPacStorePassword;
       
   247         break;
       
   248     
       
   249     case EapQtPacStoreConfig::PacStoreStatePasswordRequired:
       
   250         pageId = EapWizardPage::PagePromptPacStorePassword;
       
   251         break;
       
   252     
       
   253     default:
       
   254         Q_ASSERT(pacStoreState == EapQtPacStoreConfig::PacStoreStatePasswordStored);
       
   255         pageId = EapWizardPage::PageUsernamePassword;
       
   256         break;
       
   257     }
       
   258     
       
   259     return pageId;
       
   260 }