wlanutilities/wpswizard/src/wpswizardstepfive.cpp
changeset 19 10810c91db26
child 39 7b3e49e4608a
child 47 b3d8f88532b7
equal deleted inserted replaced
3:ff3b37722600 19:10810c91db26
       
     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 the License "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.h>
       
    21 #include <hbwidget.h>
       
    22 #include <hbradiobuttonlist.h>
       
    23 #include <hblineedit.h>
       
    24 #include <hblabel.h>
       
    25 
       
    26 // User includes
       
    27 #include "wpswizardstepfive.h"
       
    28 #include "wpswizard_p.h"
       
    29 
       
    30 // Trace Includes
       
    31 #include "OstTraceDefinitions.h"
       
    32 #ifdef OST_TRACE_COMPILER_IN_USE
       
    33 #include "wpspagestepfiveTraces.h"
       
    34 #endif
       
    35 
       
    36 /*!
       
    37  * Constructor for WPS page five
       
    38  * 
       
    39  * \param WpsWizardPrivate* Pointer to the WPS wizard private implementation 
       
    40  */
       
    41 WpsPageStepFive::WpsPageStepFive(WpsWizardPrivate* parent) :
       
    42     WpsWizardPage(parent), mWidget(NULL), mRadio(NULL), mValid(false)
       
    43 {
       
    44 OstTraceFunctionEntry1(WPSPAGESTEPFIVE_WPSPAGESTEPFIVE_ENTRY, this)
       
    45 OstTraceFunctionExit1(WPSPAGESTEPFIVE_WPSPAGESTEPFIVE_EXIT, this)
       
    46 
       
    47 }
       
    48 
       
    49 /*!
       
    50  * Destructor
       
    51  */
       
    52 WpsPageStepFive::~WpsPageStepFive()
       
    53 {
       
    54     OstTraceFunctionEntry1(WPSPAGESTEPFIVE_WPSPAGESTEPFIVE_ENTRY, this)
       
    55     OstTraceFunctionExit1(WPSPAGESTEPFIVE_WPSPAGESTEPFIVE_EXIT, this)
       
    56 
       
    57     delete mWidget;
       
    58 }
       
    59 
       
    60 /*!
       
    61  * Loads the page with all the widgets
       
    62  * 
       
    63  * \return HbWidget* Returns the view widget
       
    64  */
       
    65 HbWidget* WpsPageStepFive::initializePage()
       
    66 {
       
    67     OstTraceFunctionEntry1(WPSPAGESTEPFIVE_INITIALIZEPAGE_ENTRY, this)
       
    68 
       
    69     if (!mWidget) {
       
    70         bool ok;
       
    71         HbDocumentLoader loader;
       
    72         loader.load(":/docml/occ_wps_P5.docml", &ok);
       
    73         Q_ASSERT_X(ok, "WPS Wizard", "Invalid docml file");
       
    74 
       
    75         mWidget = qobject_cast<HbWidget*> (loader.findWidget("occ_wps_P5"));
       
    76         Q_ASSERT_X(mWidget != 0, "WPS Wizard", "View not found");
       
    77 
       
    78         //mTitle = qobject_cast<HbLabel*> (loader.findWidget("label_title"));
       
    79         //Q_ASSERT_X(mTitle != 0, "WPS wizard", "title not found");
       
    80 
       
    81         mHeading = qobject_cast<HbLabel*> (loader.findWidget("label_heading"));
       
    82         Q_ASSERT_X(mTitle != 0, "WPS wizard", "Header not found");
       
    83 
       
    84         mRadio = qobject_cast<HbRadioButtonList*> (loader.findWidget("radioButtonList"));
       
    85         Q_ASSERT_X(mRadio != 0, "WPS Wizard", "List not found");
       
    86 
       
    87         QList<TWlanProtectedSetupCredentialAttribute> arr = mWizard->getSettingsArray();
       
    88 
       
    89         QStringList ssidList;
       
    90         for (int count = 0; count < arr.count(); count++) {
       
    91             TWlanProtectedSetupCredentialAttribute attr = arr[count];
       
    92             //file.Write(attr.iSsid);
       
    93             //Append (attr.iSsid) to a list and send to UI Engine.
       
    94             QString ssid = QString::fromUtf8((const char*) attr.iSsid.Ptr(), attr.iSsid.Length());
       
    95             ssidList.append(ssid);
       
    96         }
       
    97 
       
    98         mRadio->setItems(ssidList);
       
    99 
       
   100         connect(mRadio, SIGNAL(itemSelected(int)), this, SLOT(itemSelected(int)));
       
   101     }
       
   102     OstTraceFunctionExit1(WPSPAGESTEPFIVE_INITIALIZEPAGE_EXIT, this)
       
   103     return mWidget;
       
   104 }
       
   105 
       
   106 /*!
       
   107  * Callback when the previous button is clicked
       
   108  */
       
   109 void WpsPageStepFive::previousTriggered()
       
   110 {
       
   111 OstTraceFunctionEntry1(WPSPAGESTEPFIVE_PREVIOUSTRIGGERED_ENTRY, this)
       
   112 OstTraceFunctionExit1(WPSPAGESTEPFIVE_PREVIOUSTRIGGERED_EXIT, this)
       
   113 
       
   114 }
       
   115 /*!
       
   116  * CallBack when the cancel button is clicked
       
   117  */
       
   118 void WpsPageStepFive::cancelTriggered()
       
   119 {
       
   120 OstTraceFunctionEntry1(WPSPAGESTEPFIVE_CANCELTRIGGERED_ENTRY, this)
       
   121 OstTraceFunctionExit1(WPSPAGESTEPFIVE_CANCELTRIGGERED_EXIT, this)
       
   122 
       
   123 }
       
   124 /*!
       
   125  * Funtion to determine the next page to be displayed in the wizard process
       
   126  * 
       
   127  * \param bool& RemoveFromStack indicating whether the current page should be 
       
   128  * removed from the stack
       
   129  * 
       
   130  * \return int Page Id of the next page to be displayed.
       
   131  */
       
   132 int WpsPageStepFive::nextId(bool &removeFromStack) const
       
   133 {
       
   134     OstTraceFunctionEntry1(WPSPAGESTEPFIVE_NEXTID_ENTRY, this)
       
   135 
       
   136     int id = WlanWizardPage::PageProcessSettings;
       
   137     removeFromStack = false;
       
   138     OstTraceFunctionExit1(WPSPAGESTEPFIVE_NEXTID_EXIT, this)
       
   139     return id;
       
   140 }
       
   141 
       
   142 /*!
       
   143  * Determines the Number of steps to move backwards when 'Prev' Button
       
   144  * is clicked
       
   145  * 
       
   146  * \return int Number of pages to move backwards
       
   147  */
       
   148 int WpsPageStepFive::stepsBackwards()
       
   149 {
       
   150     OstTraceFunctionEntry1(WPSPAGESTEPFIVE_STEPSBACKWARDS_ENTRY, this)
       
   151     OstTraceFunctionExit1(WPSPAGESTEPFIVE_STEPBACKWARDS_EXIT, this)
       
   152 
       
   153     return (PageWpsWizardStep5 - PageWpsWizardStep2) - 1;
       
   154 }
       
   155 
       
   156 /*!
       
   157  * Validates the content of the pages
       
   158  * 
       
   159  * \return bool Indicating the result of the operation
       
   160  */
       
   161 bool WpsPageStepFive::validate() const
       
   162 {
       
   163     OstTraceFunctionEntry1(WPSPAGESTEPFIVE_VALIDATE_ENTRY, this)
       
   164     OstTraceFunctionExit1(WPSPAGESTEPFIVE_VALIDATE_EXIT, this)
       
   165 
       
   166     return mValid;
       
   167 }
       
   168 
       
   169 /*!
       
   170  * Call back when an item is selected from the list on the UI
       
   171  * 
       
   172  * \param int index Indcating the relative position in the list
       
   173  */
       
   174 void WpsPageStepFive::itemSelected(int index)
       
   175 {
       
   176     OstTraceFunctionEntry1(WPSPAGESTEPFIVE_ITEMSELECTED_ENTRY, this)
       
   177 
       
   178     mValid = true;
       
   179     mWizard->storeSettings(index);
       
   180     mWizard->enableNextButton(mValid);
       
   181 
       
   182     OstTraceFunctionExit1(WPSPAGESTEPFIVE_ITEMSELECTED_EXIT, this)
       
   183 }
       
   184