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