wlanutilities/wlanwizard/src/wlanwizardpagekeyquery.cpp
changeset 60 822a45792fdd
parent 49 fb81b597edf1
equal deleted inserted replaced
53:bdc64aa9b954 60:822a45792fdd
     1 /*
     1 /*
     2  * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3  * All rights reserved.
     3 * All rights reserved.
     4  * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5  * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6  * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8  *
     8 *
     9  * Initial Contributors:
     9 * Initial Contributors:
    10  * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11  *
    11 *
    12  * Contributors:
    12 * Contributors:
    13  *
    13 *
    14  * Description: 
    14 * Description: 
    15  *   WLAN Wizard Page: Key query page for WEP and WPA (2).
    15 * WLAN Wizard Page: Key query page for WEP and WPA (2).
    16  *
    16 */
    17  */
       
    18 
    17 
    19 // System includes
    18 // System includes
       
    19 
    20 #include <HbDocumentLoader>
    20 #include <HbDocumentLoader>
    21 #include <HbMainWindow>
    21 #include <HbMainWindow>
    22 #include <HbWidget>
    22 #include <HbWidget>
    23 #include <HbLabel>
    23 #include <HbLabel>
    24 #include <HbLineEdit>
    24 #include <HbLineEdit>
    25 #include <HbEditorInterface>
    25 #include <HbEditorInterface>
    26 #include <HbParameterLengthLimiter>
    26 #include <HbParameterLengthLimiter>
    27 
    27 
    28 // User includes
    28 // User includes
       
    29 
    29 #include "wlanwizard.h"
    30 #include "wlanwizard.h"
    30 #include "wlanwizard_p.h"
    31 #include "wlanwizard_p.h"
    31 #include "wlanwizardpagekeyquery.h"
    32 #include "wlanwizardpagekeyquery.h"
    32 #include "wlanwizardutils.h"
    33 #include "wlanwizardutils.h"
       
    34 
    33 #include "OstTraceDefinitions.h"
    35 #include "OstTraceDefinitions.h"
    34 #ifdef OST_TRACE_COMPILER_IN_USE
    36 #ifdef OST_TRACE_COMPILER_IN_USE
    35 #include "wlanwizardpagekeyqueryTraces.h"
    37 #include "wlanwizardpagekeyqueryTraces.h"
    36 #endif
    38 #endif
    37 
    39 
    61     mLabelTitle(NULL),
    63     mLabelTitle(NULL),
    62     mLineEdit(NULL), 
    64     mLineEdit(NULL), 
    63     mLabelError(NULL), 
    65     mLabelError(NULL), 
    64     mDocLoader(NULL)
    66     mDocLoader(NULL)
    65 {
    67 {
    66     OstTraceFunctionEntry0( WLANWIZARDPAGEKEYQUERY_WLANWIZARDPAGEKEYQUERY_ENTRY );
    68     OstTraceFunctionEntry0(WLANWIZARDPAGEKEYQUERY_WLANWIZARDPAGEKEYQUERY_ENTRY);
    67     OstTraceFunctionExit0( WLANWIZARDPAGEKEYQUERY_WLANWIZARDPAGEKEYQUERY_EXIT );
    69     OstTraceFunctionExit0(WLANWIZARDPAGEKEYQUERY_WLANWIZARDPAGEKEYQUERY_EXIT);
    68 }
    70 }
    69 
    71 
    70 /*!
    72 /*!
    71    Destructor.
    73    Destructor.
    72  */
    74  */
    73 WlanWizardPageKeyQuery::~WlanWizardPageKeyQuery()
    75 WlanWizardPageKeyQuery::~WlanWizardPageKeyQuery()
    74 {
    76 {
    75     OstTraceFunctionEntry0( DUP1_WLANWIZARDPAGEKEYQUERY_WLANWIZARDPAGEKEYQUERY_ENTRY );
    77     OstTraceFunctionEntry0(DUP1_WLANWIZARDPAGEKEYQUERY_WLANWIZARDPAGEKEYQUERY_ENTRY);
       
    78     
    76     delete mDocLoader;
    79     delete mDocLoader;
    77     
    80     
    78     // Wizard framework deletes the visualization (owns mWidget).
    81     // Wizard framework deletes the visualization (owns mWidget).
    79     OstTraceFunctionExit0( DUP1_WLANWIZARDPAGEKEYQUERY_WLANWIZARDPAGEKEYQUERY_EXIT );
    82     OstTraceFunctionExit0(DUP1_WLANWIZARDPAGEKEYQUERY_WLANWIZARDPAGEKEYQUERY_EXIT);
    80 }
    83 }
    81 
    84 
    82 /*!
    85 /*!
    83    See WlanWizardPage::initializePage()
    86    See WlanWizardPage::initializePage()
    84    
    87    
    85    Initializes the key query page and initializes objects based on the security
    88    Initializes the key query page and initializes objects based on the security
    86    mode.
    89    mode.
    87  */
    90  */
    88 HbWidget* WlanWizardPageKeyQuery::initializePage()
    91 HbWidget* WlanWizardPageKeyQuery::initializePage()
    89 {
    92 {
    90     OstTraceFunctionEntry0( WLANWIZARDPAGEKEYQUERY_INITIALIZEPAGE_ENTRY );
    93     OstTraceFunctionEntry0(WLANWIZARDPAGEKEYQUERY_INITIALIZEPAGE_ENTRY);
       
    94     
    91     if (!mWidget) {
    95     if (!mWidget) {
    92         bool ok;
    96         bool ok;
    93         
    97         
    94         mDocLoader = new HbDocumentLoader(mWizard->mainWindow());
    98         mDocLoader = new HbDocumentLoader(mWizard->mainWindow());
    95         
    99         
   135         mLineEdit->setMaxLength(WlanWizardUtils::WpaMaxLength);
   139         mLineEdit->setMaxLength(WlanWizardUtils::WpaMaxLength);
   136     }
   140     }
   137     
   141     
   138     mLabelTitle->setPlainText(
   142     mLabelTitle->setPlainText(
   139         HbParameterLengthLimiter("txt_occ_dialog_enter_key_for_1").arg(
   143         HbParameterLengthLimiter("txt_occ_dialog_enter_key_for_1").arg(
   140             mWizard->configuration(WlanWizardPrivate::ConfSsid).toString()));
   144             mWizard->configuration(WlanWizardPrivate::ConfName).toString()));
   141     
   145     
   142     OstTraceFunctionExit0( WLANWIZARDPAGEKEYQUERY_INITIALIZEPAGE_EXIT );
   146     OstTraceFunctionExit0(WLANWIZARDPAGEKEYQUERY_INITIALIZEPAGE_EXIT);
   143     return mWidget;
   147     return mWidget;
   144 }
   148 }
   145 
   149 
   146 /*!
   150 /*!
   147    Loads docml at initialization phase and when HbMainWindow sends orientation()
   151    Loads docml at initialization phase and when HbMainWindow sends orientation()
   149    
   153    
   150    @param [in] orientation to be loaded.
   154    @param [in] orientation to be loaded.
   151  */
   155  */
   152 void WlanWizardPageKeyQuery::loadDocmlSection(Qt::Orientation orientation)
   156 void WlanWizardPageKeyQuery::loadDocmlSection(Qt::Orientation orientation)
   153 {
   157 {
   154     OstTraceFunctionEntry0( WLANWIZARDPAGEKEYQUERY_LOADDOCMLSECTION_ENTRY );
   158     OstTraceFunctionEntry0(WLANWIZARDPAGEKEYQUERY_LOADDOCMLSECTION_ENTRY);
       
   159     
   155     WlanWizardPageInternal::loadDocmlSection(
   160     WlanWizardPageInternal::loadDocmlSection(
   156         mDocLoader,
   161         mDocLoader,
   157         orientation,
   162         orientation,
   158         ":/docml/occ_add_wlan_01_04.docml", 
   163         ":/docml/occ_add_wlan_01_04.docml", 
   159         "portrait_section",
   164         "portrait_section",
   160         "landscape_section");
   165         "landscape_section");
   161     OstTraceFunctionExit0( WLANWIZARDPAGEKEYQUERY_LOADDOCMLSECTION_EXIT );
   166     
       
   167     OstTraceFunctionExit0(WLANWIZARDPAGEKEYQUERY_LOADDOCMLSECTION_EXIT);
   162 }
   168 }
   163 
   169 
   164 /*!
   170 /*!
   165    See WlanWizardPage::nextId()
   171    See WlanWizardPage::nextId()
   166    
   172    
   173    internal configuration and WlanWizardPage::PageProcessSettings is returned.
   179    internal configuration and WlanWizardPage::PageProcessSettings is returned.
   174    
   180    
   175  */
   181  */
   176 int WlanWizardPageKeyQuery::nextId(bool &removeFromStack) const
   182 int WlanWizardPageKeyQuery::nextId(bool &removeFromStack) const
   177 {
   183 {
   178     OstTraceFunctionEntry0( WLANWIZARDPAGEKEYQUERY_NEXTID_ENTRY );
   184     OstTraceFunctionEntry0(WLANWIZARDPAGEKEYQUERY_NEXTID_ENTRY);
       
   185     
   179     WlanWizardUtils::KeyStatus status(WlanWizardUtils::KeyStatusOk);
   186     WlanWizardUtils::KeyStatus status(WlanWizardUtils::KeyStatusOk);
   180     int pageId = WlanWizardPage::nextId(removeFromStack);
   187     int pageId = WlanWizardPage::nextId(removeFromStack);
   181     int secMode = mWizard->configuration(
   188     int secMode = mWizard->configuration(
   182         WlanWizardPrivate::ConfSecurityMode).toInt();
   189         WlanWizardPrivate::ConfSecurityMode).toInt();
   183     
   190     
   209     else {
   216     else {
   210         mLabelError->setPlainText(errorString);
   217         mLabelError->setPlainText(errorString);
   211     }
   218     }
   212 
   219 
   213     removeFromStack = false;
   220     removeFromStack = false;
   214     OstTraceFunctionExit0( WLANWIZARDPAGEKEYQUERY_NEXTID_EXIT );
   221     
       
   222     OstTraceFunctionExit0(WLANWIZARDPAGEKEYQUERY_NEXTID_EXIT);
   215     return pageId;
   223     return pageId;
   216 }
   224 }
   217 
   225 
   218 /*!
   226 /*!
   219    See WlanWizardPage::showPage()
   227    See WlanWizardPage::showPage()
   220  */
   228  */
   221 bool WlanWizardPageKeyQuery::showPage()
   229 bool WlanWizardPageKeyQuery::showPage()
   222 {
   230 {
   223     OstTraceFunctionEntry0( WLANWIZARDPAGEKEYQUERY_SHOWPAGE_ENTRY );
   231     OstTraceFunctionEntry0(WLANWIZARDPAGEKEYQUERY_SHOWPAGE_ENTRY);
       
   232     
   224     // Open virtual keyboard by setting focus to line edit
   233     // Open virtual keyboard by setting focus to line edit
   225     mLineEdit->setFocus();
   234     mLineEdit->setFocus();
   226     
   235     
   227     OstTraceFunctionExit0( WLANWIZARDPAGEKEYQUERY_SHOWPAGE_EXIT );
   236     OstTraceFunctionExit0(WLANWIZARDPAGEKEYQUERY_SHOWPAGE_EXIT);
   228     return true;
   237     return true;
   229 }
   238 }
   230 
   239 
   231 /*!
   240 /*!
   232    When focus moves into the Key editor and there is visible error text, it
   241    When focus moves into the Key editor and there is visible error text, it
   237    
   246    
   238    @return false. do not eat the event.
   247    @return false. do not eat the event.
   239  */
   248  */
   240 bool WlanWizardPageKeyQuery::eventFilter(QObject *obj, QEvent *event)
   249 bool WlanWizardPageKeyQuery::eventFilter(QObject *obj, QEvent *event)
   241 {
   250 {
   242     OstTraceFunctionEntry0( WLANWIZARDPAGEKEYQUERY_EVENTFILTER_ENTRY );
   251     OstTraceFunctionEntry0(WLANWIZARDPAGEKEYQUERY_EVENTFILTER_ENTRY);
       
   252     
   243     if (obj == mLineEdit && event->type() == QEvent::FocusIn) {
   253     if (obj == mLineEdit && event->type() == QEvent::FocusIn) {
   244         mLabelError->setPlainText("");
   254         mLabelError->setPlainText("");
   245     }
   255     }
   246     OstTraceFunctionExit0( WLANWIZARDPAGEKEYQUERY_EVENTFILTER_EXIT );
   256     
       
   257     OstTraceFunctionExit0(WLANWIZARDPAGEKEYQUERY_EVENTFILTER_EXIT);
   247     return false;
   258     return false;
   248 }
   259 }
   249 
   260 
   250 /*!
   261 /*!
   251    Maps provided error code to error text.
   262    Maps provided error code to error text.
   256    successful case.
   267    successful case.
   257  */
   268  */
   258 QString WlanWizardPageKeyQuery::keyStatusToErrorString(
   269 QString WlanWizardPageKeyQuery::keyStatusToErrorString(
   259     WlanWizardUtils::KeyStatus status) const
   270     WlanWizardUtils::KeyStatus status) const
   260 {
   271 {
   261     OstTraceFunctionEntry0( WLANWIZARDPAGEKEYQUERY_KEYSTATUSTOERRORSTRING_ENTRY );
   272     OstTraceFunctionEntry0(WLANWIZARDPAGEKEYQUERY_KEYSTATUSTOERRORSTRING_ENTRY);
       
   273     
   262     QString errorString;
   274     QString errorString;
   263     switch (status) {
   275     switch (status) {
   264     case WlanWizardUtils::KeyStatusIllegalCharacters:
   276     case WlanWizardUtils::KeyStatusIllegalCharacters:
   265         errorString = hbTrId("txt_occ_dialog_illegal_characters_in_key_please_c");
   277         errorString = hbTrId("txt_occ_dialog_illegal_characters_in_key_please_c");
   266         break;
   278         break;
   276     default:
   288     default:
   277         Q_ASSERT(WlanWizardUtils::KeyStatusOk == status);
   289         Q_ASSERT(WlanWizardUtils::KeyStatusOk == status);
   278         // nothing to do here.
   290         // nothing to do here.
   279         break;
   291         break;
   280     }
   292     }
   281     OstTraceFunctionExit0( WLANWIZARDPAGEKEYQUERY_KEYSTATUSTOERRORSTRING_EXIT );
   293     
       
   294     OstTraceFunctionExit0(WLANWIZARDPAGEKEYQUERY_KEYSTATUSTOERRORSTRING_EXIT);
   282     return errorString;
   295     return errorString;
   283 }
   296 }