wlanutilities/eapwizard/src/eapwizardpagenewpacstore.cpp
changeset 39 7b3e49e4608a
child 43 72ebcbb64834
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: New PAC store password
       
    16  *
       
    17  */
       
    18 
       
    19 // System includes
       
    20 #include <HbDocumentLoader>
       
    21 #include <HbMainWindow>
       
    22 #include <HbWidget>
       
    23 #include <HbLineEdit>
       
    24 #include <HbLabel>
       
    25 #include <eapqtexpandedeaptype.h>
       
    26 #include <eapqtconfiginterface.h>
       
    27 #include <eapqtconfig.h>
       
    28 #include <eapqtvalidator.h>
       
    29 
       
    30 // User includes
       
    31 #include "wlanwizardhelper.h"
       
    32 #include "eapwizardpagenewpacstore.h"
       
    33 #include "eapwizard_p.h"
       
    34 
       
    35 /*!
       
    36    \class EapWizardPageNewPacStore
       
    37    \brief Implements EAP wizard page: New PAC store password
       
    38  */
       
    39 
       
    40 // External function prototypes
       
    41 
       
    42 // Local constants
       
    43 
       
    44 // ======== LOCAL FUNCTIONS ========
       
    45 
       
    46 // ======== MEMBER FUNCTIONS ========
       
    47 
       
    48 
       
    49 /*!
       
    50    Constructor.
       
    51    
       
    52    @param [in] parent Pointer to EAP Wizard private implementation.
       
    53  */
       
    54 EapWizardPageNewPacStore::EapWizardPageNewPacStore(
       
    55     EapWizardPrivate* parent) :
       
    56     EapWizardPage(parent), 
       
    57     mDocumentLoader(NULL), 
       
    58     mValidator(NULL),
       
    59     mWidget(NULL), 
       
    60     mEditPasswordNew(NULL),
       
    61     mEditPasswordConfirm(NULL), 
       
    62     mTitlePasswordNew(NULL), 
       
    63     mTitlePasswordConfirm(NULL)
       
    64 {
       
    65 }
       
    66 
       
    67 /*!
       
    68    Destructor.
       
    69  */
       
    70 EapWizardPageNewPacStore::~EapWizardPageNewPacStore()
       
    71 {
       
    72 }
       
    73 
       
    74 /*!
       
    75    See WlanWizardPage. 
       
    76  */
       
    77 HbWidget* EapWizardPageNewPacStore::initializePage()
       
    78 {
       
    79     if (!mWidget) {
       
    80         bool ok;
       
    81         mDocumentLoader.reset( 
       
    82             new HbDocumentLoader(mWizard->wizardHelper()->mainWindow()));
       
    83         mDocumentLoader->load(":/docml/occ_eap_wizard_05_07.docml", &ok);
       
    84         Q_ASSERT(ok);
       
    85         
       
    86         loadDocmlSection(mWizard->wizardHelper()->mainWindow()->orientation());
       
    87         
       
    88         mWidget = qobject_cast<HbWidget*> (mDocumentLoader->findWidget("view"));
       
    89         Q_ASSERT(mWidget);
       
    90 
       
    91         mTitlePasswordNew = qobject_cast<HbLabel*> (mDocumentLoader->findWidget("setlabel_55"));
       
    92         Q_ASSERT(mTitlePasswordNew);
       
    93 
       
    94         mTitlePasswordConfirm = qobject_cast<HbLabel*> (mDocumentLoader->findWidget("setlabel_56"));
       
    95         Q_ASSERT(mTitlePasswordConfirm);
       
    96 
       
    97         mEditPasswordNew = qobject_cast<HbLineEdit*> (mDocumentLoader->findWidget("lineEditUsername"));
       
    98         Q_ASSERT(mEditPasswordNew);
       
    99 
       
   100         mEditPasswordConfirm = qobject_cast<HbLineEdit*> (mDocumentLoader->findWidget("lineEditPassword"));
       
   101         Q_ASSERT(mEditPasswordConfirm);
       
   102         
       
   103         mValidator.reset( 
       
   104             mWizard->eapConfigurationInterface()->validatorPacStore(
       
   105                 EapQtPacStoreConfig::PacStorePassword));
       
   106         Q_ASSERT(mValidator.data());
       
   107         
       
   108         mTitlePasswordNew->setPlainText(hbTrId("txt_occ_setlabel_new_pac_store_password"));
       
   109         mTitlePasswordConfirm->setPlainText(hbTrId("txt_occ_setlabel_confirm_password"));
       
   110 
       
   111         // Configure editors properties
       
   112         mValidator->updateEditor(mEditPasswordNew);
       
   113         mValidator->updateEditor(mEditPasswordConfirm);
       
   114 
       
   115         ok = connect(
       
   116             mWizard->wizardHelper()->mainWindow(),
       
   117             SIGNAL(orientationChanged(Qt::Orientation)), 
       
   118             this, 
       
   119             SLOT(loadDocmlSection(Qt::Orientation)));
       
   120         Q_ASSERT(ok);
       
   121         
       
   122         ok = connect(
       
   123             mEditPasswordNew, SIGNAL(textChanged(const QString &)), 
       
   124             this, SLOT(textChanged(const QString &)));
       
   125         Q_ASSERT(ok);
       
   126         
       
   127         ok = connect(
       
   128             mEditPasswordConfirm, SIGNAL(textChanged(const QString &)), 
       
   129             this, SLOT(textChanged(const QString &)));
       
   130         Q_ASSERT(ok);
       
   131     }
       
   132     return mWidget;
       
   133 }
       
   134 
       
   135 /*!
       
   136    Loads the required orientation of docml.
       
   137    
       
   138    @param [in] orientation Orientation to be loaded. 
       
   139  */
       
   140 void EapWizardPageNewPacStore::loadDocmlSection(Qt::Orientation orientation)
       
   141 {
       
   142     EapWizardPage::loadDocmlSection(
       
   143         mDocumentLoader.data(),
       
   144         orientation,
       
   145         ":/docml/occ_eap_wizard_05_07.docml",
       
   146         "portrait_section",
       
   147         "landscape_section");
       
   148 }
       
   149 
       
   150 /*!
       
   151    See WlanWizardPage.
       
   152    
       
   153    Validates the content of the page.
       
   154    
       
   155    @return true if content is valid.
       
   156  */
       
   157 bool EapWizardPageNewPacStore::showPage()
       
   158 {
       
   159     bool valid = false;
       
   160     if (mValidator->validate(mEditPasswordNew->text()) == EapQtValidator::StatusOk &&
       
   161         mEditPasswordNew->text() == mEditPasswordConfirm->text()) {
       
   162         valid = true;
       
   163     }
       
   164     return valid;
       
   165 }
       
   166 
       
   167 /*!
       
   168    See WlanWizardPage.
       
   169    
       
   170    @return next wizard page: EapWizardPage::PageUsernamePassword
       
   171  */
       
   172 int EapWizardPageNewPacStore::nextId() const
       
   173 {
       
   174     mWizard->setConfigurations(EapWizardPrivate::PacStorePassword, mEditPasswordNew->text());
       
   175     return EapWizardPage::PageUsernamePassword;
       
   176 }
       
   177 
       
   178 /*!
       
   179    Slot for textChanged() signal from HbLineEdit.
       
   180    
       
   181    @param [in] text NOT USED.
       
   182  */
       
   183 void EapWizardPageNewPacStore::textChanged(const QString &text)
       
   184 {
       
   185     Q_UNUSED(text);
       
   186     mWizard->wizardHelper()->enableNextButton(showPage());
       
   187 }