--- a/wlanutilities/wpswizard/src/wpswizardstepfour.cpp Thu Jun 10 15:44:54 2010 +0300
+++ b/wlanutilities/wpswizard/src/wpswizardstepfour.cpp Thu Jun 24 10:49:51 2010 +0300
@@ -2,7 +2,7 @@
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
- * under the terms of the License "Eclipse Public License v1.0"
+ * under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
@@ -16,229 +16,315 @@
*
*/
-/*
- * %version: 1 %
- */
-
// System includes
-#include <hbdocumentloader.h>
-#include <hbwidget.h>
-#include <hbradiobuttonlist.h>
-#include <hblineedit.h>
-#include <hblabel.h>
-#include <hbprogressbar.h>
-#include <hbmessagebox.h>
+#include <HbDocumentLoader>
+#include <HbWidget>
+#include <HbRadioButtonList>
+#include <HbLineEdit>
+#include <HbLabel>
+#include <HbProgressBar>
+#include <HbMessageBox>
+#include <HbMainWindow>
+#include <platform\wlanerrorcodes.h>
// User includes
#include "wpswizardstepfour.h"
+#include "wpswizardstepfour_p.h"
#include "wpswizard_p.h"
// Trace includes
+
+
#include "OstTraceDefinitions.h"
#ifdef OST_TRACE_COMPILER_IN_USE
-#include "wpspagestepfourTraces.h"
+#include "wpswizardstepfourTraces.h"
#endif
+// External function prototypes
+
+// Local constants
+
+
/*!
- * Constructor for WPS page four
- *
- * \param WpsWizardPrivate* Pointer to the WPS wizard private implementation
+ \class WpsPageStepFour
+ \brief Implementation of wps wizard page for step four.
+ */
+
+// ======== LOCAL FUNCTIONS ========
+
+// ======== MEMBER FUNCTIONS ========
+
+
+/*!
+ Constructor for WPS page four
+
+ @param [in] parent Pointer to the WPS wizard private implementation
*/
WpsPageStepFour::WpsPageStepFour(WpsWizardPrivate* parent) :
- WpsWizardPage(parent), mWidget(NULL), mRadio(NULL), mValid(false)
+ WpsWizardPage(parent),
+ mWidget(NULL),
+ mWpsErrorCode(0),
+ mCountCredentials(0),
+ mLoader(NULL),
+ d_ptr(NULL)
{
-OstTraceFunctionEntry1(WPSPAGESTEPFOUR_WPSPAGESTEPFOUR_ENTRY, this)
-OstTraceFunctionExit1(WPSPAGESTEPFOUR_WPSPAGESTEPFOUR_EXIT, this)
-
+ OstTraceFunctionEntry1(WPSPAGESTEPFOUR_WPSPAGESTEPFOUR_ENTRY, this);
+ d_ptr.reset(new WpsPageStepFourPrivate(this));
+ OstTraceFunctionExit1(WPSPAGESTEPFOUR_WPSPAGESTEPFOUR_EXIT, this);
}
/*!
- * Destructor
+ Destructor
*/
WpsPageStepFour::~WpsPageStepFour()
{
- OstTraceFunctionEntry1(WPSPAGESTEPFOUR_WPSPAGESTEPFOUR_ENTRY, this)
-
- delete mWidget;
- delete mWpsActiveRunner;
-
-OstTraceFunctionExit1(WPSPAGESTEPFOUR_WPSPAGESTEPFOUR_EXIT, this)
+ OstTraceFunctionEntry1(WPSPAGESTEPFOUR_WPSPAGESTEPFOUR_DESTRUCTOR_ENTRY, this);
+ delete mLoader;
+ OstTraceFunctionExit1(WPSPAGESTEPFOUR_WPSPAGESTEPFOUR_DESTRUCTOR_EXIT, this);
}
/*!
- * Loads the page with all the widgets
- *
- * \return HbWidget* Returns the view widget
+ Loads the page with all the widgets
+
+ @return HbWidget* Returns the view widget
*/
HbWidget* WpsPageStepFour::initializePage()
{
- OstTraceFunctionEntry1(WPSPAGESTEPFOUR_INITIALIZEPAGE_ENTRY, this)
+ OstTraceFunctionEntry1(WPSPAGESTEPFOUR_INITIALIZEPAGE_ENTRY, this);
- if (!mWidget) {
+ if (!mWidget) {
bool ok;
- HbDocumentLoader loader;
- loader.load(":/docml/occ_wps_P4.docml", &ok);
- Q_ASSERT_X(ok, "WPS Wizard", "Invalid docml file");
-
- mWidget = qobject_cast<HbWidget*> (loader.findWidget("occ_wps_P4"));
- Q_ASSERT_X(mWidget != 0, "WPS Wizard", "View not found");
- //mTitle = qobject_cast<HbLabel*> (loader.findWidget("label_title"));
- //Q_ASSERT_X(mTitle != 0, "WPS wizard", "title not found");
-
- mHeading = qobject_cast<HbLabel*> (loader.findWidget("label_heading"));
- Q_ASSERT_X(mTitle != 0, "WPS wizard", "Header not found");
+ mLoader = new HbDocumentLoader(mWizard->mainWindow());
+
+ mLoader->load(":/docml/occ_wps_P4.docml", &ok);
+ Q_ASSERT(ok);
+
+ // Initialize orientation
+ loadDocmlSection(mWizard->mainWindow()->orientation());
- mProgressBar = qobject_cast<HbProgressBar*> (loader.findWidget("horizontalProgressBar"));
- Q_ASSERT_X(mRadio != 0, "WPS Wizard", "List not found");
+ mWidget = qobject_cast<HbWidget*> (mLoader->findWidget("occ_wps_P4"));
+ Q_ASSERT(mWidget);
- // start the framework.
- mWpsActiveRunner = CWpsActiveRunner::NewL(*this);
- Q_ASSERT(error == NULL);
+ bool connectOk = connect(
+ mWizard->mainWindow(),
+ SIGNAL(orientationChanged(Qt::Orientation)),
+ this,
+ SLOT(loadDocmlSection(Qt::Orientation)));
+ Q_ASSERT(connectOk);
}
- mProgressBar->setRange(0, 0);
-
- StartWpsRunner();
- OstTraceFunctionExit1(WPSPAGESTEPFOUR_INITIALIZEPAGE_EXIT, this)
+ OstTraceFunctionExit1(WPSPAGESTEPFOUR_INITIALIZEPAGE_EXIT, this);
return mWidget;
}
/*!
- * Funtion to determine the next page to be displayed in the wizard process
- *
- * \param bool& RemoveFromStack indicating whether the current page should be
- * removed from the stack
- *
- * \return int Page Id of the next page to be displayed.
+ In case the wizard page needs timer protection to the page use this
+ method to start control operation of the page. This method will be called
+ after requiresStartOperation() if true is returned with different call
+ stack.
+
+ See requiresStartOperation(), WlanWizardHelper::nextPage().
+ */
+
+void WpsPageStepFour::startOperation()
+{
+ startWpsRunner();
+}
+
+/*!
+ Funtion to determine the next page to be displayed in the wizard process
+
+ @param [out] removeFromStack bool variable indicating whether the current
+ page should be removed from the stack
+
+ @return int Page Id of the next page to be displayed.
*/
int WpsPageStepFour::nextId(bool &removeFromStack) const
{
- OstTraceFunctionEntry1(WPSPAGESTEPFOUR_NEXTID_ENTRY, this)
+ OstTraceFunctionEntry1(WPSPAGESTEPFOUR_NEXTID_ENTRY, this);
int id = WpsWizardPage::PageNone;
removeFromStack = false;
- if (countCredentials >= 2) {
+
+ // Error has occured go to error page
+ if(mWpsErrorCode != 0) {
+ return WlanWizardPage::PageGenericError;
+ }
+
+ if(mCountCredentials == 0) {
+ id = WlanWizardPage::PageProcessSettings;
+ } else if (mCountCredentials >= 2) {
id = WpsWizardPage::PageWpsWizardStep5;
- }
- else {
+ } else {
// only one response received. So go to the summary page
mWizard->storeSettings(0);
id = WlanWizardPage::PageProcessSettings;
- }
- OstTraceFunctionExit1(WPSPAGESTEPFOUR_NEXTID_EXIT, this)
-
+ }
+
+ OstTraceFunctionExit1(WPSPAGESTEPFOUR_NEXTID_EXIT, this);
return id;
}
+/*!
+ If the wizard page requires timer protection and asyncronous time
+ lasting operation, protect parameters should return true. This is used
+ in pages e.g. where progressbar is shown. The whole point is to
+ initialize the UI before starting the operation, so that the progress bar
+ is painted before the operation takes place.
+
+ In practise this means that if true is returned in protect.
+ - WlanWizardPage::startOperation() is called to start the page operation.
+ - 1.5sec timer is used to protect the page
+ - wizardPage MUST call WlanWizardHelper::nextPage() to trigger entry to
+ next wizard page.
+
+ @return true if protection is need. see description of the method.
+ */
+
+bool WpsPageStepFour::requiresStartOperation()
+{
+ return true;
+}
/*!
- * Determines the Number of steps to move backwards when 'Prev' Button
- * is clicked
- *
- * \return int Number of pages to move backwards
+ Determines the Number of steps to move backwards when 'Prev' Button
+ is clicked
+
+ @return int Number of pages to move backwards
*/
-int WpsPageStepFour::stepsBackwards()
+int WpsPageStepFour::previousTriggered()
{
- OstTraceFunctionEntry1(WPSPAGESTEPFOUR_STEPSBACKWARDS_ENTRY, this)
- OstTraceFunctionExit1(WPSPAGESTEPFOUR_STEPBACKWARDS_EXIT, this)
-
+ OstTraceFunctionEntry1(WPSPAGESTEPFOUR_PREVIOUSTRIGGERED_ENTRY, this);
+ d_ptr->Cancel();
+ OstTraceFunctionExit1(WPSPAGESTEPFOUR_PREVIOUSTRIGGERED_EXIT, this);
return (PageWpsWizardStep4 - PageWpsWizardStep2) - 1;
}
/*!
- * Callback when the previous button is clicked
+ Determines whether the Next action button should be enabled or not
+
+ @return bool Indicating whether next button is enabled or not.
*/
-void WpsPageStepFour::previousTriggered()
+bool WpsPageStepFour::showPage()
{
- OstTraceFunctionEntry1(WPSPAGESTEPFOUR_PREVIOUSTRIGGERED_ENTRY, this)
-
- mWpsActiveRunner->DoCancel();
-OstTraceFunctionExit1(WPSPAGESTEPFOUR_PREVIOUSTRIGGERED_EXIT, this)
-
+ mWpsErrorCode = 0;
+
+ return false;
}
/*!
- * CallBack when the cancel button is clicked
-*/
-void WpsPageStepFour::cancelTriggered()
+ Handles the error case. Based on the error code decides
+ whether to retry or stop the wizard
+
+ @param [in] aErrorCode integer variable indicating the error codes
+ */
+void WpsPageStepFour::handleError(int aErrorCode)
{
- OstTraceFunctionEntry1(WPSPAGESTEPFOUR_CANCELTRIGGERED_ENTRY, this)
+ OstTraceFunctionEntry1(WPSPAGESTEPFOUR_HANDLEERROR_ENTRY, this);
+ QString str;
+ OstTrace1( TRACE_ERROR, WPSPAGESTEPFOUR_HANDLEERROR, "WpsPageStepFour::handleError;aErrorCode=%d", aErrorCode );
+ mWpsErrorCode = aErrorCode;
+ switch (aErrorCode) {
+ case KErrWlanProtectedSetupOOBInterfaceReadError:
+ case KErrWlanProtectedSetupDecryptionCRCFailure:
+ case KErrWlanProtectedSetup2_4ChannelNotSupported:
+ case KErrWlanProtectedSetup5_0ChannelNotSupported:
+ case KErrWlanProtectedSetupNetworkAuthFailure:
+ case KErrWlanProtectedSetupNoDHCPResponse:
+ case KErrWlanProtectedSetupFailedDHCPConfig:
+ case KErrWlanProtectedSetupIPAddressConflict:
+ case KErrWlanProtectedSetupCouldNotConnectToRegistrar:
+ case KErrWlanProtectedSetupMultiplePBCSessionsDetected:
+ case KErrWlanProtectedSetupRogueActivitySuspected:
+ case KErrWlanProtectedSetupDeviceBusy:
+ case KErrWlanProtectedSetupSetupLocked:
+ case KErrWlanProtectedSetupMessageTimeout:
+ case KErrWlanProtectedSetupRegistrationSessionTimeout:
+ str = QString(hbTrId("txt_occ_dialog_configuration_failed_please_try_ag"));
+ break;
- mWpsActiveRunner->DoCancel();
-OstTraceFunctionExit1(WPSPAGESTEPFOUR_CANCELTRIGGERED_EXIT, this)
+ case KErrWlanProtectedSetupDevicePasswordAuthFailure:
+ case KErrWlanProtectedSetupPINMethodNotSupported:
+ case KErrWlanProtectedSetupPBMethodNotSupported:
+ default:
+ str = QString(hbTrId("txt_occ_dialog_configuration_failed_authenticatio"));
+ break;
+ }
+
+ mValid = false;
+ mWizard->setConfiguration(WlanWizardHelper::ConfGenericErrorString, str);
+ mWizard->setConfiguration(
+ WlanWizardHelper::ConfGenericErrorPageStepsBackwards,
+ (PageWpsWizardStep4 - PageWpsWizardStep2));
+ mWizard->nextPage();
+
+ OstTraceFunctionExit1(WPSPAGESTEPFOUR_HANDLEERROR_EXIT, this) ;
}
/*!
- * Validates the content of the pages
- *
- * \return bool Indicating the result of the operation
+ Provides the functionality to initiate the WPS functionality
*/
-bool WpsPageStepFour::validate() const
+void WpsPageStepFour::startWpsRunner()
{
- OstTraceFunctionEntry1(WPSPAGESTEPFOUR_VALIDATE_ENTRY, this)
- OstTraceFunctionExit1(WPSPAGESTEPFOUR_VALIDATE_EXIT, this)
-
- return mValid;
+ OstTraceFunctionEntry1(WPSPAGESTEPFOUR_STARTWPSRUNNER_ENTRY, this);
+ mValid = false;
+ d_ptr->StartSetup(mWizard->getSsid(), mWizard->getPin());
+ OstTraceFunctionExit1(WPSPAGESTEPFOUR_STARTWPSRUNNER_EXIT, this);
}
+/*!
+ Stores the credentials set by the user, through the WPs Wizard
+
+ @param [in] credentials List of Credentials entered by user.
+
+ @param credentialscount Number Of Credentials in the list
+ */
+void WpsPageStepFour::setCredentials(
+ QList<TWlanProtectedSetupCredentialAttribute>& credentials,
+ int credentialscount)
+{
+ OstTraceFunctionEntry1( WPSPAGESTEPFOUR_SETCREDENTIALS_ENTRY, this );
+
+ mCountCredentials = credentialscount;
+ mWizard->storeSettingsArray(credentials);
+ mWizard->nextPage();
+ // enable the next button
+
+ OstTraceFunctionExit1( WPSPAGESTEPFOUR_SETCREDENTIALS_EXIT, this );
+}
/*!
- * CallBack function when the middleware WPS call returns back
- *
- * \param QList An array of received settngs
- * \param int Error indicating the result of the operation
- *
+ CallBack when the cancel button is clicked
*/
-void WpsPageStepFour::WpsActiveRunnerStopped(
- QList<TWlanProtectedSetupCredentialAttribute>& aCredentials, TInt aError)
+void WpsPageStepFour::cancelTriggered()
{
- OstTraceFunctionEntry1(WPSPAGESTEPFOUR_WPSACTIVERUNNERSTOPPED_ENTRY, this)
-
- mWpsErrorCode = aError;
- if (aError == KErrNone) {
- countCredentials = aCredentials.count();
- mWizard->storeSettingsArray(aCredentials);
- mWizard->nextPage();
- }
- else if (aError == KErrCancel) {
- // operation was cancelled
-
- }
- else {
- QString str;
- str = QString("Error: %1").arg(aError);
- mProgressBar->setVisible(false);
- //mHeading->setPlainText("General Error");
- mHeading->setPlainText(str);
- mWizard->enableNextButton(false);
-
- }
-OstTraceFunctionExit1(WPSPAGESTEPFOUR_WPSACTIVERUNNERSTOPPED_EXIT, this)
+ OstTraceFunctionEntry1( WPSPAGESTEPFOUR_CANCELTRIGGERED_ENTRY, this );
+ d_ptr->Cancel();
+ OstTraceFunctionExit1( WPSPAGESTEPFOUR_CANCELTRIGGERED_EXIT, this );
}
-
/*!
- * Provides the functionality to initiate the WPS functionality
+ Loads docml at initialization phase and when HbMainWindow sends
+ orientation() signal.
+
+ @param orientation[in] orientation to be loaded.
*/
-void WpsPageStepFour::StartWpsRunner()
+void WpsPageStepFour::loadDocmlSection(Qt::Orientation orientation)
{
-
- OstTraceFunctionEntry1(WPSPAGESTEPFOUR_STARTWPSRUNNER_ENTRY, this)
-
- // convert QString to symbian RBuf8
+ bool ok = false;
+
+ // Load the orientation specific section
+ if (orientation == Qt::Horizontal) {
+ mLoader->load(":/docml/occ_wps_P4.docml", "landscape", &ok);
+ Q_ASSERT(ok);
+ }
+ else {
+ Q_ASSERT(orientation == Qt::Vertical);
+ mLoader->load(":/docml/occ_wps_P4.docml", "portrait", &ok);
+ Q_ASSERT(ok);
+ }
+}
- QString ssid = mWizard->getSsid();
-
- TPtrC ptrName(reinterpret_cast<const TText*> (ssid.constData()));
-
- RBuf8 ssidName;
- ssidName.Create(ptrName.Length());
- ssidName.Copy(ptrName);
-
- mWpsActiveRunner->StartSetup(ssidName, mWizard->getPin());
- ssidName.Close();
-OstTraceFunctionExit1(WPSPAGESTEPFOUR_STARTWPSRUNNER_EXIT, this)
-}