wlanutilities/eapwizard/src/eapwizardpageinnertype.cpp
changeset 39 7b3e49e4608a
child 43 72ebcbb64834
child 50 d4198dcb9983
equal deleted inserted replaced
36:682dd021f9be 39:7b3e49e4608a
       
     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: Inner 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 <HbParameterLengthLimiter>
       
    26 #include <eapqtpluginhandle.h>
       
    27 #include <eapqtplugininfo.h>
       
    28 #include <eapqtconfiginterface.h>
       
    29 
       
    30 // User includes
       
    31 #include "wlanwizardhelper.h"
       
    32 #include "eapwizardpageinnertype.h"
       
    33 #include "eapwizard_p.h"
       
    34 
       
    35 
       
    36 /*!
       
    37    \class EapWizardPageInnerType
       
    38    \brief Implements EAP wizard page: Inner 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    @param [in] outerType Identifies the outer type: Peap or EapTtls
       
    55  */
       
    56 EapWizardPageInnerType::EapWizardPageInnerType(
       
    57     EapWizardPrivate* parent, int outerType) :
       
    58     EapWizardPage(parent), 
       
    59     mWidget(NULL), 
       
    60     mRadio(NULL), 
       
    61     mTitle(NULL),
       
    62     mDocumentLoader(NULL),    
       
    63     mOuterType(outerType),
       
    64     mValid(false)
       
    65 {
       
    66 }
       
    67 
       
    68 /*!
       
    69    Destructor.
       
    70  */
       
    71 EapWizardPageInnerType::~EapWizardPageInnerType()
       
    72 {
       
    73 }
       
    74 
       
    75 /*!
       
    76    See WlanWizardPage. 
       
    77  */
       
    78 HbWidget* EapWizardPageInnerType::initializePage()
       
    79 {
       
    80     if (!mWidget) {
       
    81         bool ok;
       
    82         mDocumentLoader.reset(
       
    83             new HbDocumentLoader(mWizard->wizardHelper()->mainWindow()));
       
    84         mDocumentLoader->load(":/docml/occ_eap_wizard_01_02_04.docml", &ok);
       
    85         Q_ASSERT(ok);
       
    86 
       
    87         loadDocmlSection(mWizard->wizardHelper()->mainWindow()->orientation());
       
    88         
       
    89         mWidget = qobject_cast<HbWidget*> (mDocumentLoader->findWidget("occ_eap_wizard_01"));
       
    90         Q_ASSERT(mWidget);
       
    91 
       
    92         mTitle = qobject_cast<HbLabel*> (mDocumentLoader->findWidget("title"));
       
    93         Q_ASSERT(mTitle);
       
    94 
       
    95         mRadio = qobject_cast<HbRadioButtonList*> (mDocumentLoader->findWidget("list"));
       
    96         Q_ASSERT(mRadio);
       
    97         
       
    98         ok = connect(
       
    99             mWizard->wizardHelper()->mainWindow(),
       
   100             SIGNAL(orientationChanged(Qt::Orientation)), 
       
   101             this, 
       
   102             SLOT(loadDocmlSection(Qt::Orientation)));
       
   103         Q_ASSERT(ok);
       
   104         
       
   105         QStringList list;
       
   106         switch (mOuterType){
       
   107         case EapQtPluginHandle::PluginPeap:
       
   108             appendToList(list, EapQtPluginHandle::PluginEapMschapv2);    
       
   109             break;
       
   110             
       
   111         default:
       
   112             Q_ASSERT(mOuterType == EapQtPluginHandle::PluginEapTtls);
       
   113             appendToList(list, EapQtPluginHandle::PluginPlainMschapv2);
       
   114             appendToList(list, EapQtPluginHandle::PluginPap);
       
   115             break;
       
   116         }
       
   117         appendToList(list, EapQtPluginHandle::PluginEapGtc);
       
   118         mRadio->setItems(list);
       
   119  
       
   120         ok = connect(mRadio, SIGNAL(itemSelected(int)), this, SLOT(itemSelected(int)));
       
   121         Q_ASSERT(ok);
       
   122     }
       
   123 
       
   124     mTitle->setPlainText(
       
   125         HbParameterLengthLimiter(
       
   126             hbTrId("txt_occ_title_select_innear_eap_type_for_1")).arg(
       
   127                 mWizard->eapTypeToString(
       
   128                     mWizard->configurations(
       
   129                         EapWizardPrivate::OuterType).toInt())));
       
   130 
       
   131     return mWidget;
       
   132 }
       
   133 
       
   134 /*!
       
   135    Loads the required orientation of docml.
       
   136    
       
   137    @param [in] orientation Orientation to be loaded. 
       
   138  */
       
   139 void EapWizardPageInnerType::loadDocmlSection(Qt::Orientation orientation)
       
   140 {
       
   141     EapWizardPage::loadDocmlSection(
       
   142         mDocumentLoader.data(),
       
   143         orientation,
       
   144         ":/docml/occ_eap_wizard_01_02_04.docml", 
       
   145         "portrait_section",
       
   146         "landscape_section");
       
   147 }
       
   148 
       
   149 /*!
       
   150    See WlanWizardPage.
       
   151    
       
   152    @return next wizard page: EapWizardPage::PageUsernamePassword
       
   153  */
       
   154 int EapWizardPageInnerType::nextId() const
       
   155 {
       
   156     mWizard->setConfigurations(
       
   157         EapWizardPrivate::InnerType, 
       
   158         mEapTypes.at(mRadio->selected()));
       
   159     
       
   160     return EapWizardPage::PageUsernamePassword;
       
   161 }
       
   162 
       
   163 /*!
       
   164    See WlanWizardPage.
       
   165    
       
   166    Validates the content of the page.
       
   167    
       
   168    @return true if content is valid.
       
   169  */
       
   170 bool EapWizardPageInnerType::showPage()
       
   171 {
       
   172     return mValid;
       
   173 }
       
   174 
       
   175 /*!
       
   176    Handler for itemsSelected() signal from HbRadioButtonList.
       
   177    
       
   178    @param [in] index NOT USED
       
   179  */
       
   180 void EapWizardPageInnerType::itemSelected(int index )
       
   181 {
       
   182     Q_UNUSED(index);
       
   183     mValid = true;
       
   184     mWizard->wizardHelper()->enableNextButton(mValid);
       
   185 }
       
   186 
       
   187 /*!
       
   188    Appends given method to radiobutton list if plugin (method) is supported
       
   189    
       
   190    @param [in,out] items the content of radiobutton list
       
   191    @param [in] pluginHandle EAP Type plugin handle to be added.
       
   192  */
       
   193 void EapWizardPageInnerType::appendToList(
       
   194     QStringList &items, 
       
   195     EapQtPluginHandle::Plugin innerType)
       
   196 {
       
   197     if (mWizard->eapConfigurationInterface()->isSupportedInnerType(
       
   198         static_cast<EapQtPluginHandle::Plugin>(mOuterType), innerType)) {
       
   199         items << mWizard->eapTypeToString(innerType);
       
   200         mEapTypes.append(innerType);
       
   201     }
       
   202 }