wlanutilities/eapwizard/src/eapwizardpageinnertype.cpp
branchRCL_3
changeset 24 63be7eb3fc78
equal deleted inserted replaced
23:b852595f5cbe 24:63be7eb3fc78
       
     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 #include "OstTraceDefinitions.h"
       
    35 #ifdef OST_TRACE_COMPILER_IN_USE
       
    36 #include "eapwizardpageinnertypeTraces.h"
       
    37 #endif
       
    38 
       
    39 
       
    40 
       
    41 /*!
       
    42    \class EapWizardPageInnerType
       
    43    \brief Implements EAP wizard page: Inner EAP type selection.
       
    44  */
       
    45 
       
    46 // External function prototypes
       
    47 
       
    48 // Local constants
       
    49 
       
    50 // ======== LOCAL FUNCTIONS ========
       
    51 
       
    52 // ======== MEMBER FUNCTIONS ========
       
    53 
       
    54 
       
    55 /*!
       
    56    Constructor.
       
    57 
       
    58    @param [in] parent Pointer to EAP Wizard private implementation.
       
    59    @param [in] outerType Identifies the outer type: Peap or EapTtls
       
    60  */
       
    61 EapWizardPageInnerType::EapWizardPageInnerType(
       
    62     EapWizardPrivate* parent, int outerType) :
       
    63     EapWizardPage(parent), 
       
    64     mWidget(NULL), 
       
    65     mRadio(NULL), 
       
    66     mTitle(NULL),
       
    67     mDocumentLoader(NULL),    
       
    68     mOuterType(outerType),
       
    69     mValid(false)
       
    70 {
       
    71     OstTraceFunctionEntry0( EAPWIZARDPAGEINNERTYPE_EAPWIZARDPAGEINNERTYPE_ENTRY );
       
    72     OstTraceFunctionExit0( EAPWIZARDPAGEINNERTYPE_EAPWIZARDPAGEINNERTYPE_EXIT );
       
    73 }
       
    74 
       
    75 /*!
       
    76    Destructor.
       
    77  */
       
    78 EapWizardPageInnerType::~EapWizardPageInnerType()
       
    79 {
       
    80     OstTraceFunctionEntry0( DUP1_EAPWIZARDPAGEINNERTYPE_EAPWIZARDPAGEINNERTYPE_ENTRY );
       
    81     OstTraceFunctionExit0( DUP1_EAPWIZARDPAGEINNERTYPE_EAPWIZARDPAGEINNERTYPE_EXIT );
       
    82 }
       
    83 
       
    84 /*!
       
    85    See WlanWizardPage. 
       
    86  */
       
    87 HbWidget* EapWizardPageInnerType::initializePage()
       
    88 {
       
    89     OstTraceFunctionEntry0( EAPWIZARDPAGEINNERTYPE_INITIALIZEPAGE_ENTRY );
       
    90     if (!mWidget) {
       
    91         bool ok;
       
    92         mDocumentLoader.reset(
       
    93             new HbDocumentLoader(mWizard->wizardHelper()->mainWindow()));
       
    94         mDocumentLoader->load(":/docml/occ_eap_wizard_01_02_04.docml", &ok);
       
    95         Q_ASSERT(ok);
       
    96 
       
    97         loadDocmlSection(mWizard->wizardHelper()->mainWindow()->orientation());
       
    98 
       
    99         mWidget = qobject_cast<HbWidget*> (mDocumentLoader->findWidget("occ_eap_wizard_01"));
       
   100         Q_ASSERT(mWidget);
       
   101 
       
   102         mTitle = qobject_cast<HbLabel*> (mDocumentLoader->findWidget("title"));
       
   103         Q_ASSERT(mTitle);
       
   104 
       
   105         mRadio = qobject_cast<HbRadioButtonList*> (mDocumentLoader->findWidget("list"));
       
   106         Q_ASSERT(mRadio);
       
   107 
       
   108         ok = connect(
       
   109             mWizard->wizardHelper()->mainWindow(),
       
   110             SIGNAL(orientationChanged(Qt::Orientation)), 
       
   111             this, 
       
   112             SLOT(loadDocmlSection(Qt::Orientation)));
       
   113         Q_ASSERT(ok);
       
   114 
       
   115         QStringList list;
       
   116         switch (mOuterType){
       
   117         case EapQtPluginHandle::PluginPeap:
       
   118             appendToList(list, EapQtPluginHandle::PluginEapMschapv2);    
       
   119             break;
       
   120 
       
   121         default:
       
   122             Q_ASSERT(mOuterType == EapQtPluginHandle::PluginEapTtls);
       
   123             appendToList(list, EapQtPluginHandle::PluginPlainMschapv2);
       
   124             appendToList(list, EapQtPluginHandle::PluginPap);
       
   125             break;
       
   126         }
       
   127         appendToList(list, EapQtPluginHandle::PluginEapGtc);
       
   128         mRadio->setItems(list);
       
   129 
       
   130         ok = connect(mRadio, SIGNAL(itemSelected(int)), this, SLOT(itemSelected(int)));
       
   131         Q_ASSERT(ok);
       
   132     }
       
   133 
       
   134     mTitle->setPlainText(
       
   135         HbParameterLengthLimiter("txt_occ_title_select_innear_eap_type_for_1").arg(
       
   136             mWizard->eapTypeToString(
       
   137                 mWizard->configurations(
       
   138                     EapWizardPrivate::OuterType).toInt())));
       
   139 
       
   140     OstTraceFunctionExit0( EAPWIZARDPAGEINNERTYPE_INITIALIZEPAGE_EXIT );
       
   141     return mWidget;
       
   142 }
       
   143 
       
   144 /*!
       
   145    Loads the required orientation of docml.
       
   146 
       
   147    @param [in] orientation Orientation to be loaded. 
       
   148  */
       
   149 void EapWizardPageInnerType::loadDocmlSection(Qt::Orientation orientation)
       
   150 {
       
   151     OstTraceFunctionEntry0( EAPWIZARDPAGEINNERTYPE_LOADDOCMLSECTION_ENTRY );
       
   152     EapWizardPage::loadDocmlSection(
       
   153         mDocumentLoader.data(),
       
   154         orientation,
       
   155         ":/docml/occ_eap_wizard_01_02_04.docml", 
       
   156         "portrait_section",
       
   157         "landscape_section");
       
   158     OstTraceFunctionExit0( EAPWIZARDPAGEINNERTYPE_LOADDOCMLSECTION_EXIT );
       
   159 }
       
   160 
       
   161 /*!
       
   162    See WlanWizardPage.
       
   163 
       
   164    @return next wizard page: EapWizardPage::PageUsernamePassword
       
   165  */
       
   166 int EapWizardPageInnerType::nextId() const
       
   167 {
       
   168     OstTraceFunctionEntry0( EAPWIZARDPAGEINNERTYPE_NEXTID_ENTRY );
       
   169     mWizard->setConfigurations(
       
   170         EapWizardPrivate::InnerType, 
       
   171         mEapTypes.at(mRadio->selected()));
       
   172 
       
   173     OstTraceFunctionExit0( EAPWIZARDPAGEINNERTYPE_NEXTID_EXIT );
       
   174     return EapWizardPage::PageUsernamePassword;
       
   175 }
       
   176 
       
   177 /*!
       
   178    See WlanWizardPage.
       
   179 
       
   180    Validates the content of the page.
       
   181 
       
   182    @return true if content is valid.
       
   183  */
       
   184 bool EapWizardPageInnerType::showPage()
       
   185 {
       
   186     OstTraceFunctionEntry0( EAPWIZARDPAGEINNERTYPE_SHOWPAGE_ENTRY );
       
   187     OstTraceFunctionExit0( EAPWIZARDPAGEINNERTYPE_SHOWPAGE_EXIT );
       
   188     return mValid;
       
   189 }
       
   190 
       
   191 /*!
       
   192    Handler for itemsSelected() signal from HbRadioButtonList.
       
   193 
       
   194    @param [in] index NOT USED
       
   195  */
       
   196 void EapWizardPageInnerType::itemSelected(int index )
       
   197 {
       
   198     OstTraceFunctionEntry0( EAPWIZARDPAGEINNERTYPE_ITEMSELECTED_ENTRY );
       
   199     Q_UNUSED(index);
       
   200     mValid = true;
       
   201     mWizard->wizardHelper()->enableNextButton(mValid);
       
   202     OstTraceFunctionExit0( EAPWIZARDPAGEINNERTYPE_ITEMSELECTED_EXIT );
       
   203 }
       
   204 
       
   205 /*!
       
   206    Appends given method to radiobutton list if plugin (method) is supported
       
   207 
       
   208    @param [in,out] items the content of radiobutton list
       
   209    @param [in] pluginHandle EAP Type plugin handle to be added.
       
   210  */
       
   211 void EapWizardPageInnerType::appendToList(
       
   212     QStringList &items, 
       
   213     EapQtPluginHandle::Plugin innerType)
       
   214 {
       
   215     OstTraceFunctionEntry0( EAPWIZARDPAGEINNERTYPE_APPENDTOLIST_ENTRY );
       
   216     if (mWizard->eapConfigurationInterface()->isSupportedInnerType(
       
   217         static_cast<EapQtPluginHandle::Plugin>(mOuterType), innerType)) {
       
   218         items << mWizard->eapTypeToString(innerType);
       
   219         mEapTypes.append(innerType);
       
   220     }
       
   221     OstTraceFunctionExit0( EAPWIZARDPAGEINNERTYPE_APPENDTOLIST_EXIT );
       
   222 }