wlanutilities/wpswizard/src/wpswizardstepfive.cpp
branchRCL_3
changeset 25 f28ada11abbf
parent 24 63be7eb3fc78
equal deleted inserted replaced
24:63be7eb3fc78 25:f28ada11abbf
     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  *   WPS Wizard Page: Step 5
       
    16  *
       
    17  */
       
    18 
       
    19 // System includes
       
    20 #include <HbDocumentLoader>
       
    21 #include <HbWidget>
       
    22 #include <HbRadioButtonList>
       
    23 #include <HbLineEdit>
       
    24 #include <HbLabel>
       
    25 #include <HbMainWindow>
       
    26 
       
    27 // User includes
       
    28 #include "wpswizardstepfive.h"
       
    29 #include "wpswizard_p.h"
       
    30 
       
    31 // Trace Includes
       
    32 #include "OstTraceDefinitions.h"
       
    33 #ifdef OST_TRACE_COMPILER_IN_USE
       
    34 #include "wpswizardstepfiveTraces.h"
       
    35 #endif
       
    36 
       
    37 // External function prototypes
       
    38 
       
    39 // Local constants
       
    40 
       
    41 
       
    42 /*!
       
    43    \class WpsPageStepFive
       
    44    \brief Implementation of wps wizard page for step five. 
       
    45  */
       
    46 
       
    47 // ======== LOCAL FUNCTIONS ========
       
    48 
       
    49 // ======== MEMBER FUNCTIONS ========
       
    50 
       
    51 
       
    52 /*!
       
    53    Constructor for WPS page five
       
    54    
       
    55    @param [in] parent WpsWizardPrivate* Pointer to the WPS wizard private 
       
    56           implementation 
       
    57  */
       
    58 WpsPageStepFive::WpsPageStepFive(WpsWizardPrivate* parent) :
       
    59     WpsWizardPage(parent), 
       
    60     mWidget(NULL), 
       
    61     mRadio(NULL), 
       
    62     mHeading(NULL),
       
    63     mValid(false),
       
    64     mLoader(NULL)
       
    65 {
       
    66     OstTraceFunctionEntry1(WPSPAGESTEPFIVE_WPSPAGESTEPFIVE_ENTRY, this);
       
    67     OstTraceFunctionExit1(WPSPAGESTEPFIVE_WPSPAGESTEPFIVE_EXIT, this);
       
    68 }
       
    69 
       
    70 /*!
       
    71    Destructor
       
    72  */
       
    73 WpsPageStepFive::~WpsPageStepFive()
       
    74 {
       
    75     OstTraceFunctionEntry1(WPSPAGESTEPFIVE_WPSPAGESTEPFIVE_DESTRUCTOR_ENTRY, this); 
       
    76     delete mLoader;
       
    77     OstTraceFunctionExit1(WPSPAGESTEPFIVE_WPSPAGESTEPFIVE_DESTRUCTOR_EXIT, this);
       
    78 }
       
    79 
       
    80 /*!
       
    81    Loads the page with all the widgets
       
    82    
       
    83    @return HbWidget* Returns the view widget
       
    84  */
       
    85 HbWidget* WpsPageStepFive::initializePage()
       
    86 {
       
    87     OstTraceFunctionEntry1(WPSPAGESTEPFIVE_INITIALIZEPAGE_ENTRY, this);
       
    88 
       
    89     if (!mWidget) {
       
    90         bool ok;
       
    91         
       
    92         mLoader = new HbDocumentLoader(mWizard->mainWindow());
       
    93         
       
    94         mLoader->load(":/docml/occ_wps_01_05.docml", &ok);
       
    95         Q_ASSERT(ok);
       
    96         
       
    97         // Initialize orientation
       
    98         loadDocmlSection(mWizard->mainWindow()->orientation());
       
    99 
       
   100         mWidget = qobject_cast<HbWidget*> (mLoader->findWidget("occ_wps_P1"));
       
   101         Q_ASSERT(mWidget);
       
   102 
       
   103         mHeading = qobject_cast<HbLabel*> (mLoader->findWidget("label"));
       
   104         Q_ASSERT(mHeading);
       
   105         
       
   106         mHeading->setPlainText(hbTrId("txt_occ_dialog_settings_received_for_multiple_wlan"));
       
   107 
       
   108         mRadio = qobject_cast<HbRadioButtonList*> (mLoader->findWidget(
       
   109                 "radioButtonList"));
       
   110         Q_ASSERT(mRadio);
       
   111 
       
   112         QList<TWlanProtectedSetupCredentialAttribute> arr = mWizard->getSettingsArray();
       
   113 
       
   114         QStringList ssidList;
       
   115         for (int count = 0; count < arr.count(); count++)
       
   116             {
       
   117             TWlanProtectedSetupCredentialAttribute attr = arr[count];
       
   118             QString ssid = QString::fromUtf8((const char*) attr.iSsid.Ptr(),
       
   119                     attr.iSsid.Length());
       
   120             ssidList.append(ssid);
       
   121             }
       
   122         mRadio->setItems(ssidList);
       
   123 
       
   124         bool connectOk = connect(
       
   125             mRadio, 
       
   126             SIGNAL(itemSelected(int)), 
       
   127             this,
       
   128             SLOT(itemSelected(int)));
       
   129         Q_ASSERT(connectOk);
       
   130         
       
   131         connectOk = connect(
       
   132             mWizard->mainWindow(), 
       
   133             SIGNAL(orientationChanged(Qt::Orientation)),
       
   134             this, 
       
   135             SLOT(loadDocmlSection(Qt::Orientation)));
       
   136                    
       
   137         Q_ASSERT(connectOk);
       
   138     }
       
   139     
       
   140     OstTraceFunctionExit1(WPSPAGESTEPFIVE_INITIALIZEPAGE_EXIT, this);
       
   141     return mWidget;
       
   142 }
       
   143 
       
   144 /*!
       
   145    Determines the Number of steps to move backwards when 'Prev' Button
       
   146    is clicked
       
   147    
       
   148    @return int Number of pages to move backwards
       
   149  */
       
   150 int WpsPageStepFive::previousTriggered()
       
   151 {
       
   152     OstTraceFunctionEntry1(WPSPAGESTEPFIVE_PREVIOUSTRIGGERED_ENTRY, this); 
       
   153     OstTraceFunctionExit1(WPSPAGESTEPFIVE_PREVIOUSTRIGGERED_EXIT, this);
       
   154     
       
   155     return (PageWpsWizardStep5 - PageWpsWizardStep2) - 1;
       
   156 }
       
   157 /*!
       
   158    CallBack when the cancel button is clicked
       
   159  */
       
   160 void WpsPageStepFive::cancelTriggered()
       
   161 {
       
   162     OstTraceFunctionEntry1(WPSPAGESTEPFIVE_CANCELTRIGGERED_ENTRY, this); 
       
   163     OstTraceFunctionExit1(WPSPAGESTEPFIVE_CANCELTRIGGERED_EXIT, this);
       
   164 }
       
   165 
       
   166 /*!
       
   167    Funtion to determine the next page to be displayed in the wizard process
       
   168    
       
   169    @param [out] removeFromStack bool RemoveFromStack indicating whether the current 
       
   170           page should be removed from the stack
       
   171    
       
   172    @return int Page Id of the next page to be displayed.
       
   173  */
       
   174 int WpsPageStepFive::nextId(bool &removeFromStack) const
       
   175 {
       
   176     OstTraceFunctionEntry1(WPSPAGESTEPFIVE_NEXTID_ENTRY, this);
       
   177     removeFromStack = false;
       
   178     OstTraceFunctionExit1(WPSPAGESTEPFIVE_NEXTID_EXIT, this);
       
   179     return WlanWizardPage::PageProcessSettings;
       
   180 }
       
   181 
       
   182 /*!
       
   183    Determines whether the Next action button should be enabled or not
       
   184    
       
   185    @return bool Indicating whether next button is enabled or not.
       
   186  */
       
   187 bool WpsPageStepFive::showPage()
       
   188 {
       
   189     return mValid;
       
   190 }
       
   191 
       
   192 
       
   193 /*!
       
   194    Call back when an item is selected from the list on the UI
       
   195    
       
   196    @param [in] index Indicating the relative position in the list
       
   197  */
       
   198 void WpsPageStepFive::itemSelected(int index)
       
   199 {
       
   200     OstTraceFunctionEntry1(WPSPAGESTEPFIVE_ITEMSELECTED_ENTRY, this);
       
   201     mValid = true;
       
   202     mWizard->storeSettings(index);
       
   203     mWizard->enableNextButton(mValid);
       
   204     OstTraceFunctionExit1(WPSPAGESTEPFIVE_ITEMSELECTED_EXIT, this);
       
   205 }
       
   206 
       
   207 
       
   208 /*!
       
   209    Loads docml at initialization phase and when HbMainWindow sends orientation()
       
   210    signal.
       
   211    
       
   212    @param [in] orientation orientation to be loaded.
       
   213  */
       
   214 void WpsPageStepFive::loadDocmlSection(Qt::Orientation orientation)
       
   215 {
       
   216     bool ok = false;
       
   217     
       
   218     // Load the orientation specific section
       
   219     if (orientation == Qt::Horizontal) {
       
   220     mLoader->load(":/docml/occ_wps_01_05.docml", "landscape", &ok);
       
   221         Q_ASSERT(ok);
       
   222     } 
       
   223     else {
       
   224         Q_ASSERT(orientation == Qt::Vertical);
       
   225         mLoader->load(":/docml/occ_wps_01_05.docml", "portrait", &ok);
       
   226         Q_ASSERT(ok);
       
   227     }
       
   228 }
       
   229