# HG changeset patch # User hgs # Date 1274724699 -10800 # Node ID e8f4211554fbc283bef58baf3f0908684e01ab4f # Parent ab513c8439db6a99e98a9c8d0059d423de2d979e 201021 diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanentryplugin/inc/cpwlanentryitemdata.h --- a/wlanutilities/wlanentryplugin/inc/cpwlanentryitemdata.h Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanentryplugin/inc/cpwlanentryitemdata.h Mon May 24 21:11:39 2010 +0300 @@ -2,7 +2,7 @@ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available -* under the terms of "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". * @@ -11,8 +11,8 @@ * * Contributors: * -* Description: -* +* Description: +* WLAN Entry plugin item data implementation. */ #ifndef CPWLANENTRYITEMDATA_H @@ -66,7 +66,7 @@ private: // data - WlanStatusInfo *mWlanStatusInfo; + WlanStatusInfo *mWlanStatusInfo; //!< WLAN status info handler // Friend classes diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanentryplugin/inc/wlanstatusinfo.h --- a/wlanutilities/wlanentryplugin/inc/wlanstatusinfo.h Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanentryplugin/inc/wlanstatusinfo.h Mon May 24 21:11:39 2010 +0300 @@ -1,19 +1,19 @@ /* - * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * This component and the accompanying materials are made available - * 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". - * - * Initial Contributors: - * Nokia Corporation - initial contribution. - * - * Contributors: - * - * Description: - * - */ +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Status Info wrapper for WLAN entry plugin. +*/ #ifndef WLANSTATUSINFO_H #define WLANSTATUSINFO_H @@ -27,6 +27,7 @@ // Forward declarations class WlanQtUtils; +class XQSettingsManager; // External data types @@ -42,15 +43,15 @@ // Data types - /** + /*! * WLAN Status value. */ enum { - /** WLAN is configured OFF. */ + //! WLAN is configured OFF. WlanStatusOff = 0, - /** No WLAN connections. */ + //! No WLAN connections. WlanStatusIdle, - /** WLAN IAP is connected. */ + //! WLAN IAP is connected. WlanStatusConnected, }; @@ -58,9 +59,9 @@ ~WlanStatusInfo(); - int status(); + int status() const; - QString statusText(); + QString statusText() const; signals: @@ -79,18 +80,27 @@ Q_DISABLE_COPY(WlanStatusInfo) + bool isWlanOn() const; + private slots: void updateStatus(); private: // data - WlanQtUtils *mWlanQtUtils; // WlanQtUtils instance. - QString mStatusText; // WLAN status text. - int mStatus; // WLAN status value WlanStatus*. + //! WlanQtUtils instance. + WlanQtUtils *mWlanQtUtils; + + //! Settings manager for platform settings reading, writing & status changes. + XQSettingsManager *mSettingsManager; + + //! WLAN status text. + QString mStatusText; + + //! WLAN status value WlanStatus*. + int mStatus; // Friend classes - }; #endif // WLANSTATUSINFO_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanentryplugin/rom/wlanentryplugin.iby --- a/wlanutilities/wlanentryplugin/rom/wlanentryplugin.iby Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanentryplugin/rom/wlanentryplugin.iby Mon May 24 21:11:39 2010 +0300 @@ -11,8 +11,8 @@ * * Contributors: * -* Description: -* +* Description: +* WLAN Entry Plugin iby file. */ #ifndef WLANENTRYPLUGIN_IBY diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanentryplugin/rom/wlanentryplugin_resources.iby --- a/wlanutilities/wlanentryplugin/rom/wlanentryplugin_resources.iby Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanentryplugin/rom/wlanentryplugin_resources.iby Mon May 24 21:11:39 2010 +0300 @@ -1,19 +1,19 @@ /* - * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * This component and the accompanying materials are made available - * 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". - * - * Initial Contributors: - * Nokia Corporation - initial contribution. - * - * Contributors: - * - * Description: - * - */ +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Entry Plugin resource iby file. +*/ #ifndef WLANENTRYPLUGIN_RESOURCES_IBY #define WLANENTRYPLUGIN_RESOURCES_IBY diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanentryplugin/src/cpwlanentryitemdata.cpp --- a/wlanutilities/wlanentryplugin/src/cpwlanentryitemdata.cpp Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanentryplugin/src/cpwlanentryitemdata.cpp Mon May 24 21:11:39 2010 +0300 @@ -2,7 +2,7 @@ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available -* under the terms of "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". * @@ -11,34 +11,34 @@ * * Contributors: * -* Description: -* +* Description: +* WLAN Entry plugin item data implementation. */ // System includes +#include +#include +#include + #ifdef WLANENTRYPLUGIN_SERVICETRACES #include #endif -#include - -#include -#include +#include #include #include // User includes +#include "wlanstatusinfo.h" +#include "cpwlanentryitemdata.h" + #include "OstTraceDefinitions.h" #ifdef OST_TRACE_COMPILER_IN_USE #include "cpwlanentryitemdataTraces.h" #endif -#include "wlanstatusinfo.h" - -#include "cpwlanentryitemdata.h" - /*! \class CpWlanEntryItemData \brief Implementation of WLAN Status Plugin entry item data. @@ -55,13 +55,15 @@ /*! Constructor. + + @param[in,out] itemDataHelper Control Panel item data helper object. */ CpWlanEntryItemData::CpWlanEntryItemData(CpItemDataHelper &itemDataHelper) : CpSettingFormEntryItemData(itemDataHelper, hbTrId("txt_occ_dblist_wireless_lan")), mWlanStatusInfo(new WlanStatusInfo(this)) { - OstTraceFunctionEntry1(CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_ENTRY, this); + OstTraceFunctionEntry0(CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_ENTRY); // Listen for WLAN status updates bool connectStatus = connect( @@ -74,7 +76,7 @@ // Update to show initial WLAN status. statusUpdate(); - OstTraceFunctionExit1(CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_EXIT, this); + OstTraceFunctionExit0(CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_EXIT); } /*! @@ -83,8 +85,8 @@ CpWlanEntryItemData::~CpWlanEntryItemData() { - OstTraceFunctionEntry1(DUP1_CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_ENTRY, this); - OstTraceFunctionExit1(DUP1_CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_EXIT, this); + OstTraceFunctionEntry0(DUP1_CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_ENTRY); + OstTraceFunctionExit0(DUP1_CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_EXIT); } /*! @@ -93,7 +95,7 @@ CpBaseSettingView *CpWlanEntryItemData::createSettingView() const { - OstTraceFunctionEntry1(CPWLANENTRYITEMDATA_CREATESETTINGVIEW_ENTRY, this); + OstTraceFunctionEntry0(CPWLANENTRYITEMDATA_CREATESETTINGVIEW_ENTRY); #ifdef WLANENTRYPLUGIN_SERVICETRACES qInstallMsgHandler(XQSERVICEMESSAGEHANDLER); @@ -101,15 +103,34 @@ #endif // Execute synchronous WLAN Sniffer list view - XQServiceRequest* snd = new XQServiceRequest("com.nokia.services.wlansniffer.list","listView()",true); - bool status = snd->send(); + // TODO: Start using defines in xqaiwdeclplat.h when available + XQApplicationManager aiwMgr; + XQAiwRequest *request = aiwMgr.create( + "wlansniffer", + "com.nokia.symbian.IWlanSniffer", + "listView()", + true); + + // The WLAN Sniffer service must always exist + Q_ASSERT(request); + + // The service is synchronous & embedded + request->setSynchronous(true); + + // Window title needs to be set to "Control Panel" + XQRequestInfo reqInfo; + // TODO: Start using the official define when available + reqInfo.setInfo("WindowTitle", hbTrId("txt_cp_title_control_panel")); + request->setInfo(reqInfo); + + bool status = request->send(); #ifdef WLANENTRYPLUGIN_SERVICETRACES XQSERVICE_DEBUG_PRINT("CpWlanEntryItemData::createSettingView listView() service request completed"); #endif Q_ASSERT(status); - delete snd; + delete request; - OstTraceFunctionExit1(CPWLANENTRYITEMDATA_CREATESETTINGVIEW_EXIT, this); + OstTraceFunctionExit0(CPWLANENTRYITEMDATA_CREATESETTINGVIEW_EXIT); return 0; } @@ -119,31 +140,37 @@ */ void CpWlanEntryItemData::statusUpdate() { - OstTraceFunctionEntry1(CPWLANENTRYITEMDATA_STATUSUPDATE_ENTRY, this); + OstTraceFunctionEntry0(CPWLANENTRYITEMDATA_STATUSUPDATE_ENTRY); // Build icon with (possible) badge - HbIcon wlanIcon("qtg_large_wlan"); + HbIcon wlanIcon; switch (mWlanStatusInfo->status()) { + case WlanStatusInfo::WlanStatusIdle: + wlanIcon = HbIcon("qtg_large_wlan"); + break; + case WlanStatusInfo::WlanStatusOff: -#ifdef WLANSTATUSICONBADGING // TODO: Remove flagging when icon badging is supported - wlanIcon.addBadge( - Qt::AlignTop | Qt::AlignRight, - HbIcon("pri_small_super_off")); -#endif + wlanIcon = HbIcon("qtg_large_wlan_off"); break; case WlanStatusInfo::WlanStatusConnected: -#ifdef WLANSTATUSICONBADGING // TODO: Remove flagging when icon badging is supported + wlanIcon = HbIcon("qtg_large_wlan"); wlanIcon.addBadge( - Qt::AlignTop | Qt::AlignRight, - HbIcon("qtg_small_online")); + Qt::AlignBottom | Qt::AlignRight, + HbIcon("qtg_small_connection")); + break; + +#ifndef QT_NO_DEBUG + default: + // Unsupported status type detected + Q_ASSERT(0); + break; #endif - break; } // Set the updated WLAN status this->setEntryItemIcon(wlanIcon); this->setDescription(mWlanStatusInfo->statusText()); - OstTraceFunctionExit1(CPWLANENTRYITEMDATA_STATUSUPDATE_EXIT, this); + OstTraceFunctionExit0(CPWLANENTRYITEMDATA_STATUSUPDATE_EXIT); } diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanentryplugin/src/wlanstatusinfo.cpp --- a/wlanutilities/wlanentryplugin/src/wlanstatusinfo.cpp Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanentryplugin/src/wlanstatusinfo.cpp Mon May 24 21:11:39 2010 +0300 @@ -12,16 +12,18 @@ * Contributors: * * Description: +* WLAN Status Info wrapper for WLAN entry plugin. */ // System includes #include +#include +#include // User includes #include "wlanqtutils.h" -#include "wlanqtutilswlaniap.h" #include "wlanstatusinfo.h" @@ -33,14 +35,25 @@ /*! \class WlanStatusInfo \brief Class for maintaining and updating the WLAN status for the WLAN - Status Control Panel Plugin. - + Status Control Panel Plugin. */ // External function prototypes // Local constants +//! Master WLAN ON/OFF setting key +static const XQSettingsKey masterWlanKey( + XQSettingsKey::TargetCentralRepository, + KCRUidWlanDeviceSettingsRegistryId.iUid, + KWlanOnOff); + +//! WLAN forced OFF setting key +static const XQSettingsKey wlanForceKey( + XQSettingsKey::TargetCentralRepository, + KCRUidWlanDeviceSettingsRegistryId.iUid, + KWlanForceDisable); + // ======== LOCAL FUNCTIONS ======== // ======== MEMBER FUNCTIONS ======== @@ -52,18 +65,21 @@ WlanStatusInfo::WlanStatusInfo(QObject *parent) : QObject(parent), mWlanQtUtils(new WlanQtUtils()), + mSettingsManager(new XQSettingsManager(this)), mStatusText(""), mStatus(WlanStatusOff) { - OstTraceFunctionEntry1(WLANSTATUSINFO_WLANSTATUSINFO_ENTRY, this); + OstTraceFunctionEntry0(WLANSTATUSINFO_WLANSTATUSINFO_ENTRY); // Listen for WLAN ON/OFF switching bool connectStatus = connect( - mWlanQtUtils, - SIGNAL(masterWlanStatus(bool)), - this, + mSettingsManager, + SIGNAL(valueChanged(XQSettingsKey, QVariant)), + this, SLOT(updateStatus())); - Q_ASSERT(connectStatus == true); + Q_ASSERT(connectStatus); + mSettingsManager->startMonitoring(masterWlanKey); + mSettingsManager->startMonitoring(wlanForceKey); // Listen for WLAN connection statuses connectStatus = connect( @@ -74,7 +90,7 @@ Q_ASSERT(connectStatus == true); connectStatus = connect( mWlanQtUtils, - SIGNAL(wlanNetworkClosed(int)), + SIGNAL(wlanNetworkClosed(int, int)), this, SLOT(updateStatus())); Q_ASSERT(connectStatus == true); @@ -82,7 +98,7 @@ // Set initial status updateStatus(); - OstTraceFunctionExit1(WLANSTATUSINFO_WLANSTATUSINFO_EXIT, this); + OstTraceFunctionExit0(WLANSTATUSINFO_WLANSTATUSINFO_EXIT); } /*! @@ -91,21 +107,21 @@ WlanStatusInfo::~WlanStatusInfo() { - OstTraceFunctionEntry1(DUP1_WLANSTATUSINFO_WLANSTATUSINFO_ENTRY, this); + OstTraceFunctionEntry0(DUP1_WLANSTATUSINFO_WLANSTATUSINFO_ENTRY); delete mWlanQtUtils; - OstTraceFunctionExit1(DUP1_WLANSTATUSINFO_WLANSTATUSINFO_EXIT, this); + OstTraceFunctionExit0(DUP1_WLANSTATUSINFO_WLANSTATUSINFO_EXIT); } /*! Function for getting current WLAN status value (WlanStatusInfo::WlanStatus*). */ -int WlanStatusInfo::status() +int WlanStatusInfo::status() const { - OstTraceFunctionEntry1(WLANSTATUSINFO_STATUS_ENTRY, this); - OstTraceFunctionExit1(WLANSTATUSINFO_STATUS_EXIT, this); + OstTraceFunctionEntry0(WLANSTATUSINFO_STATUS_ENTRY); + OstTraceFunctionExit0(WLANSTATUSINFO_STATUS_EXIT); return mStatus; } @@ -113,34 +129,58 @@ Returns the current WLAN status text. */ -QString WlanStatusInfo::statusText() +QString WlanStatusInfo::statusText() const { - OstTraceFunctionEntry1(WLANSTATUSINFO_STATUSTEXT_ENTRY, this); - OstTraceFunctionExit1(WLANSTATUSINFO_STATUSTEXT_EXIT, this); + OstTraceFunctionEntry0(WLANSTATUSINFO_STATUSTEXT_ENTRY); + OstTraceFunctionExit0(WLANSTATUSINFO_STATUSTEXT_EXIT); return mStatusText; } /*! + Function for checking if WLAN is ON. + WLAN is enabled if the WLAN OnOff key is true and the force disable + wlan key is false. + + @return Returns true if WLAN is ON. +*/ + +bool WlanStatusInfo::isWlanOn() const +{ + OstTraceFunctionEntry0(WLANSTATUSINFO_ISWLANON_ENTRY); + + bool wlanOn = mSettingsManager->readItemValue(masterWlanKey).toBool(); + bool forcedOff = mSettingsManager->readItemValue(wlanForceKey).toBool(); + + OstTraceExt2( + TRACE_NORMAL, + WLANSTATUSINFO_ISWLANON, + "WlanStatusInfo::isWlanOn;wlanOn=%hhu;forcedOff=%hhu", + wlanOn, + forcedOff); + + OstTraceFunctionExit0(WLANSTATUSINFO_ISWLANON_EXIT); + return wlanOn && !forcedOff; +} + +/*! Slot used for updating the WLAN status. */ void WlanStatusInfo::updateStatus() { - OstTraceFunctionEntry1(WLANSTATUSINFO_UPDATESTATUS_ENTRY, this); + OstTraceFunctionEntry0(WLANSTATUSINFO_UPDATESTATUS_ENTRY); // Backup old status to detect changes QString oldStatusText = mStatusText; - int connectedIapId = mWlanQtUtils->connectedWlanId(); - + // Figure out current WLAN status - if (mWlanQtUtils->masterWlan() == false) { + if (!isWlanOn()) { // WLAN is switched OFF. mStatus = WlanStatusOff; mStatusText = hbTrId("txt_occ_dblist_wireless_lan_val_off"); - } else if (connectedIapId != WlanQtUtilsInvalidIapId) { + } else if (mWlanQtUtils->connectionStatus() == WlanQtUtils::ConnStatusConnected) { mStatus = WlanStatusConnected; - mStatusText = hbTrId("txt_occ_dblist_wireless_lan_val_connected_to_1") - .arg(mWlanQtUtils->iap(connectedIapId)->name()); + mStatusText = mWlanQtUtils->iapName(mWlanQtUtils->activeIap()); } else { mStatus = WlanStatusIdle; mStatusText = hbTrId("txt_occ_dblist_wireless_lan_val_wlan_is_on"); @@ -151,5 +191,5 @@ emit statusUpdated(); } - OstTraceFunctionExit1(WLANSTATUSINFO_UPDATESTATUS_EXIT, this); + OstTraceFunctionExit0(WLANSTATUSINFO_UPDATESTATUS_EXIT); } diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanentryplugin/traces/OstTraceDefinitions.h --- a/wlanutilities/wlanentryplugin/traces/OstTraceDefinitions.h Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanentryplugin/traces/OstTraceDefinitions.h Mon May 24 21:11:39 2010 +0300 @@ -1,18 +1,19 @@ /* - * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * This component and the accompanying materials are made available - * 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". - * - * Initial Contributors: - * Nokia Corporation - initial contribution. - * - * Contributors: - * - * Description: - */ +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* OST trace definition header. +*/ #ifndef __OSTTRACEDEFINITIONS_H__ #define __OSTTRACEDEFINITIONS_H__ diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanentryplugin/wlanentryplugin.pro --- a/wlanutilities/wlanentryplugin/wlanentryplugin.pro Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanentryplugin/wlanentryplugin.pro Mon May 24 21:11:39 2010 +0300 @@ -12,6 +12,7 @@ # Contributors: # # Description: +# WLAN Entry Plugin Qt project file. # TEMPLATE = lib @@ -22,10 +23,17 @@ # wlanutilities Private API INCLUDEPATH += ../inc CONFIG += hb plugin -MOC_DIR = moc -OBJECTS_DIR = obj -RCC_DIR = rcc -LIBS += -lwlanqtutilities -lcpframework -lxqservice -lqtsysteminfo +LIBS += -lwlanqtutilities -lcpframework -lxqservice -lxqserviceutil -lqtsysteminfo -lxqsettingsmanager + +# Temporary solution to fix tracecompiler +# When tracecompiler is fixed, this can be removed +symbian: { + MMP_RULES += "USERINCLUDE traces" +} + +#Store generated files to their own directory +MOC_DIR = build +RCC_DIR = build # Sources HEADERS += \ diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/base/inc/wlanqtutils.h --- a/wlanutilities/wlanqtutilities/base/inc/wlanqtutils.h Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanqtutilities/base/inc/wlanqtutils.h Mon May 24 21:11:39 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -12,151 +12,162 @@ * Contributors: * * Description: +* WLAN Qt Utilities interface. */ #ifndef WLANQTUTILS_H #define WLANQTUTILS_H -#include +// System includes -#include "wlanqtutilscommon.h" +#include +#include +#include + +// User includes + +// Forward declarations class WlanQtUtilsIap; -class WlanQtUtilsWlanIap; -class WlanQtUtilsWlanAp; +class WlanQtUtilsAp; class WlanQtUtilsPrivate; -const int WlanQtUtilsInvalidIapId = -1; +// External data types + +// Constants -/** - * Wlan Qt Utilities. - * - * This class provides a Qt API to UI components for retrieving different kind of information - * related to WLAN functionality. - */ -class WLANQTUTILITIESDLL_EXPORT WlanQtUtils : public QObject +//! Library interface export macro +#ifdef BUILD_WLANQTUTILITIES_DLL +#define WLANQTUTILS_EXPORT Q_DECL_EXPORT +#else +#define WLANQTUTILS_EXPORT Q_DECL_IMPORT +#endif + +// Class declaration + +class WLANQTUTILS_EXPORT WlanQtUtils : public QObject { Q_OBJECT public: + + // Data types + + //! "None" IAP ID value (e.g. for "not found" cases) + static const int IapIdNone = -1; + + /*! + WLAN connection status. + Remember to update traces/trace.properties when modifying this enum. + */ + enum ConnStatus { + ConnStatusNone = 0, //!< Reserved. + ConnStatusConnecting, //!< Connecting. + ConnStatusConnected, //!< Connected. + ConnStatusDisconnected //!< Disconnected. + }; - /** - * Constructor. - */ WlanQtUtils(); - /** - * Destructor. - */ ~WlanQtUtils(); - /** - * Function to request details of available WLAN networks. Can be called at any time, calling right - * after wlanScanReady() signal ensures you get the most recent results. - * - * @param[out] wlanIapList List of available WLAN IAPs. - * @param[out] wlanApList List of unknown WLAN APs. - */ - void availableWlanAps( - QList &wlanIapList, - QList &wlanApList); + void scanWlans(); + + void scanWlanAps(); + + void scanWlanDirect(const QString &ssid); + + void stopWlanScan(); + + void availableWlans( + QList< QSharedPointer > &wlanIapList, + QList< QSharedPointer > &wlanApList) const; - /** - * Function to create an IAP from the given WLAN access point. - * - * @param[in] wlanAp Access point containing parameters to include in the new IAP. - * @return ID of the newly created IAP. - */ - int createWlanIap(const WlanQtUtilsWlanAp *wlanAp); + void availableWlanAps( + QList< QSharedPointer > &wlanApList) const; + + int createIap(const WlanQtUtilsAp *wlanAp); - /** - * Function to start connection creation for the given IAP. connectionStatus() signal will be emitted - * when connection creation succeeds or fails. - * - * @param[in] iapId ID of the IAP to be connected. - */ - void connectIap(int iapId); + bool updateIap(int iapId, const WlanQtUtilsAp *wlanAp); - /** - * Function to disconnect the given IAP. - * - * @param[in] iapId ID of the IAP to be disconnected. - */ + void deleteIap(int iapId); + + void connectIap(int iapId, bool runIct = false); + void disconnectIap(int iapId); - /** - * Function to retrieve a pointer to the IAP with the given ID. - * - * @param[in] iapId ID of the requested IAP. - * @return Pointer to the found IAP, NULL if not found. - */ - WlanQtUtilsIap *iap(int iapId) const; + ConnStatus connectionStatus() const; + + int activeIap() const; + + QString iapName(int iapId) const; + +signals: + + /*! + Signal indicating that WLAN scan results are available. + */ + void wlanScanReady(); - /** - * Function for getting the master WLAN status. - * - * @return Master WLAN status: true if enabled, otherwise false. - */ - bool masterWlan() const; + /*! + Signal indicating that WLAN scan results are available when scanning + is requested with scanWlanAps() method. + */ + void wlanScanApReady(); - /** - * Function for switching the master WLAN status ON or OFF. - * - * @param[in] enabled If set to true, WLAN is switched ON, and vice versa. - */ - void setMasterWlan(bool enabled); + /*! + Signal indicating that WLAN scan results are available when scanning + is requested with scanWlanDirect() method. + */ + void wlanScanDirectReady(); - /** - * Function for getting the ID of the (possibly) connected WLAN IAP. - * - * @return ID of the connected IAP, WlanQtUtilsInvalidIapId if not valid. - */ - int connectedWlanId() const; + /*! + Signal indicating that new WLAN network has been opened. + + @param [in] iapId ID of the opened IAP. + */ + void wlanNetworkOpened(int iapId); + + /*! + Signal indicating that a WLAN network has been closed. - /** - * Function for requesting a WLAN scan to be triggered. Currently triggers - * only a single scan, but can be extended to perform also periodic scans, - * if needed in the future. - * - * Signal wlanScanReady() is emitted when new scan results are available. - */ - void scanWlans(); + @param [in] iapId ID of the closed IAP. + @param [in] reason RConnection::Start() error code. + This is the reason of the closure if user requested + connection creation and it failed. + Otherwise KErrNone. + */ + void wlanNetworkClosed(int iapId, int reason); + + /*! + Signal indicating result of finished ICT run. + + @param [in] iapId ID of IAP ICT was run for. + @param [in] result True: ICT passed, False: ICT failed. + */ + void ictResult(int iapId, bool result); -signals: - - /** - * Signal indicating that WLAN scan results are available. - */ - void wlanScanReady(); +public slots: - /** - * Signal indicating that new WLAN network has been opened. - * - * @param[in] iapId ID of the opened IAP. - */ - void wlanNetworkOpened(int iapId); +protected: + +protected slots: - /** - * Signal indicating that a WLAN network has been closed. - * - * @param[in] iapId ID of the closed IAP. - */ - void wlanNetworkClosed(int iapId); +private: + + Q_DISABLE_COPY(WlanQtUtils) + +private slots: - /** - * Signal indicating that the WLAN master status has changed. - */ - void masterWlanStatus(bool enabled); - -private: // Data +private: // data + + //! Pointer to private implementation + QScopedPointer d_ptr; - /** Pointer to private implementation */ - WlanQtUtilsPrivate *d_ptr; - -private: // Friend classes - - // This is defined as a friend class in order to be able to emit public signals - // directly from private implementation code. + // Friend classes + + // This is defined as a friend class in order to be able to emit public + // signals directly from private implementation code. friend class WlanQtUtilsPrivate; // This is defined as a friend class in order to be able to @@ -164,6 +175,4 @@ friend class TestWlanQtUtils; }; -#endif /* WLANQTUTILS_H */ - -// End of File +#endif // WLANQTUTILS_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/base/inc/wlanqtutils_p.h --- a/wlanutilities/wlanqtutilities/base/inc/wlanqtutils_p.h Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanqtutilities/base/inc/wlanqtutils_p.h Mon May 24 21:11:39 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -12,228 +12,157 @@ * Contributors: * * Description: +* WLAN Qt Utilities private implementation interface. */ #ifndef WLANQTUTILS_P_H #define WLANQTUTILS_P_H +// System includes + #include -#include +#include +#include -#include "wlanqtutilscommon.h" +// User includes + +#include "wlanqtutils.h" + +// Forward declarations class WlanQtUtils; class WlanQtUtilsIap; -class WlanQtUtilsWlanIap; -class WlanQtUtilsWlanAp; -class WlanQtUtilsActiveConn; -class ConMonWrapper; -class CmmWrapper; -class EsockWrapper; +class WlanQtUtilsAp; +class WlanQtUtilsConnection; +class WlanQtUtilsIapSettings; +class WlanQtUtilsConMonWrapper; +class WlanQtUtilsEsockWrapper; class ConnTestWrapper; -/** - * Private implementation of Wlan Qt Utilities. - */ +// External data types + +// Constants + +// Class declaration + class WlanQtUtilsPrivate : public QObject { Q_OBJECT public: - - /** - * Constructor. - */ - WlanQtUtilsPrivate(WlanQtUtils *publicPtr); - - /** - * Destructor. - */ - ~WlanQtUtilsPrivate(); + + // Data types - // Functions duplicating WlanQtUtils public interface - - /** - * Function to request details of available WLAN networks. Can be called at any time, calling right - * after wlanScanReady() signal ensures you get the most recent results. - * - * @param[out] wlanIapList List of available WLAN IAPs. - * @param[out] wlanApList List of unknown WLAN APs. - */ - void availableWlanAps( - QList &wlanIapList, - QList &wlanApList); + explicit WlanQtUtilsPrivate(WlanQtUtils *q_ptr); - /** - * Function to create an IAP from the given WLAN access point. - * - * @param[in] wlanAp Access point containing parameters to include in the new IAP. - * @return ID of the newly created IAP. - */ - int createWlanIap(const WlanQtUtilsWlanAp *wlanAp); - - /** - * Function to start connection creation for the given IAP. connectionStatus() signal will be emitted - * when connection creation succeeds or fails. - * - * @param[in] iapId ID of the IAP to be connected. - */ - void connectIap(int iapId); + virtual ~WlanQtUtilsPrivate(); - /** - * Function to disconnect the given IAP. - * - * @param[in] iapId ID of the IAP to be disconnected. - */ - void disconnectIap(int iapId); - - /** - * Function to retrieve a pointer to the IAP with the given ID. - * - * @param[in] iapId ID of the requested IAP. - * @return Pointer to the found IAP, NULL if not found. - */ - WlanQtUtilsIap *iap(int iapId) const; - - /** - * Function for getting the master WLAN status. - * - * @return Master WLAN status: true if enabled, otherwise false. - */ - bool masterWlan() const; - - /** - * Function for switching the master WLAN status ON or OFF. - * - * @param[in] enabled If set to true, WLAN is switched ON, and vice versa. - */ - void setMasterWlan(bool enabled); - - /** - * Function for getting the ID of the (possibly) connected WLAN IAP. - * - * @return ID of the connected IAP, WlanQtUtilsInvalidIapId if not valid. - */ - int connectedWlanId() const; - - /** - * Function for requesting a WLAN scan to be triggered. Currently triggers - * only a single scan, but can be extended to perform also periodic scans, - * if needed in the future. - * - * Signal wlanScanReady() is emitted when new scan results are available. - */ void scanWlans(); + void scanWlanAps(); + + void scanWlanDirect(const QString &ssid); + + void stopWlanScan(); + + void availableWlans( + QList< QSharedPointer > &wlanIapList, + QList< QSharedPointer > &wlanApList) const; + + void availableWlanAps( + QList< QSharedPointer > &wlanApList) const; + + int createIap(const WlanQtUtilsAp *wlanAp); + + bool updateIap(int iapId, const WlanQtUtilsAp *wlanAp); + + void deleteIap(int iapId); + + void connectIap(int iapId, bool runIct); + + void disconnectIap(int iapId); + + WlanQtUtils::ConnStatus connectionStatus() const; + + int activeIap() const; + + QString iapName(int iapId) const; + +signals: + +public slots: + +protected: + +protected slots: + +private: + + Q_DISABLE_COPY(WlanQtUtilsPrivate) + + bool wlanIapExists( + const QList< QSharedPointer > list, + const WlanQtUtilsAp *ap) const; + + void traceIapsAndAps( + const QList< QSharedPointer > &iaps, + const QList< QSharedPointer > &aps) const; + private slots: - /** - * Slot for handling WLAN scan result event from wrapper. Results are stored in member variable - * (possible duplicates are removed). - * - * @param[in] availableWlans WLAN networks found in scan. - */ - void updateAvailableWlanAps(QList &availableWlans); - - /** - * Slot for handling connection setup status event from wrapper. - * - * @param[in] isOpened Was connection setup successful? - */ + void updateAvailableWlanAps( + QList< QSharedPointer > &availableWlans); + void updateConnectionStatus(bool isOpened); - - /** - * Slot for handling connectivity test result event from wrapper. Tested IAP is stored to - * Internet SNAP, if test was successful. - * - * @param[in] result Was the test successful? - */ + void updateConnectivityTestResult(bool result); - /** - * Slot for updating active connection status from wrapper. - * - * @param[in] connectionId ID of the new connection. - */ void addActiveConnection(uint connectionId); - /** - * Slot for updating active connection status from wrapper. - * - * @param[in] connectionId ID of the deleted connection. - */ void removeActiveConnection(uint connectionId); - /** - * Slot for updating active connection status from wrapper. - * - * @param[in] connectionId ID of the updated connection. - * @param[in] connectionStatus New status of the connection. - */ - void updateActiveConnection(uint connectionId, WlanQtUtilsConnectionStatus connectionStatus); - -private: + void updateActiveConnection( + uint connectionId, + WlanQtUtils::ConnStatus connectionStatus); + +private: // data + + // Not owned data - int fetchIaps(); + //! Pointer to public implementation. + WlanQtUtils *q_ptr; + + // Owned data + + //! Iap settings handler. + WlanQtUtilsIapSettings *mSettings; - /** - * This function searches for a WLAN IAP with the given WLAN parameters. - * - * @param[in] ssid SSID to search for. - * @param[in] secMode Security mode to search for. - * @return True, if suitable WLAN IAP found, false otherwise. - */ - bool wlanIapExists(QString ssid, WlanQtUtilsWlanSecMode secMode); - - /** - * This function updates the connection status of: - * - IAP with the given ID - * - all other IAPs, which represent the same network (SSID & security mode match) - * - * @param[in] iapId ID of the IAP whose status is to be updated. - * @param[in] status Updated connection status. - */ - void updateIapConnectionStatuses(int iapId, WlanQtUtilsConnectionStatus status); - -private: // Data + //! Wrapper object for Connection Monitor and other parts of connmon library. + WlanQtUtilsConMonWrapper *mConMonWrapper; - /** Pointer to public implementation */ - WlanQtUtils *q_ptr; - - /** Wrapper object for Connection Method Manager. */ - CmmWrapper *cmmWrapper_; - - /** Wrapper object for Connection Monitor and other parts of connmon library. */ - ConMonWrapper *conMonWrapper_; - - /** Wrapper object for esock library. */ - EsockWrapper *esockWrapper_; + //! Wrapper object for esock library. + WlanQtUtilsEsockWrapper *mEsockWrapper; - /** Wrapper object for Internet Connectivity Test library. */ - ConnTestWrapper *connTestWrapper_; + //! Wrapper object for Internet Connectivity Test library. + ConnTestWrapper *mConnTestWrapper; + + //! List of available WLAN APs according to the latest scan. + QList< QSharedPointer > mWlanScanList; - /** List of available WLAN APs according to the latest scan. */ - QList wlanScanList_; + //! ID of IAP requiring ICT running, IapIdNone if not valid. + int mToBeTestedIapId; - /** List of WLAN IAPs configured to the device. */ - QMap wlanIapList_; - - /** ID of IAP requiring ICT running, -1 if not valid. */ - int toBeTestedIapId_; + //! ID of IAP being connected by us (requested by UI), IapIdNone if not valid. + int mConnectingIapId; - /** ID of IAP being connected by us (requested by UI), -1 if not valid. */ - int connectingIapId_; + //! Information of possible active connection. + QSharedPointer mConnection; + + // Friend classes - /** Information of possible active connection. */ - WlanQtUtilsActiveConn *activeConnection_; - -private: // Friend classes - // This is defined as a friend class in order to be able to // call event handlers of wrappers from test code. friend class TestWlanQtUtils; }; -#endif /* WLANQTUTILS_P_H */ - -// End of File +#endif // WLANQTUTILS_P_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/base/inc/wlanqtutilsactiveconn.h --- a/wlanutilities/wlanqtutilities/base/inc/wlanqtutilsactiveconn.h Fri May 14 10:30:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,113 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* 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". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* This is the header file for WlanQtUtilsActiveConn class. -*/ - -#ifndef WLANQTUTILSACTIVECONN_H -#define WLANQTUTILSACTIVECONN_H - -#include -#include "wlanqtutilscommon.h" - - -/** - * This class represents an active connection. - * TODO: consider deriving own classes for WLAN and Cellular connections. - * Still, we can keep the same interface and avoid dynamic_casts. - */ -class WlanQtUtilsActiveConn : public QObject -{ -public: - - /** - * Constructor. - */ - WlanQtUtilsActiveConn(); - - /** - * Destructor. - */ - virtual ~WlanQtUtilsActiveConn(); - - /** - * Getter. - * - * @return Connection ID specific for Connection Monitor Server. - */ - uint connectionId() const; - - /** - * Setter. - * - * @param[in] connectionId Connection ID specific for Connection Monitor Server. - */ - void setConnectionId(uint connectionId); - - /** - * Getter. - * - * @return IAP ID. - */ - uint iapId() const; - - /** - * Setter. - * - * @param[in] iapId IAP ID. - */ - void setIapId(uint iapId); - - /** - * Getter. - * - * @return Status of the connection. - */ - WlanQtUtilsConnectionStatus connectionStatus() const; - - /** - * Setter. - * - * @param[in] connectionStatus Status of the connection. - */ - void setConnectionStatus(WlanQtUtilsConnectionStatus connectionStatus); - - /** - * Getter. - * - * @return Bearer type. - */ - WlanQtUtilsBearerType bearerType() const; - - /** - * Setter. - * - * @param[in] bearerType Bearer type. - */ - void setBearerType(WlanQtUtilsBearerType bearerType); - -private: // Data - - /** Connection Monitor Server specific connection ID. */ - uint connectionId_; - /** IAP ID. */ - uint iapId_; - - /** Connection status. */ - WlanQtUtilsConnectionStatus connectionStatus_; - /** Bearer type. */ - WlanQtUtilsBearerType bearerType_; -}; - -#endif /* WLANQTUTILSACTIVECONN_H */ diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/base/inc/wlanqtutilsap.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/base/inc/wlanqtutilsap.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,165 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN AP (Access Point, unknown network) class. +*/ + +#ifndef WLANQTUTILSAP_H +#define WLANQTUTILSAP_H + +// System includes + +#include +#include +#include +#include + +// User includes + +// Forward declarations + +class WlanQtUtilsApPrivate; + +// External data types + +// Constants + +//! Library interface export macro +#ifdef BUILD_WLANQTUTILITIES_DLL +#define WLANQTUTILSAP_EXPORT Q_DECL_EXPORT +#else +#define WLANQTUTILSAP_EXPORT Q_DECL_IMPORT +#endif + +// Class declaration + +class WLANQTUTILSAP_EXPORT WlanQtUtilsAp +{ + +public: + + // Data types + + /*! + Configuration IDs that can be read and set in this class. + Remember to update traces/trace.properties file when modifying + this enum (tracing is also the cause for fixing the enum values). + + Scan Results: + - ConfIdSsid + - ConfIdSignalStrength + - ConfIdConnectionMode + - ConfIdSecurityMode + - ConfIdWpaPskUse + - ConfIdWpsSupported + + IAP creation and updates: + Mandatory for all security modes: + - ConfIdSsid + - ConfIdConnectionMode + - ConfIdSecurityMode + - ConfIdHidden + + Open: No extra configurations. + 802.1x: No extra configurations. + + WEP: + - ConfIdWepKey1 + - ConfIdWepKey2 + - ConfIdWepKey3 + - ConfIdWepKey4 + - ConfIdWepDefaultIndex + + WPA/WPA2: + - ConfIdWpaPskUse + - ConfIdWpaPsk + */ + enum ConfId { + //! QString: WLAN Network Name (SSID) + ConfIdSsid = 0, + //! int: signal strength in RSSI (dBm) + ConfIdSignalStrength = 1, + //! int: (CMManagerShim::WlanNetMode) + ConfIdConnectionMode = 2, + //! int: (CMManagerShim::WlanSecMode) + ConfIdSecurityMode = 3, + //! bool: true - WPA PSK, false - WPA EAP + ConfIdWpaPskUse = 4, + //! QString: Pre-Shared Key for WPA + //! Length: 8-63 - Ascii key + //! Length: 64 - Hex key + ConfIdWpaPsk = 5, + //! QString: WEP Key for index 1: + //! HEX: + //! - 64 bit: allowed key length = 10 + //! - 128 bit: allowed key length = 26 + //! + //! ASCII: + //! - 64 bit: allowed key length = 5 + //! - 128 bit: allowed key length = 13 + ConfIdWepKey1 = 6, + //! QString: WEP Key for index 2 + ConfIdWepKey2 = 7, + //! QString: WEP Key for index 3 + ConfIdWepKey3 = 8, + //! QString: WEP Key for index 4 + ConfIdWepKey4 = 9, + //! int: (CMManagerShim::WlanWepKeyIndex): Default WEP Key index + ConfIdWepDefaultIndex = 10, + //! bool: Is WLAN Hidden: true - hidden, false - not hidden. + ConfIdHidden = 11, + //! bool: true - Wifi Protected setup is supported, false - not + ConfIdWpsSupported = 12 + }; + + WlanQtUtilsAp(); + + WlanQtUtilsAp(const WlanQtUtilsAp &ref); + + virtual ~WlanQtUtilsAp(); + + QVariant value(int identifier) const; + + void setValue(int identifier, QVariant value); + + static bool compare( + const WlanQtUtilsAp *ap1, + const WlanQtUtilsAp *ap2); + +signals: + +public slots: + +protected: + +protected slots: + +private: + + // Disabling implicit assignment operator + WlanQtUtilsAp &operator=(const WlanQtUtilsAp &); + +private slots: + +private: // data + + QScopedPointer d_ptr; //!< Private implementation + + // Friend classes +}; + +// Metatype support is needed since we use this class with QVariant +Q_DECLARE_METATYPE(WlanQtUtilsAp) + +#endif // WLANQTUTILSAP_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/base/inc/wlanqtutilscommon.h --- a/wlanutilities/wlanqtutilities/base/inc/wlanqtutilscommon.h Fri May 14 10:30:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,101 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* 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". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef WLANQTUTILSCOMMON_H -#define WLANQTUTILSCOMMON_H - -#ifdef BUILD_WLANQTUTILITIES_DLL -#define WLANQTUTILITIESDLL_EXPORT Q_DECL_EXPORT -#else -#define WLANQTUTILITIESDLL_EXPORT Q_DECL_IMPORT -#endif - -// Maximum length of WLAN SSID (limit also for number of characters for user input) -static const int KMaxSsidLen = 32; -// Maximum length of WEP key -static const int KMaxWEPKeyLen = 64; -// Maximum length of WPA key -static const int KMaxWPAKeyLen = 256; - -/** - * Bearer type. - */ -enum WlanQtUtilsBearerType { - WlanQtUtilsBearerTypeNone = 0, ///< None of the bearer types. - WlanQtUtilsBearerTypeCellular , ///< Cellular (2G, 3G, 3.5G) bearer type. - WlanQtUtilsBearerTypeWlan ///< WLAN bearer type. -}; - -/** - * Connection status. - */ -enum WlanQtUtilsConnectionStatus { - WlanQtUtilsConnectionStatusNone = 0, ///< None of the connection statuses. - WlanQtUtilsConnectionStatusConnecting, ///< Connecting. - WlanQtUtilsConnectionStatusConnected, ///< Connected. - WlanQtUtilsConnectionStatusDisconnected ///< Disconnected. -}; - -/** - * Signal strength category boundaries in dB (absolute value). - * Smaller value means better signal. - */ -// TODO: WLAN signal level values valid are copied from 08wk41 Sniffer. OK? -// (WINS emulator gives just 0 which is equal to "Absolute max"...) -enum -{ - WlanQtUtilsWlanSignalStrengthAbsoluteMax = 0, ///< Absolute maximum signal strength. - WlanQtUtilsWlanSignalStrengthMax = 60, ///< Maximum signal strength. - WlanQtUtilsWlanSignalStrengthGood = 74, ///< Good signal strength. - WlanQtUtilsWlanSignalStrengthLow = 87, ///< signal strength. - WlanQtUtilsWlanSignalStrengthMin = 100, ///< Minimum signal strength. - WlanQtUtilsWlanSignalUnavailable = 9999, ///< Signal is unavailable. -}; - -/** WLAN signal is unknown. */ -const int WlanQtUtilsWlanSignalUnknown = 1000000; - -/** WLAN transmit power is unknown. */ -const unsigned WlanQtUtilsWlanTransmitPowerUnknown = 0xFFFFFFFF; - -/** - * WLAN security modes. - * Mapping functions exist for reading and writing these values - * from / to ConnMon and CMM. - */ -enum WlanQtUtilsWlanSecMode -{ - WlanQtUtilsWlanSecModeNone = 100, ///< None of the security modes. - WlanQtUtilsWlanSecModeOpen = 101, ///< Open security mode. - WlanQtUtilsWlanSecModeWep = 102, ///< WEP security mode. - WlanQtUtilsWlanSecMode802_1x = 103, ///< 802.1x security mode. - WlanQtUtilsWlanSecModeWpa = 104, ///< WPA security mode. - WlanQtUtilsWlanSecModeWpa2 = 105 ///< WPA@ security mode. -}; - -/** - * WLAN connection modes. - */ -enum WlanQtUtilsWlanConnMode -{ - WlanQtUtilsWlanConnModeNone = 200, ///< None of the connection modes. - WlanQtUtilsWlanConnModeInfraStructure = 201, ///< Infrastructure connection mode. - WlanQtUtilsWlanConnModeAdHoc = 202, ///< Adhoc connection mode. - WlanQtUtilsWlanConnModeSecureInfra = 203, ///< Secure infrastructure connection mode.´ -}; - -#endif // WLANQTUTILSCOMMON_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/base/inc/wlanqtutilsconnection.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/base/inc/wlanqtutilsconnection.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,87 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Qt Utilities WLAN connection status handler. +*/ + +#ifndef WLANQTUTILSCONNECTION_H +#define WLANQTUTILSCONNECTION_H + +// System includes + +#include + +// User includes + +#include "wlanqtutils.h" + +// Forward declarations + +// External data types + +// Constants + +// Class declaration + +class WlanQtUtilsConnection +{ + +public: + + // Data types + + WlanQtUtilsConnection(); + + virtual ~WlanQtUtilsConnection(); + + uint connectionId() const; + + void setConnectionId(uint connectionId); + + uint iapId() const; + + void setIapId(uint iapId); + + WlanQtUtils::ConnStatus connectionStatus() const; + + void setConnectionStatus( + WlanQtUtils::ConnStatus connectionStatus); + +signals: + +public slots: + +protected: + +protected slots: + +private: + +private slots: + +private: // data + + //! Connection Monitor Server specific connection ID. + uint mConnectionId; + + //! IAP ID. + uint mIapId; + + //! Connection status. + WlanQtUtils::ConnStatus mConnectionStatus; + + // Friend classes +}; + +#endif // WLANQTUTILSCONNECTION_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/base/inc/wlanqtutilsiap.h --- a/wlanutilities/wlanqtutilities/base/inc/wlanqtutilsiap.h Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanqtutilities/base/inc/wlanqtutilsiap.h Mon May 24 21:11:39 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -12,49 +12,93 @@ * Contributors: * * Description: -* This is a header file for WlanQtUtilsIap class. +* WLAN IAP (Internet Access Point, known network) class. */ #ifndef WLANQTUTILSIAP_H #define WLANQTUTILSIAP_H -#include -#include "wlanqtutilscommon.h" +// System includes + +#include + +// User includes + +#include "wlanqtutilsap.h" + +// Forward declarations + +class WlanQtUtilsIapPrivate; + +// External data types -class QString; +// Constants -class WLANQTUTILITIESDLL_EXPORT WlanQtUtilsIap : public QObject +//! Library interface export macro +#ifdef BUILD_WLANQTUTILITIES_DLL +#define WLANQTUTILSIAP_EXPORT Q_DECL_EXPORT +#else +#define WLANQTUTILSIAP_EXPORT Q_DECL_IMPORT +#endif + +// Class declaration + +class WLANQTUTILSIAP_EXPORT WlanQtUtilsIap : public WlanQtUtilsAp { - + public: + // Data types + + /*! + Configuration IDs that can be read and set in this class (via + functions declared in the parent class). Values under 100 are + reserved for the parent class. + + Remember to update traces/trace.properties file when modifying + this enum (tracing is also the cause for fixing the enum values). + + Values available for IAPs: + - ConfIdIapId + - ConfIdName + - ConfIdNetworkId + - WlanQtUtilsAp::ConfIdSsid + - WlanQtUtilsAp::ConfIdSignalStrength + - WlanQtUtilsAp::ConfIdSecurityMode + - WlanQtUtilsAp::ConfIdWpaPskUse + */ + enum ConfId { + //! int: IAP ID + ConfIdIapId = 100, + //! QString: Name + ConfIdName = 101, + //! int: Network ID + ConfIdNetworkId = 102 + }; + WlanQtUtilsIap(); - WlanQtUtilsIap( - int id, - int netId, - QString name, - WlanQtUtilsBearerType bearerType); + virtual ~WlanQtUtilsIap(); - int id() const; - int networkId() const; - QString name() const; - WlanQtUtilsBearerType bearerType() const; - WlanQtUtilsConnectionStatus connectionStatus() const; - - void setId(int id); - void setNetworkId(int NetId); - void setName(QString name); - void setBearerType(WlanQtUtilsBearerType bearerType); - void setConnectionStatus(WlanQtUtilsConnectionStatus connectionStatus); +signals: + +public slots: + +protected: + +protected slots: private: - int id_; - int netId_; - QString name_; - WlanQtUtilsBearerType bearerType_; - WlanQtUtilsConnectionStatus connectionStatus_; - // TODO: SNAP ID list + + Q_DISABLE_COPY(WlanQtUtilsIap) + +private slots: + +private: // data + + QScopedPointer d_ptr; //!< Private implementation + + // Friend classes }; -#endif /* WLANQTUTILSIAP_H */ +#endif // WLANQTUTILSIAP_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/base/inc/wlanqtutilsiapsettings.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/base/inc/wlanqtutilsiapsettings.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Qt Utilities WLAN IAP settings handling. +*/ + +#ifndef WLANQTUTILSIAPSETTINGS_H +#define WLANQTUTILSIAPSETTINGS_H + +// System includes + +#include +#include +#include + +// User includes + +// Forward declarations + +class CmManagerShim; +class CmConnectionMethodShim; +class WlanQtUtilsIap; +class WlanQtUtilsAp; + +// External data types + +// Constants + +// Class declaration + +class WlanQtUtilsIapSettings : public QObject +{ + Q_OBJECT + +public: + + // Data types + + explicit WlanQtUtilsIapSettings(QObject *parent = 0); + + virtual ~WlanQtUtilsIapSettings(); + + void fetchIaps(QList< QSharedPointer > &iapList) const; + + QSharedPointer fetchIap(int iapId) const; + + int createIap(const WlanQtUtilsAp *wlanAp); + + bool updateIap(int iapId, const WlanQtUtilsAp *wlanAp); + + void deleteIap(int iapId); + + void moveIapToInternetSnap(int iapId); + +signals: + +public slots: + +protected: + +protected slots: + +private: + + Q_DISABLE_COPY(WlanQtUtilsIapSettings) + + void storeSettings( + const WlanQtUtilsAp *wlanAp, + CmConnectionMethodShim *iap); + + void storeWepKey( + const QString &key, + int index, + CmConnectionMethodShim *iap); + +private slots: + +private: // data + + CmManagerShim *mCmManager; //!< CmManager instance + + // Friend classes +}; + +#endif // WLANQTUTILSIAPSETTINGS_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/base/inc/wlanqtutilswlanap.h --- a/wlanutilities/wlanqtutilities/base/inc/wlanqtutilswlanap.h Fri May 14 10:30:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,167 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* 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". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* This is the header file for WlanQtUtilsWlanAp class. -*/ - -#ifndef WLANQTUTILSWLANAP_H -#define WLANQTUTILSWLANAP_H - -#include -#include -#include "wlanqtutilscommon.h" - -class QString; - -/** - * This class represents WLAN access point (AP). - */ -class WLANQTUTILITIESDLL_EXPORT WlanQtUtilsWlanAp : public QObject -{ -public: - - /** - * Constructor. - */ - WlanQtUtilsWlanAp(); - - /** - * Copy constructor. - */ - WlanQtUtilsWlanAp(const WlanQtUtilsWlanAp &ref); - - /** - * Constructor. - * - * @param ssid SSID. - * @param bssid BSSID, that is, MAC address. - * @param signalStrength Signal strength. - * @param connectionMode Connection mode as TConnMonNetworkMode. - * @param securityMode WLAN Security mode. - */ - WlanQtUtilsWlanAp( - QString ssid, - QString bssid, - int signalStrength, - int connectionMode, - WlanQtUtilsWlanSecMode securityMode); - - /** - * Destructor. - */ - virtual ~WlanQtUtilsWlanAp(); - - /** - * Returns SSID. - * - * @return SSID. - */ - QString ssid() const; - - /** - * Getter. - * - * @return BSSID. - */ - QString bssid() const; - - /** - * Getter. - * - * @return Signal strength. - */ - int signalStrength() const; - - /** - * Getter. - * - * @return Connection mode as TConnMonNetworkMode. - */ - int connectionMode() const; - - /** - * Getter. - * - * @return Security mode as WlanQtUtilsWlanSecMode. - */ - WlanQtUtilsWlanSecMode securityMode() const; - - /** - * Getter. - * - * @return Security key. - */ - QString securityKey() const; - - /** - * Setter. - * - * @param SSID. - */ - void setSsid(QString ssid); - - /** - * Setter. - * - * @param BSSID. - */ - void setBssid(QString bssid); - - /** - * Setter. - * - * @param Signal strength. - */ - void setSignalStrength(int signalStrength); - - /** - * Setter. - * - * @param connectionMode Connection mode as TConnMonNetworkMode. - */ - void setConnectionMode(int connectionMode); - - /** - * Setter. - * - * @param securityMode WLAN Security mode. - */ - void setSecurityMode(WlanQtUtilsWlanSecMode securityMode); - - /** - * Setter. - * - * @param securityKey WLAN Security key. - */ - void setSecurityKey(QString securityKey); - -private: //data - - /** SSID */ - QString ssid_; - /** BSSID, that is, MAC address. */ - QString bssid_; // TODO: Check if QString is suitable - /** Signal strength. */ - int signalStrength_; - /** Connection mode as TConnMonNetworkMode. */ - int connectionMode_; - /** WLAN security mode. */ - WlanQtUtilsWlanSecMode securityMode_; - /** Security key, if available. */ - QString securityKey_; -}; - -Q_DECLARE_METATYPE(WlanQtUtilsWlanAp) - -#endif /* WLANQTUTILSWLANIAP_H */ diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/base/inc/wlanqtutilswlaniap.h --- a/wlanutilities/wlanqtutilities/base/inc/wlanqtutilswlaniap.h Fri May 14 10:30:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* 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". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* This is a header file for WlanQtUtilsWlanIap class. -*/ - -#ifndef WLANQTUTILSWLANIAP_H -#define WLANQTUTILSWLANIAP_H - -#include "wlanqtutilscommon.h" -#include "wlanqtutilsiap.h" - -class WLANQTUTILITIESDLL_EXPORT WlanQtUtilsWlanIap : public WlanQtUtilsIap -{ - // Q_OBJECT macro needed for qobject_cast to work - Q_OBJECT - -public: - WlanQtUtilsWlanIap(); - WlanQtUtilsWlanIap(int id, int netId, QString name, WlanQtUtilsBearerType bearerType, QString ssid, WlanQtUtilsWlanSecMode securityMode); - virtual ~WlanQtUtilsWlanIap(); - - QString ssid() const; - int signalStrength() const; - WlanQtUtilsWlanSecMode securityMode() const; - - void setSsid(QString ssid); - void setSignalStrength(int signalStrength); - void setSecurityMode(WlanQtUtilsWlanSecMode securityMode); - -private: - QString ssid_; - int signalStrength_; - WlanQtUtilsWlanSecMode securityMode_; - // TODO: secKey_ (type unknown) -}; - -#endif /* WLANQTUTILSWLANIAP_H */ diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/base/src/wlanqtutils.cpp --- a/wlanutilities/wlanqtutilities/base/src/wlanqtutils.cpp Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanqtutilities/base/src/wlanqtutils.cpp Mon May 24 21:11:39 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -12,69 +12,231 @@ * Contributors: * * Description: +* WLAN Qt Utilities implementation. */ -#include "wlanqtutilswlanap.h" -#include "wlanqtutilswlaniap.h" +// System includes +// User includes + +#include "wlanqtutilsap.h" +#include "wlanqtutilsiap.h" #include "wlanqtutils_p.h" #include "wlanqtutils.h" -WlanQtUtils::WlanQtUtils() +/*! + \class WlanQtUtils + \brief Wlan Qt Utilities. This class provides a Qt API for UI components + for retrieving different kind of information related to WLAN + functionality. +*/ + + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +/*! + Constructor. +*/ + +WlanQtUtils::WlanQtUtils() : + d_ptr(new WlanQtUtilsPrivate(this)) { - d_ptr = new WlanQtUtilsPrivate(this); } +/*! + Destructor. +*/ + WlanQtUtils::~WlanQtUtils() { - delete d_ptr; +} + +/*! + Function for requesting a single WLAN scan to be triggered. + Signal wlanScanReady() is emitted when new scan results are available. +*/ + +void WlanQtUtils::scanWlans() +{ + d_ptr->scanWlans(); +} + +/*! + Function for requesting a WLAN AP scan to be triggered. + Signal availableWlanAps() is emitted when new scan results are available. +*/ + +void WlanQtUtils::scanWlanAps() +{ + d_ptr->scanWlanAps(); } -void WlanQtUtils::availableWlanAps( - QList &wlanIapList, - QList &wlanApList) +/*! + Function for requesting a direct WLAN scan with given SSID. + + Signal wlanScanDirectReady() is emitted when new scan results are + available. + + @param [in] ssid Network name to be found +*/ + +void WlanQtUtils::scanWlanDirect(const QString &ssid) { - d_ptr->availableWlanAps(wlanIapList, wlanApList); + d_ptr->scanWlanDirect(ssid); +} + +/*! + Function for stopping a (possibly) ongoing WLAN scan. No scan result + signal will be sent before a new scan request is made. +*/ + +void WlanQtUtils::stopWlanScan() +{ + d_ptr->stopWlanScan(); +} + +/*! + Function to request details of available WLAN networks. Can be called + at any time. Calling right after wlanScanReady() signal ensures you get + the most recent results. + + @param [out] wlanIapList List of available WLAN IAPs. + @param [out] wlanApList List of unknown WLAN APs. +*/ + +void WlanQtUtils::availableWlans( + QList< QSharedPointer > &wlanIapList, + QList< QSharedPointer > &wlanApList) const +{ + d_ptr->availableWlans(wlanIapList, wlanApList); } -int WlanQtUtils::createWlanIap(const WlanQtUtilsWlanAp *wlanAp) +/*! + Function to request details of available WLAN networks. This function is + used to get the results that are informed by following signals: + -wlanScanApReady() + -wlanScanDirectReady() + + @param [out] wlanApList List of unknown WLAN APs. +*/ + +void WlanQtUtils::availableWlanAps( + QList< QSharedPointer > &wlanApList) const { - return d_ptr->createWlanIap(wlanAp); + d_ptr->availableWlanAps(wlanApList); +} + +/*! + Function to create an IAP from the given WLAN access point. + + @param [in] wlanAp Access point containing parameters to include in the new IAP. + + @return IAP ID if creation succeeds, IapIdNone otherwise. +*/ + +int WlanQtUtils::createIap(const WlanQtUtilsAp *wlanAp) +{ + return d_ptr->createIap(wlanAp); } -void WlanQtUtils::connectIap(int iapId) +/*! + Function to update an IAP from the given WLAN access point. + + @param [in] iapId ID of the IAP to be updated. + @param [in] wlanAp Access point containing parameters to update in the IAP. + + @return Was update successful? +*/ + +bool WlanQtUtils::updateIap(int iapId, const WlanQtUtilsAp *wlanAp) +{ + return d_ptr->updateIap(iapId, wlanAp); +} + +/*! + Function to delete an IAP. + + @param [in] iapId ID of the IAP to be deleted. +*/ + +void WlanQtUtils::deleteIap(int iapId) { - d_ptr->connectIap(iapId); + d_ptr->deleteIap(iapId); } +/*! + Function to start connection creation for the given IAP. Runs also + Internet Connectivity Test (ICT), if requested with the optional + parameter. + + Connecting while there is already a connection is also supported. + + wlanNetworkOpened() or wlanNetworkClosed() signal will be emitted + when connection status changes. + + ictResult() signal will be emitted when (possible) ICT result is + available. + + @param [in] iapId ID of the IAP to be connected. + @param [in] runIct Should ICT be run or not? +*/ + +void WlanQtUtils::connectIap(int iapId, bool runIct) +{ + d_ptr->connectIap(iapId, runIct); +} + +/*! + Function to disconnect the given IAP. + Disconnecting when there is no connection is also supported. + + @param [in] iapId ID of the IAP to be disconnected. +*/ + void WlanQtUtils::disconnectIap(int iapId) { d_ptr->disconnectIap(iapId); } -WlanQtUtilsIap *WlanQtUtils::iap(int iapId) const +/*! + Function to retrieve the name of the IAP with the given ID. + + @param [in] iapId ID of the requested IAP. + + @return Name of the IAP or empty QString if IAP is not found. +*/ + +QString WlanQtUtils::iapName(int iapId) const { - return d_ptr->iap(iapId); -} - -bool WlanQtUtils::masterWlan() const -{ - return d_ptr->masterWlan(); + return d_ptr->iapName(iapId); } -void WlanQtUtils::setMasterWlan(bool enabled) +/*! + Connection status getter. + + @return Current WLAN connection status. +*/ + +WlanQtUtils::ConnStatus WlanQtUtils::connectionStatus() const { - d_ptr->setMasterWlan(enabled); + return d_ptr->connectionStatus(); } -int WlanQtUtils::connectedWlanId() const -{ - return d_ptr->connectedWlanId(); -} +/*! + Function for getting the ID of the (possibly) active WLAN IAP. + Active here means non-disconnected. + Use connectionStatus() for retrieving the actual status. -void WlanQtUtils::scanWlans() + @return ID of the active IAP, IapIdNone if not valid. +*/ + +int WlanQtUtils::activeIap() const { - d_ptr->scanWlans(); + return d_ptr->activeIap(); } - -// End of File diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/base/src/wlanqtutils_p.cpp --- a/wlanutilities/wlanqtutilities/base/src/wlanqtutils_p.cpp Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanqtutilities/base/src/wlanqtutils_p.cpp Mon May 24 21:11:39 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -12,12 +12,19 @@ * Contributors: * * Description: +* WLAN Qt Utilities private implementation. */ -#include "wlanqtutilswlanap.h" -#include "wlanqtutilswlaniap.h" -#include "wlanqtutilsactiveconn.h" -#include "wlanqtutilscmmwrapper.h" +// System includes + +#include + +// User includes + +#include "wlanqtutilsap.h" +#include "wlanqtutilsiap.h" +#include "wlanqtutilsconnection.h" +#include "wlanqtutilsiapsettings.h" #include "wlanqtutilsconmonwrapper.h" #include "wlanqtutilsesockwrapper.h" #include "wlanqtutilsconntestwrapper.h" @@ -25,466 +32,690 @@ #include "wlanqtutils.h" #include "wlanqtutils_p.h" -#ifdef WLANQTUTILS_NO_OST_TRACES_FLAG -#include -#else #include "OstTraceDefinitions.h" -#endif #ifdef OST_TRACE_COMPILER_IN_USE #include "wlanqtutils_pTraces.h" #endif +/*! + \class WlanQtUtilsPrivate + \brief Private implementation class for WLAN Qt Utilities. -WlanQtUtilsPrivate::WlanQtUtilsPrivate(WlanQtUtils *publicPtr) : - q_ptr(publicPtr), - wlanScanList_(), - wlanIapList_(), - toBeTestedIapId_(WlanQtUtilsInvalidIapId), - connectingIapId_(WlanQtUtilsInvalidIapId), - activeConnection_(NULL) + The private interface functions are identical to those in WlanQtUtils + class, so refer to that for descriptions. Other functions contain + implementation documentation. +*/ + + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +/*! + Constructor. +*/ + +WlanQtUtilsPrivate::WlanQtUtilsPrivate(WlanQtUtils *q_ptr) : + q_ptr(q_ptr), + mSettings(new WlanQtUtilsIapSettings(this)), + mConMonWrapper(new WlanQtUtilsConMonWrapper(this)), + mEsockWrapper(new WlanQtUtilsEsockWrapper(this)), + mConnTestWrapper(new ConnTestWrapper(this)), + mWlanScanList(), + mToBeTestedIapId(WlanQtUtils::IapIdNone), + mConnectingIapId(WlanQtUtils::IapIdNone), + mConnection() { - OstTraceFunctionEntry1( WLANQTUTILSPRIVATE_WLANQTUTILSPRIVATE_ENTRY, this ); - - // Let's allocate memory for wrapper objects. - // Engine is set as a parent for wrapper objects. - cmmWrapper_ = new CmmWrapper(this); - conMonWrapper_ = new ConMonWrapper(this); - esockWrapper_ = new EsockWrapper(this); - connTestWrapper_ = new ConnTestWrapper(this); - + OstTraceFunctionEntry1(WLANQTUTILSPRIVATE_WLANQTUTILSPRIVATE_ENTRY, this); + // Make all connections. - // Todo: having these as signals from the wrappers doesn't bring much benefit - // -> could be optimized as normal callbacks - connect( - conMonWrapper_, - SIGNAL(availableWlanApsFromWrapper(QList&)), - this, - SLOT(updateAvailableWlanAps(QList&))); + bool connectStatus = connect( + mConMonWrapper, + SIGNAL(availableWlanApsFromWrapper( + QList< QSharedPointer >&)), + this, + SLOT(updateAvailableWlanAps( + QList< QSharedPointer >&))); + Q_ASSERT(connectStatus); - connect( - esockWrapper_, - SIGNAL(connectionStatusFromWrapper(bool)), + connectStatus = connect( + mEsockWrapper, + SIGNAL(connectionStatusFromWrapper(bool)), this, SLOT(updateConnectionStatus(bool))); + Q_ASSERT(connectStatus); - connect( - connTestWrapper_, - SIGNAL(connectivityTestResult(bool)), + connectStatus = connect( + mConnTestWrapper, + SIGNAL(connectivityTestResult(bool)), this, SLOT(updateConnectivityTestResult(bool))); + Q_ASSERT(connectStatus); - connect( - conMonWrapper_, - SIGNAL(connCreatedEventFromWrapper(uint)), + connectStatus = connect( + mConMonWrapper, + SIGNAL(connCreatedEventFromWrapper(uint)), this, SLOT(addActiveConnection(uint))); + Q_ASSERT(connectStatus); - connect( - conMonWrapper_, - SIGNAL(connDeletedEventFromWrapper(uint)), + connectStatus = connect( + mConMonWrapper, + SIGNAL(connDeletedEventFromWrapper(uint)), this, SLOT(removeActiveConnection(uint))); - - connect( - conMonWrapper_, - SIGNAL(connStatusEventFromWrapper(uint, WlanQtUtilsConnectionStatus)), - this, - SLOT(updateActiveConnection(uint, WlanQtUtilsConnectionStatus))); + Q_ASSERT(connectStatus); - // Fetch the initial IAP configuration - fetchIaps(); + connectStatus = connect( + mConMonWrapper, + SIGNAL(connStatusEventFromWrapper(uint, WlanQtUtils::ConnStatus)), + this, + SLOT(updateActiveConnection(uint, WlanQtUtils::ConnStatus))); + Q_ASSERT(connectStatus); - // Retrieve initial status of active connections and update IAPs, if needed. - activeConnection_ = conMonWrapper_->activeConnection(); - if (activeConnection_ != NULL) { - updateIapConnectionStatuses(activeConnection_->iapId(), activeConnection_->connectionStatus()); - } + // Retrieve initial status of active connections + mConnection = QSharedPointer( + mConMonWrapper->activeConnection()); - // TODO: error handling + OstTraceFunctionExit1(WLANQTUTILSPRIVATE_WLANQTUTILSPRIVATE_EXIT, this); +} - OstTraceFunctionExit1( WLANQTUTILSPRIVATE_WLANQTUTILSPRIVATE_EXIT, this ); -} +/*! + Destructor. +*/ WlanQtUtilsPrivate::~WlanQtUtilsPrivate() { - OstTraceFunctionEntry1( WLANQTUTILSPRIVATE_WLANQTUTILSPRIVATEDESTR_ENTRY, this ); - - // Delete WLAN scan list - for (int i = 0; i < wlanScanList_.count(); i++) { - delete wlanScanList_[i]; - } - wlanScanList_.clear(); + OstTraceFunctionEntry1(WLANQTUTILSPRIVATE_WLANQTUTILSPRIVATEDESTR_ENTRY, this); + OstTraceFunctionExit1(WLANQTUTILSPRIVATE_WLANQTUTILSPRIVATEDESTR_EXIT, this); +} + +/*! + See WlanQtUtils::scanWlans(). +*/ + +void WlanQtUtilsPrivate::scanWlans() +{ + OstTraceFunctionEntry1(WLANQTUTILSPRIVATE_SCANWLANS_ENTRY, this); + + // Just forward the request to wrapper, which triggers a single WLAN scan + mConMonWrapper->scanAvailableWlanAPs(); + + OstTraceFunctionExit1(WLANQTUTILSPRIVATE_SCANWLANS_EXIT, this); +} + +/*! + See WlanQtUtils::scanWlanAps(). +*/ + +void WlanQtUtilsPrivate::scanWlanAps() +{ + OstTraceFunctionEntry1(WLANQTUTILSPRIVATE_SCANWLANAPS_ENTRY, this); - delete activeConnection_; - - delete cmmWrapper_; - delete conMonWrapper_; - delete esockWrapper_; - delete connTestWrapper_; + emit q_ptr->wlanScanApReady(); + // TODO: implement me (wizard requires this) - OstTraceFunctionExit1( WLANQTUTILSPRIVATE_WLANQTUTILSPRIVATEDESTR_EXIT, this ); + OstTraceFunctionExit1(WLANQTUTILSPRIVATE_SCANWLANAPS_EXIT, this); } -void WlanQtUtilsPrivate::availableWlanAps( - QList &wlanIapList, - QList &wlanApList) +/*! + See WlanQtUtils::scanWlanDirect(). +*/ + +void WlanQtUtilsPrivate::scanWlanDirect(const QString &ssid) { - OstTraceFunctionEntry1( WLANQTUTILSPRIVATE_AVAILABLEWLANAPS_ENTRY, this ); + OstTraceFunctionEntry1(WLANQTUTILSPRIVATE_SCANWLANDIRECT_ENTRY, this); + + Q_UNUSED(ssid); + + emit q_ptr->wlanScanDirectReady(); + // TODO: implement me (wizard requires this) + OstTraceFunctionExit1(WLANQTUTILSPRIVATE_SCANWLANDIRECT_EXIT, this); +} + +/*! + See WlanQtUtils::stopWlanScan(). +*/ + +void WlanQtUtilsPrivate::stopWlanScan() +{ + OstTraceFunctionEntry1(WLANQTUTILSPRIVATE_STOPWLANSCAN_ENTRY, this); + + mConMonWrapper->stopScan(); + + OstTraceFunctionExit1(WLANQTUTILSPRIVATE_STOPWLANSCAN_EXIT, this); +} + +/*! + See WlanQtUtils::availableWlans(). +*/ + +void WlanQtUtilsPrivate::availableWlans( + QList< QSharedPointer > &wlanIapList, + QList< QSharedPointer > &wlanApList) const +{ + OstTraceFunctionEntry1(WLANQTUTILSPRIVATE_AVAILABLEWLAN_ENTRY, this); + wlanIapList.clear(); wlanApList.clear(); - - // Add possible connected or connecting IAP as the first item in the list - int activeIapId = WlanQtUtilsInvalidIapId; - if (activeConnection_ != NULL) { - activeIapId = activeConnection_->iapId(); - } else if (connectingIapId_ != WlanQtUtilsInvalidIapId) { - activeIapId = connectingIapId_; - } - if (wlanIapList_.contains(activeIapId)) { - wlanIapList_[activeIapId]->setSignalStrength(WlanQtUtilsWlanSignalStrengthMax); - wlanIapList_[activeIapId]->setConnectionStatus(WlanQtUtilsConnectionStatusConnected); - wlanIapList.append(wlanIapList_[activeIapId]); - } - - // Todo: IAPs with same SSID and security mode? probably we want to show only one of them? - + + // Read the list of configured IAPs + QList > configuredIapList; + mSettings->fetchIaps(configuredIapList); + // Match IAPs against WLAN scan results - foreach (WlanQtUtilsWlanIap *iap, wlanIapList_) { - foreach (WlanQtUtilsWlanAp *scanAp, wlanScanList_) { - // Todo: security mode check - if (iap->ssid() == scanAp->ssid()) { - // IAP found, add it to caller's list of known IAPs (signal strength needs to be - // updated manually since the IAP in our list does not have that information yet) - iap->setSignalStrength(scanAp->signalStrength()); - if (iap->id() != activeIapId) { - wlanIapList.append(iap); - } // else: connected IAP, added as the first item in the list already + foreach (QSharedPointer iap, configuredIapList) { + foreach (QSharedPointer scanAp, mWlanScanList) { + if (WlanQtUtilsAp::compare(iap.data(), scanAp.data()) == true) { + // IAP found, add it to caller's list of known IAPs + // (signal strength needs to be updated manually since + // the IAP in our list does not have that information yet) + iap->setValue( + WlanQtUtilsAp::ConfIdSignalStrength, + scanAp->value(WlanQtUtilsAp::ConfIdSignalStrength)); + wlanIapList.append(iap); break; } } } // Go through the scan results to find unknown APs - for (int i = 0; i < wlanScanList_.count(); i++) { - // Skip networks with empty SSID (hidden networks are handled by UI currently) - if (wlanScanList_[i]->ssid().isEmpty() == FALSE) { - // Check whether an IAP with these parameters exists in any SNAP (in which case this - // network should not be shown as available in this SNAP) - if (wlanIapExists(wlanScanList_[i]->ssid(), wlanScanList_[i]->securityMode()) == false) { - // No IAP found in any SNAP, copy the AP to caller's list of unknown APs - wlanApList.append(wlanScanList_[i]); - } + for (int i = 0; i < mWlanScanList.count(); i++) { + // Check whether an IAP with these parameters exists (in which + // case this network is already added as an IAP in the loop above) + if (!wlanIapExists(configuredIapList, mWlanScanList[i].data())) { + // No IAP found in, copy the AP to caller's list of + // unknown APs + wlanApList.append(mWlanScanList[i]); } } + + traceIapsAndAps(wlanIapList, wlanApList); + + OstTraceFunctionExit1(WLANQTUTILSPRIVATE_AVAILABLEWLAN_EXIT, this); +} + +/*! + See WlanQtUtils::availableWlanAps(). +*/ + +void WlanQtUtilsPrivate::availableWlanAps( + QList< QSharedPointer > &wlanApList) const +{ + OstTraceFunctionEntry1(WLANQTUTILSPRIVATE_AVAILABLEWLANAPS_ENTRY, this); - // Sort APs by their SSIDs. - QMap wlanApMap; - // Loop the AP list copying the keys (lower case SSID) and elements - // into the map. - for (int i = 0; i < wlanApList.count(); i++ ) { - wlanApMap.insertMulti(wlanApList[i]->ssid().toLower(), wlanApList[i]); - } - wlanApList = wlanApMap.values(); + Q_UNUSED(wlanApList); + // TODO: implement me (wizard requires this) + + OstTraceFunctionExit1(WLANQTUTILSPRIVATE_AVAILABLEWLANAPS_EXIT, this); +} + +/*! + See WlanQtUtils::createIap(). +*/ - OstTraceFunctionExit1( WLANQTUTILSPRIVATE_AVAILABLEWLANAPS_EXIT, this ); +int WlanQtUtilsPrivate::createIap(const WlanQtUtilsAp *wlanAp) +{ + OstTraceFunctionEntry1(WLANQTUTILSPRIVATE_CREATEIAP_ENTRY, this); + + // Create the new IAP and return its ID + int newIapId = mSettings->createIap(wlanAp); + + OstTrace1( + TRACE_BORDER, + WLANQTUTILSPRIVATE_CREATEIAP, + "WlanQtUtilsPrivate::createIap;New IAP ID=%d", + newIapId); + + OstTraceFunctionExit1(WLANQTUTILSPRIVATE_CREATEIAP_EXIT, this); + return newIapId; } -int WlanQtUtilsPrivate::createWlanIap(const WlanQtUtilsWlanAp *wlanAp) +/*! + See WlanQtUtils::updateIap(). +*/ + +bool WlanQtUtilsPrivate::updateIap(int iapId, const WlanQtUtilsAp *wlanAp) { - OstTraceFunctionEntry1( WLANQTUTILSPRIVATE_CREATEWLANIAP_ENTRY, this ); + OstTraceFunctionEntry1(WLANQTUTILSPRIVATE_UPDATEIAP_ENTRY, this); + + bool success = mSettings->updateIap(iapId, wlanAp); - // Create the new IAP. Store its ID, because we need to run ICT for it later - WlanQtUtilsWlanIap *newIap = cmmWrapper_->createWlanIap(wlanAp); - toBeTestedIapId_ = newIap->id(); - wlanIapList_.insert(newIap->id(), newIap); - - OstTrace1( - TRACE_API, - WLANQTUTILSPRIVATE_CREATEWLANIAP, - "WlanQtUtilsPrivate::createWlanIap;New IAP ID=%d", toBeTestedIapId_ ); - OstTraceFunctionExit1( WLANQTUTILSPRIVATE_CREATEWLANIAP_EXIT, this ); - return toBeTestedIapId_; + OstTraceFunctionExit1(WLANQTUTILSPRIVATE_UPDATEIAP_EXIT, this); + return success; +} + +/*! + See WlanQtUtils::deleteIap(). +*/ + +void WlanQtUtilsPrivate::deleteIap(int iapId) +{ + OstTraceFunctionEntry1(WLANQTUTILSPRIVATE_DELETEIAP_ENTRY, this); + + mSettings->deleteIap(iapId); + + OstTraceFunctionExit1(WLANQTUTILSPRIVATE_DELETEIAP_EXIT, this); } -void WlanQtUtilsPrivate::connectIap(int iapId) +/*! + See WlanQtUtils::connectIap(). +*/ + +void WlanQtUtilsPrivate::connectIap(int iapId, bool runIct) { - OstTraceFunctionEntry1( WLANQTUTILSPRIVATE_CONNECTIAP_ENTRY, this ); - OstTrace1( TRACE_API, WLANQTUTILSPRIVATE_CONNECTIAP, "WlanQtUtilsPrivate::connectIap;IAP ID=%d", iapId ); + OstTraceFunctionEntry1(WLANQTUTILSPRIVATE_CONNECTIAP_ENTRY, this); - Q_ASSERT(activeConnection_ == NULL); - connectingIapId_ = iapId; - esockWrapper_->connectIap(iapId); + OstTraceExt2( + TRACE_BORDER, + WLANQTUTILSPRIVATE_CONNECTIAP, + "WlanQtUtilsPrivate::connectIap;IAP ID=%d;runIct=%hhu", + iapId, + runIct); + + Q_ASSERT(iapId != WlanQtUtils::IapIdNone); - OstTraceFunctionExit1( WLANQTUTILSPRIVATE_CONNECTIAP_EXIT, this ); + if (runIct) { + // Mark this IAP for ICT testing after it has been opened + mToBeTestedIapId = iapId; + } + mConnectingIapId = iapId; + mEsockWrapper->connectIap(iapId); + + OstTraceFunctionExit1(WLANQTUTILSPRIVATE_CONNECTIAP_EXIT, this); } +/*! + See WlanQtUtils::disconnectIap(). +*/ + void WlanQtUtilsPrivate::disconnectIap(int iapId) { - OstTraceFunctionEntry1( WLANQTUTILSPRIVATE_DISCONNECTIAP_ENTRY, this ); - OstTrace1( TRACE_API, WLANQTUTILSPRIVATE_DISCONNECTIAP, "WlanQtUtilsPrivate::disconnectIap;IAP ID=%d", iapId ); - - Q_ASSERT(activeConnection_ != NULL); - Q_ASSERT(activeConnection_->iapId() == iapId); - Q_ASSERT(wlanIapList_.contains(iapId)); + OstTraceFunctionEntry1(WLANQTUTILSPRIVATE_DISCONNECTIAP_ENTRY, this); - // Todo: IAP may have been opened by someone else... how to know when to disconnect RConnection? - esockWrapper_->disconnectIap(); - - // In order to close connection even if there are other users for the IAP, close also via ConMon - conMonWrapper_->disconnectIap(iapId); - // Change status of the IAP to non-connected - wlanIapList_[iapId]->setConnectionStatus(WlanQtUtilsConnectionStatusDisconnected); + OstTrace1( + TRACE_BORDER, + WLANQTUTILSPRIVATE_DISCONNECTIAP, + "WlanQtUtilsPrivate::disconnectIap;IAP ID=%d", iapId ); - OstTraceFunctionExit1( WLANQTUTILSPRIVATE_DISCONNECTIAP_EXIT, this ); + if (iapId != WlanQtUtils::IapIdNone) { + // Close our RConnection handle, if needed. Wrapper ignores call, if + // no handle exists. + mEsockWrapper->disconnectIap(); + + // In order to close connection even if there are other users for the + // IAP, close also via ConMon + mConMonWrapper->disconnectIap(iapId); + } // else: just ignore call + + OstTraceFunctionExit1(WLANQTUTILSPRIVATE_DISCONNECTIAP_EXIT, this); } -WlanQtUtilsIap *WlanQtUtilsPrivate::iap(int iapId) const +/*! + See WlanQtUtils::connectionStatus(). +*/ + +WlanQtUtils::ConnStatus WlanQtUtilsPrivate::connectionStatus() const { - if (wlanIapList_.contains(iapId)) { - return wlanIapList_.value(iapId); + OstTraceFunctionEntry0(WLANQTUTILSPRIVATE_CONNECTIONSTATUS_ENTRY); + + WlanQtUtils::ConnStatus status = WlanQtUtils::ConnStatusDisconnected; + + if (mConnection) { + status = mConnection->connectionStatus(); } - // else: no match - return NULL; + OstTrace1( + TRACE_BORDER, + WLANQTUTILSPRIVATE_CONNECTIONSTATUS, + "WlanQtUtilsPrivate::connectionStatus;status=%{ConnStatus};", + (TUint)status); + + OstTraceFunctionExit0(WLANQTUTILSPRIVATE_CONNECTIONSTATUS_EXIT); + return status; } -bool WlanQtUtilsPrivate::masterWlan() const +/*! + See WlanQtUtils::activeIap(). +*/ + +int WlanQtUtilsPrivate::activeIap() const { - OstTraceFunctionEntry1( WLANQTUTILSPRIVATE_MASTERWLAN_ENTRY, this ); + OstTraceFunctionEntry0(WLANQTUTILSPRIVATE_ACTIVEIAP_ENTRY); + + int iapId = WlanQtUtils::IapIdNone; + + if (mConnection) { + iapId = mConnection->iapId(); + } + OstTrace1( + TRACE_BORDER, + WLANQTUTILSPRIVATE_ACTIVEIAP, + "WlanQtUtilsPrivate::activeIap;iapId=%d", + iapId); - // TODO: Add actual implementation, this is just temporary dummy for testing wlanentryplugin! + OstTraceFunctionExit0(WLANQTUTILSPRIVATE_ACTIVEIAP_EXIT); + return iapId; +} + +/*! + See WlanQtUtils::iapName(). +*/ - OstTraceFunctionExit1( WLANQTUTILSPRIVATE_MASTERWLAN_EXIT, this ); - return true; +QString WlanQtUtilsPrivate::iapName(int iapId) const +{ + OstTraceFunctionEntry1(WLANQTUTILSPRIVATE_IAPNAME_ENTRY, this); + + QString name; + // Read the IAP from settings and return its name + QSharedPointer iap = mSettings->fetchIap(iapId); + if (iap) { + name = iap->value(WlanQtUtilsIap::ConfIdName).toString(); + } + + OstTraceFunctionExit1(WLANQTUTILSPRIVATE_IAPNAME_EXIT, this); + return name; } -void WlanQtUtilsPrivate::setMasterWlan(bool enabled) -{ - OstTraceFunctionEntry1( WLANQTUTILSPRIVATE_SETMASTERWLAN_ENTRY, this ); +/*! + This function searches for a WLAN IAP matching the given WLAN AP. + + @param [in] list List to search from. + @param [in] ap Access point to search for. - // TODO: Add actual implementation. - (void)enabled; - - OstTraceFunctionExit1( WLANQTUTILSPRIVATE_SETMASTERWLAN_EXIT, this ); -} + @return True, if suitable WLAN IAP found, false otherwise. +*/ -int WlanQtUtilsPrivate::connectedWlanId() const +bool WlanQtUtilsPrivate::wlanIapExists( + const QList< QSharedPointer > list, + const WlanQtUtilsAp *ap) const { - OstTraceFunctionEntry1( WLANQTUTILSPRIVATE_CONNECTEDWLANID_ENTRY, this ); - - int retVal = WlanQtUtilsInvalidIapId; - if (activeConnection_ != NULL) { - retVal = activeConnection_->iapId(); + bool match = false; // Return value + + foreach (QSharedPointer iap, list) { + if (WlanQtUtilsAp::compare(iap.data(), ap) == true) { + // Match found + match = true; + break; + } } - OstTraceFunctionExit1( WLANQTUTILSPRIVATE_CONNECTEDWLANID_EXIT, this ); - return retVal; + + return match; } -void WlanQtUtilsPrivate::scanWlans() -{ - OstTraceFunctionEntry1( WLANQTUTILSPRIVATE_SCANWLANS_ENTRY, this ); +/*! + This function traces the given IAPs and APs. + + @param [in] iaps IAPs to trace. + @param [in] aps APs to trace. +*/ - // Just forward the request to wrapper, which triggers a single WLAN scan - conMonWrapper_->scanAvailableWlanAPs(); - - OstTraceFunctionExit1( WLANQTUTILSPRIVATE_SCANWLANS_EXIT, this ); +void WlanQtUtilsPrivate::traceIapsAndAps( + const QList > &iaps, + const QList > &aps) const +{ +#ifndef OST_TRACE_COMPILER_IN_USE + Q_UNUSED(iaps); + Q_UNUSED(aps); +#else + foreach (QSharedPointer iap, iaps) { + QString tmp(iap->value(WlanQtUtilsIap::ConfIdName).toString()); + TPtrC16 name(tmp.utf16(), tmp.length()); + OstTraceExt3( + TRACE_NORMAL, + WLANQTUTILSPRIVATE_TRACEAVAILABLEWLANAPS_IAP, + "WlanQtUtilsPrivate::traceAvailableWlanAps IAP;name=%S;iap->securityMode()=%d;iap->signalStrength()=%d", + name, + iap->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(), + iap->value(WlanQtUtilsAp::ConfIdSignalStrength).toInt()); + } + foreach (QSharedPointer ap, aps) { + QString tmp(ap->value(WlanQtUtilsAp::ConfIdSsid).toString()); + TPtrC16 ssid(tmp.utf16(), tmp.length()); + OstTraceExt3( + TRACE_NORMAL, + WLANQTUTILSPRIVATE_TRACEAVAILABLEWLANAPS_AP, + "WlanQtUtilsPrivate::traceAvailableWlanAps AP;ssid=%S;ap->securityMode()=%d;ap->signalStrength()=%d", + ssid, + ap->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(), + ap->value(WlanQtUtilsAp::ConfIdSignalStrength).toInt() ); + } +#endif } -void WlanQtUtilsPrivate::updateAvailableWlanAps(QList &availableWlanList) +/*! + Slot for handling WLAN scan result event from wrapper. Results are + stored in member variable (possible duplicates are removed). + + @param [in] availableWlanList WLAN networks found in scan. +*/ + +void WlanQtUtilsPrivate::updateAvailableWlanAps( + QList > &availableWlanList) { - OstTraceFunctionEntry1( WLANQTUTILSPRIVATE_UPDATEAVAILABLEWLANAPS_ENTRY, this ); - + OstTraceFunctionEntry1(WLANQTUTILSPRIVATE_UPDATEAVAILABLEWLANAPS_ENTRY, this); + // Old results are removed - wlanScanList_.clear(); - // Copy available WLAN's to engine's scan result list (duplicates are removed) + mWlanScanList.clear(); + // Copy available WLANs to scan result list (duplicates are removed) for (int i = 0; i < availableWlanList.count(); i++) { bool duplicate = false; - for (int j = 0; j < wlanScanList_.count(); j++) { - if (availableWlanList[i]->ssid() == wlanScanList_[j]->ssid() - && availableWlanList[i]->securityMode() == wlanScanList_[j]->securityMode()) { + for (int j = 0; j < mWlanScanList.count(); j++) { + if (WlanQtUtilsAp::compare( + availableWlanList[i].data(), + mWlanScanList[j].data()) == true) { duplicate = true; break; } } if (duplicate == false) { - wlanScanList_.append(availableWlanList[i]); + mWlanScanList.append(availableWlanList[i]); } - // Todo: else deallocate? } - // the information is forwarded to the UI + // The information is forwarded to the UI + OstTrace0( + TRACE_BORDER, + WLANQTUTILSPRIVATE_WLANSCANREADY, + "WlanQtUtilsPrivate::emit wlanScanReady"); emit q_ptr->wlanScanReady(); + + OstTraceFunctionExit1(WLANQTUTILSPRIVATE_UPDATEAVAILABLEWLANAPS_EXIT, this); +} - OstTraceFunctionExit1( WLANQTUTILSPRIVATE_UPDATEAVAILABLEWLANAPS_EXIT, this ); -} +/*! + Slot for handling connection setup status event from wrapper. + + @param [in] isOpened Was connection setup successful? +*/ void WlanQtUtilsPrivate::updateConnectionStatus(bool isOpened) { - OstTraceFunctionEntry1( WLANQTUTILSPRIVATE_UPDATECONNECTIONSTATUS_ENTRY, this ); - OstTrace1( - TRACE_API, - WLANQTUTILSPRIVATE_UPDATECONNECTIONSTATUS, - "WlanQtUtilsPrivate::updateConnectionStatus;isOpened=%d", isOpened ); - + OstTraceFunctionEntry1(WLANQTUTILSPRIVATE_UPDATECONNECTIONSTATUS_ENTRY, this); + if (isOpened == false) { - // Opening failed, update connection statuses, but don't inform UI about - // connection closing here. It is done always in removeActiveConnection(). - if (activeConnection_ != NULL) { - activeConnection_->setConnectionStatus(WlanQtUtilsConnectionStatusDisconnected); + // Opening failed, update connection status and inform UI + if (mConnection) { + mConnection->setConnectionStatus( + WlanQtUtils::ConnStatusDisconnected); } - updateIapConnectionStatuses(connectingIapId_, WlanQtUtilsConnectionStatusDisconnected); + + // Include the status code from connection wrapper + int status = mEsockWrapper->lastStatusCode(); + OstTraceExt2( + TRACE_BORDER, + WLANQTUTILSPRIVATE_WLANNETWORKCLOSED, + "WlanQtUtilsPrivate::emit wlanNetworkClosed;IAP ID=%d;status=%d", + mConnectingIapId, + status); + emit q_ptr->wlanNetworkClosed(mConnectingIapId, status); } else { - // Opening succeeded, update connection statuses and inform UI - if (activeConnection_ != NULL) { - activeConnection_->setConnectionStatus(WlanQtUtilsConnectionStatusConnected); + // Opening succeeded, update connection status and inform UI + if (mConnection) { + mConnection->setConnectionStatus( + WlanQtUtils::ConnStatusConnected); } - updateIapConnectionStatuses(connectingIapId_, WlanQtUtilsConnectionStatusConnected); - emit q_ptr->wlanNetworkOpened(connectingIapId_); + + OstTrace1( + TRACE_BORDER, + WLANQTUTILSPRIVATE_WLANNETWORKOPENED, + "WlanQtUtilsPrivate::emit wlanNetworkOpened;IAP ID=%d", + mConnectingIapId); + emit q_ptr->wlanNetworkOpened(mConnectingIapId); // Start ICT, if needed - if (connectingIapId_ == toBeTestedIapId_) { - WlanQtUtilsIap *iap = WlanQtUtilsPrivate::iap(toBeTestedIapId_); - connTestWrapper_->startConnectivityTest(toBeTestedIapId_, iap->networkId()); + if (mConnectingIapId == mToBeTestedIapId) { + QSharedPointer iap = + mSettings->fetchIap(mToBeTestedIapId); + mConnTestWrapper->startConnectivityTest( + mToBeTestedIapId, + iap->value(WlanQtUtilsIap::ConfIdNetworkId).toInt()); } } // IAP is no more in connecting state - connectingIapId_ = WlanQtUtilsInvalidIapId; + mConnectingIapId = WlanQtUtils::IapIdNone; + + OstTraceFunctionExit1(WLANQTUTILSPRIVATE_UPDATECONNECTIONSTATUS_EXIT, this); +} - OstTraceFunctionExit1( WLANQTUTILSPRIVATE_UPDATECONNECTIONSTATUS_EXIT, this ); -} +/*! + Slot for handling connectivity test result event from wrapper. Tested + IAP is stored to Internet SNAP, if test was successful. + + @param [in] result Was the test successful? +*/ void WlanQtUtilsPrivate::updateConnectivityTestResult(bool result) { - OstTraceFunctionEntry1( WLANQTUTILSPRIVATE_UPDATECONNECTIVITYTESTRESULT_ENTRY, this ); - OstTrace1( - TRACE_API, - WLANQTUTILSPRIVATE_UPDATECONNECTIVITYTESTRESULT, - "WlanQtUtilsPrivate::updateConnectivityTestResult;result=%d", result ); - + OstTraceFunctionEntry1(WLANQTUTILSPRIVATE_UPDATECONNECTIVITYTESTRESULT_ENTRY, this); + if (result == true) { // Move the tested IAP to Internet SNAP since the test passed - Q_ASSERT(toBeTestedIapId_ != WlanQtUtilsInvalidIapId); - cmmWrapper_->moveIapToInternetSnap(toBeTestedIapId_); + Q_ASSERT(mToBeTestedIapId != WlanQtUtils::IapIdNone); + mSettings->moveIapToInternetSnap(mToBeTestedIapId); } // else: do nothing, IAP remains to be uncategorized - else - { - // TODO: Remove this. This is needed now since the connectivity test fails - // and thus the IAP is not shown correctly. - cmmWrapper_->moveIapToInternetSnap(toBeTestedIapId_); + + // Inform UI + OstTraceExt2( + TRACE_NORMAL, + WLANQTUTILSPRIVATE_ICTRESULT, + "WlanQtUtilsPrivate::emit ictResult;result=%hhu;IAP ID=%d", + result, + mToBeTestedIapId); + + emit q_ptr->ictResult(mToBeTestedIapId, result); - } // This IAP is now tested - toBeTestedIapId_ = WlanQtUtilsInvalidIapId; + mToBeTestedIapId = WlanQtUtils::IapIdNone; + + OstTraceFunctionExit1(WLANQTUTILSPRIVATE_UPDATECONNECTIVITYTESTRESULT_EXIT, this); +} - OstTraceFunctionExit1( WLANQTUTILSPRIVATE_UPDATECONNECTIVITYTESTRESULT_EXIT, this ); -} +/*! + Slot for updating active connection status from wrapper. + + @param [in] connectionId ID of the new connection. +*/ void WlanQtUtilsPrivate::addActiveConnection(uint connectionId) { - OstTraceFunctionEntry1( WLANQTUTILSPRIVATE_ADDACTIVECONNECTION_ENTRY, this ); + OstTraceFunctionEntry1(WLANQTUTILSPRIVATE_ADDACTIVECONNECTION_ENTRY, this); OstTrace1( - TRACE_API, + TRACE_BORDER, WLANQTUTILSPRIVATE_ADDACTIVECONNECTION, - "WlanQtUtilsPrivate::addActiveConnection;connectionId=%u", connectionId ); + "WlanQtUtilsPrivate::addActiveConnection;connectionId=%u", + connectionId); - Q_ASSERT(activeConnection_ == NULL); - activeConnection_ = conMonWrapper_->connectionInfo(connectionId); - Q_ASSERT(wlanIapList_.contains(activeConnection_->iapId())); - updateIapConnectionStatuses(activeConnection_->iapId(), activeConnection_->connectionStatus()); + Q_ASSERT(mConnection == NULL); + mConnection = QSharedPointer( + mConMonWrapper->connectionInfo(connectionId)); - OstTraceFunctionExit1( WLANQTUTILSPRIVATE_ADDACTIVECONNECTION_EXIT, this ); + OstTraceFunctionExit1(WLANQTUTILSPRIVATE_ADDACTIVECONNECTION_EXIT, this); } +/*! + Slot for updating active connection status from wrapper. + + @param [in] connectionId ID of the deleted connection. +*/ + void WlanQtUtilsPrivate::removeActiveConnection(uint connectionId) { - OstTraceFunctionEntry1( WLANQTUTILSPRIVATE_REMOVEACTIVECONNECTION_ENTRY, this ); + OstTraceFunctionEntry1(WLANQTUTILSPRIVATE_REMOVEACTIVECONNECTION_ENTRY, this); OstTrace1( - TRACE_API, + TRACE_BORDER, WLANQTUTILSPRIVATE_REMOVEACTIVECONNECTION, - "WlanQtUtilsPrivate::removeActiveConnection;connectionId=%u", connectionId ); - - Q_ASSERT(activeConnection_ != NULL); - if (activeConnection_->connectionId() == connectionId) { - // Connection is closed, update connection statuses and inform UI. - // wlanNetworkClosed is sent from here (and only from here), because, in some cases, - // connection may be removed without any connection status updates. - int closedIapId = activeConnection_->iapId(); - updateIapConnectionStatuses(activeConnection_->iapId(), WlanQtUtilsConnectionStatusDisconnected); - delete activeConnection_; - activeConnection_ = NULL; - emit q_ptr->wlanNetworkClosed(closedIapId); + "WlanQtUtilsPrivate::removeActiveConnection;connectionId=%u", + connectionId); + + Q_ASSERT(mConnection); + if (mConnection->connectionId() == connectionId) { + int closedIapId = mConnection->iapId(); + mConnection.clear(); + + if (mConnectingIapId != closedIapId) { + // Connection is closed, inform UI. wlanNetworkClosed is sent + // from here instead of updateActiveConnection(closed), + // because, in some cases, connection may be removed without + // any connection status updates. + // Note: reason parameter is not accurate here, because it is + // only relevant for connections opened by this dll + // (updateConnectionStatus) + OstTraceExt2( + TRACE_BORDER, + DUP1_WLANQTUTILSPRIVATE_WLANNETWORKCLOSED, + "WlanQtUtilsPrivate::emit wlanNetworkClosed;IAP ID=%d;status=%d", + closedIapId, + KErrNone); + emit q_ptr->wlanNetworkClosed(closedIapId, KErrNone); + } + // else: connection creation started by thid dll, but creation failed + // -> wlanNetworkClosed is sent from updateConnectionStatus } - OstTraceFunctionExit1( WLANQTUTILSPRIVATE_REMOVEACTIVECONNECTION_EXIT, this ); -} - -void WlanQtUtilsPrivate::updateActiveConnection(uint connectionId, WlanQtUtilsConnectionStatus connectionStatus) -{ - OstTraceFunctionEntry1( WLANQTUTILSPRIVATE_UPDATEACTIVECONNECTION_ENTRY, this ); - OstTraceExt2( - TRACE_API, - WLANQTUTILSPRIVATE_UPDATEACTIVECONNECTION, - "WlanQtUtilsPrivate::updateActiveConnection;connectionId=%u;connectionStatus=%u", connectionId, connectionStatus ); - - Q_ASSERT(activeConnection_ != NULL); - if (activeConnection_->connectionId() == connectionId - && activeConnection_->connectionStatus() != connectionStatus) { - // Update connection statuses and inform UI, if necessary - activeConnection_->setConnectionStatus(connectionStatus); - updateIapConnectionStatuses(activeConnection_->iapId(), connectionStatus); - if (connectionStatus == WlanQtUtilsConnectionStatusConnected) { - emit q_ptr->wlanNetworkOpened(activeConnection_->iapId()); - } - // Do not inform UI about connection closing here. It is done always in - // removeActiveConnection(), because that may occur without any connection status updates. - } // else: connection status did not change - - OstTraceFunctionExit1( WLANQTUTILSPRIVATE_UPDATEACTIVECONNECTION_EXIT, this ); + OstTraceFunctionExit1(WLANQTUTILSPRIVATE_REMOVEACTIVECONNECTION_EXIT, this); } -int WlanQtUtilsPrivate::fetchIaps() +/*! + Slot for updating active connection status from wrapper. + + @param [in] connectionId ID of the updated connection. + @param [in] connectionStatus New status of the connection. +*/ + +void WlanQtUtilsPrivate::updateActiveConnection( + uint connectionId, + WlanQtUtils::ConnStatus connectionStatus) { - OstTraceFunctionEntry1( WLANQTUTILSPRIVATE_FETCHIAPS_ENTRY, this ); - - QList list; - int error = 0; - // Read the IAP list and store WLAN IAPs in our internal map data structure - error = cmmWrapper_->fetchIaps(list); - foreach (WlanQtUtilsIap *iap, list) { - if (iap->bearerType() == WlanQtUtilsBearerTypeWlan) { - // Notice that insertMulti not used, because IAP IDs should be unique - wlanIapList_.insert(iap->id(), qobject_cast(iap)); - } - } - - OstTraceFunctionExit1( WLANQTUTILSPRIVATE_FETCHIAPS_EXIT, this ); - return error; -} + OstTraceFunctionEntry1(WLANQTUTILSPRIVATE_UPDATEACTIVECONNECTION_ENTRY, this); + OstTraceExt2( + TRACE_BORDER, + WLANQTUTILSPRIVATE_UPDATEACTIVECONNECTION, + "WlanQtUtilsPrivate::updateActiveConnection;connectionId=%u;connectionStatus=%u", + connectionId, + (uint)connectionStatus); -bool WlanQtUtilsPrivate::wlanIapExists(QString ssid, WlanQtUtilsWlanSecMode secMode) -{ - foreach (WlanQtUtilsWlanIap *iap, wlanIapList_) { - // todo: secmode - (void)secMode; - if (iap->ssid() == ssid) { - return true; + Q_ASSERT(mConnection); + if (mConnection->connectionId() == connectionId + && mConnection->connectionStatus() != connectionStatus) { + // Update connection status and inform UI, if necessary + mConnection->setConnectionStatus(connectionStatus); + if (connectionStatus == WlanQtUtils::ConnStatusConnected) { + OstTrace1( + TRACE_BORDER, + DUP1_WLANQTUTILSPRIVATE_WLANNETWORKOPENED, + "WlanQtUtilsPrivate::emit wlanNetworkOpened;IAP ID=%d", + mConnection->iapId()); + emit q_ptr->wlanNetworkOpened(mConnection->iapId()); } - } - - return false; -} + // Do not inform UI about connection closing here. It is done in + // removeActiveConnection(), because that may occur without any + // connection status updates. + } // else: connection status did not change -void WlanQtUtilsPrivate::updateIapConnectionStatuses(int iapId, WlanQtUtilsConnectionStatus status) -{ - OstTraceFunctionEntry1( WLANQTUTILSPRIVATE_UPDATEIAPCONNECTIONSTATUSES_ENTRY, this ); - - const WlanQtUtilsWlanIap *referenceIap = qobject_cast(iap(iapId)); - foreach (WlanQtUtilsWlanIap *iap, wlanIapList_) { - // todo: security mode checking - if (iap->id() == referenceIap->id() || iap->ssid() == referenceIap->ssid()) { - iap->setConnectionStatus(status); - } - } - - OstTraceFunctionExit1( WLANQTUTILSPRIVATE_UPDATEIAPCONNECTIONSTATUSES_EXIT, this ); + OstTraceFunctionExit1(WLANQTUTILSPRIVATE_UPDATEACTIVECONNECTION_EXIT, this); } diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/base/src/wlanqtutilsactiveconn.cpp --- a/wlanutilities/wlanqtutilities/base/src/wlanqtutilsactiveconn.cpp Fri May 14 10:30:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* 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". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* This is a source file for WlanQtUtilsActiveConn class. -*/ - -#include "wlanqtutilsactiveconn.h" - -WlanQtUtilsActiveConn::WlanQtUtilsActiveConn() : - connectionId_(0), - iapId_(0), - connectionStatus_(WlanQtUtilsConnectionStatusNone), - bearerType_(WlanQtUtilsBearerTypeNone) -{ -} - -WlanQtUtilsActiveConn::~WlanQtUtilsActiveConn() -{ -} - -uint WlanQtUtilsActiveConn::connectionId() const -{ - return connectionId_; -} - -void WlanQtUtilsActiveConn::setConnectionId(uint connectionId) -{ - connectionId_ = connectionId; -} - -uint WlanQtUtilsActiveConn::iapId() const -{ - return iapId_; -} - -void WlanQtUtilsActiveConn::setIapId(uint iapId) -{ - iapId_ = iapId; -} - -WlanQtUtilsConnectionStatus WlanQtUtilsActiveConn::connectionStatus() const -{ - return connectionStatus_; -} - -void WlanQtUtilsActiveConn::setConnectionStatus(WlanQtUtilsConnectionStatus connectionStatus) -{ - connectionStatus_ = connectionStatus; -} - -WlanQtUtilsBearerType WlanQtUtilsActiveConn::bearerType() const -{ - return bearerType_; -} - -void WlanQtUtilsActiveConn::setBearerType(WlanQtUtilsBearerType bearerType) -{ - bearerType_ = bearerType; -} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/base/src/wlanqtutilsap.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/base/src/wlanqtutilsap.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,175 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN AP (Access Point, unknown network) class. +*/ + +// System includes + +#include +#include +#include +#include + +// User includes + +#include "wlanqtutilsap.h" + +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wlanqtutilsapTraces.h" +#endif + +/*! + \class WlanQtUtilsApPrivate + \brief Private implementation of WlanQtUtilsAp. +*/ + +class WlanQtUtilsApPrivate +{ +private: + //! Access Point configuration data + QHash mConfigurations; + + friend class WlanQtUtilsAp; +}; + +/*! + \class WlanQtUtilsAp + \brief WLAN Access Point class. + + Contains the information related to unknown WLAN access points. +*/ + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +/*! + Constructor. +*/ + +WlanQtUtilsAp::WlanQtUtilsAp() : + d_ptr(new WlanQtUtilsApPrivate()) +{ +} + +/*! + Copy constructor. + + @param [in] ref AP to create a copy of. +*/ + +WlanQtUtilsAp::WlanQtUtilsAp(const WlanQtUtilsAp &ref) : + d_ptr(new WlanQtUtilsApPrivate()) +{ + d_ptr->mConfigurations = ref.d_ptr->mConfigurations; +} + +/*! + Destructor. +*/ + +WlanQtUtilsAp::~WlanQtUtilsAp() +{ +} + +/*! + Getter for AP data. + + @param [in] identifier Identifier of value to get. + + @return Value. +*/ + +QVariant WlanQtUtilsAp::value(int identifier) const +{ + Q_ASSERT(d_ptr->mConfigurations.contains(identifier)); + Q_ASSERT(d_ptr->mConfigurations[identifier].isValid()); + +#ifdef OST_TRACE_COMPILER_IN_USE + QString tmp; + QDebug tmpStream(&tmp); + tmpStream << d_ptr->mConfigurations[identifier]; + TPtrC16 string(tmp.utf16(), tmp.length()); + + OstTraceExt2( + TRACE_DUMP, + WLANQTUTILSAP_VALUE, + "WlanQtUtilsAp::value;identifier=%{ConfId};string=%S", + (TUint)identifier, + string); +#endif + + return d_ptr->mConfigurations[identifier]; +} + +/*! + Setter for AP data. + + @param [in] identifier Identifier of value to set. + @param [in] value Value to set. +*/ + +void WlanQtUtilsAp::setValue(int identifier, QVariant value) +{ +#ifdef OST_TRACE_COMPILER_IN_USE + QString tmp; + QDebug tmpStream(&tmp); + tmpStream << value; + TPtrC16 string(tmp.utf16(), tmp.length()); + + OstTraceExt2( + TRACE_DUMP, + WLANQTUTILSAP_SETVALUE, + "WlanQtUtilsAp::setValue;identifier=%{ConfId};string=%S", + (TUint)identifier, + string); +#endif + + d_ptr->mConfigurations[identifier] = value; +} + +/*! + AP comparison function. + + @param [in] ap1 First AP to compare. + @param [in] ap2 Second AP to compare. + + @return TRUE, if APs are considered to be same. +*/ + +bool WlanQtUtilsAp::compare( + const WlanQtUtilsAp *ap1, + const WlanQtUtilsAp *ap2) +{ + bool equal = false; + + // SSID (case sensitive) and security mode (with or without PSK) + // are the values, which identify a unique access point. + if (ap1->value(WlanQtUtilsAp::ConfIdSsid) == + ap2->value(WlanQtUtilsAp::ConfIdSsid) + && ap1->value(WlanQtUtilsAp::ConfIdSecurityMode) == + ap2->value(WlanQtUtilsAp::ConfIdSecurityMode) + && ap1->value(WlanQtUtilsAp::ConfIdWpaPskUse) == + ap2->value(WlanQtUtilsAp::ConfIdWpaPskUse)) { + equal = true; + } + + return equal; +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/base/src/wlanqtutilsconnection.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/base/src/wlanqtutilsconnection.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,121 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Qt Utilities WLAN connection status handler. +*/ + +// System includes + +// User includes + +#include "wlanqtutilsconnection.h" + +/*! + \class WlanQtUtilsConnection + \brief WLAN connection status handler for WLAN Qt Utilities. +*/ + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +/*! + Constructor. +*/ + +WlanQtUtilsConnection::WlanQtUtilsConnection() : + mConnectionId(0), + mIapId(0), + mConnectionStatus(WlanQtUtils::ConnStatusNone) +{ +} + +/*! + Destructor. +*/ + +WlanQtUtilsConnection::~WlanQtUtilsConnection() +{ +} + +/*! + Connection ID getter. + + @return Connection ID specific for Connection Monitor Server. +*/ + +uint WlanQtUtilsConnection::connectionId() const +{ + return mConnectionId; +} + +/*! + Connection ID setter. + + @param [in] connectionId Connection Monitor Server Connection ID. +*/ + +void WlanQtUtilsConnection::setConnectionId(uint connectionId) +{ + mConnectionId = connectionId; +} + +/*! + IAP ID getter. + + @return IAP ID. +*/ + +uint WlanQtUtilsConnection::iapId() const +{ + return mIapId; +} + +/*! + IAP ID setter. + + @param [in] iapId IAP ID. +*/ + +void WlanQtUtilsConnection::setIapId(uint iapId) +{ + mIapId = iapId; +} + +/*! + Connection status getter. + + @return Status of the connection. +*/ + +WlanQtUtils::ConnStatus WlanQtUtilsConnection::connectionStatus() const +{ + return mConnectionStatus; +} + +/*! + Connection status setter. + + @param [in] connectionStatus Status of the connection. +*/ + +void WlanQtUtilsConnection::setConnectionStatus( + WlanQtUtils::ConnStatus connectionStatus) +{ + mConnectionStatus = connectionStatus; +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/base/src/wlanqtutilsiap.cpp --- a/wlanutilities/wlanqtutilities/base/src/wlanqtutilsiap.cpp Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanqtutilities/base/src/wlanqtutilsiap.cpp Mon May 24 21:11:39 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -12,81 +12,60 @@ * Contributors: * * Description: -* +* WLAN IAP (Internet Access Point, known network) class. */ -#include +// System includes + +// User includes + #include "wlanqtutilsiap.h" -WlanQtUtilsIap::WlanQtUtilsIap() : - id_(0), - netId_(0), - name_(""), - bearerType_(WlanQtUtilsBearerTypeNone), - connectionStatus_(WlanQtUtilsConnectionStatusNone) +/*! + \class WlanQtUtilsIapPrivate + \brief Private implementation of WlanQtUtilsIap. + + This class is reserved for WlanQtUtilsIap private implementation. + + NOTE: Even though there is currently no implementation, this is + required for possible later additions to avoid binary compatibility + break. +*/ + +class WlanQtUtilsIapPrivate { + friend class WlanQtUtilsIap; +}; +/*! + \class WlanQtUtilsIap + \brief WLAN Internet Access Point class. + + Contains the information related to known WLAN access points. +*/ + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +/*! + Constructor. +*/ + +WlanQtUtilsIap::WlanQtUtilsIap() : + WlanQtUtilsAp(), + d_ptr(new WlanQtUtilsIapPrivate()) +{ } -WlanQtUtilsIap::WlanQtUtilsIap( - int id, - int netId, - QString name, - WlanQtUtilsBearerType bearerType) : - id_(id), netId_(netId), name_(name), bearerType_(bearerType), connectionStatus_(WlanQtUtilsConnectionStatusNone) -{ -} +/*! + Destructor. +*/ WlanQtUtilsIap::~WlanQtUtilsIap() { } - -int WlanQtUtilsIap::id() const -{ - return id_; -} - -int WlanQtUtilsIap::networkId() const -{ - return netId_; -} - -QString WlanQtUtilsIap::name() const -{ - return name_; -} - -WlanQtUtilsBearerType WlanQtUtilsIap::bearerType() const -{ - return bearerType_; -} - -WlanQtUtilsConnectionStatus WlanQtUtilsIap::connectionStatus() const -{ - return connectionStatus_; -} - -void WlanQtUtilsIap::setId(int id) -{ - id_ = id; -} - -void WlanQtUtilsIap::setNetworkId(int netId) -{ - netId_ = netId; -} - -void WlanQtUtilsIap::setName(QString name) -{ - name_ = name; -} - -void WlanQtUtilsIap::setBearerType(WlanQtUtilsBearerType bearerType) -{ - bearerType_ = bearerType; -} - -void WlanQtUtilsIap::setConnectionStatus(WlanQtUtilsConnectionStatus connectionStatus) -{ - connectionStatus_ = connectionStatus; -} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/base/src/wlanqtutilsiapsettings.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/base/src/wlanqtutilsiapsettings.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,477 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Qt Utilities WLAN IAP settings handling. +*/ + +// System includes + +#include +#include +#include + +#include +#include +#include + +// User includes + +#include "wlanqtutils.h" +#include "wlanqtutilsap.h" +#include "wlanqtutilsiap.h" +#include "wlanqtutilsiapsettings.h" + +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wlanqtutilsiapsettingsTraces.h" +#endif + +/*! + \class WlanQtUtilsIapSettings + \brief WLAN IAP related settings handler. + + Provides functionality to manipulate WLAN IAPs via the CM Manager Shim + interface. + + NOTE: Shim functions may throw exceptions that need to be catched in + this class. +*/ + +// External function prototypes + +// Local constants + +// WEP key lengths used to determine key format +static const int WepHex64BitMaxLength = 10; +static const int WepHex128BitMaxLength = 26; +static const int WepAscii64BitMaxLength = 5; +static const int WepAscii128BitMaxLength = 13; + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +/*! + Constructor. + + @param [in] parent Parent object. +*/ + +WlanQtUtilsIapSettings::WlanQtUtilsIapSettings(QObject *parent) : + QObject(parent), + mCmManager(new CmManagerShim()) +{ + OstTraceFunctionEntry0(WLANQTUTILSIAPSETTINGS_WLANQTUTILSIAPSETTINGS_ENTRY); + OstTraceFunctionExit0(WLANQTUTILSIAPSETTINGS_WLANQTUTILSIAPSETTINGS_EXIT); +} + +/*! + Destructor. +*/ + +WlanQtUtilsIapSettings::~WlanQtUtilsIapSettings() +{ + OstTraceFunctionEntry0(DUP1_WLANQTUTILSIAPSETTINGS_WLANQTUTILSIAPSETTINGS_ENTRY); + + delete mCmManager; + + OstTraceFunctionExit0(DUP1_WLANQTUTILSIAPSETTINGS_WLANQTUTILSIAPSETTINGS_EXIT); +} + +/*! + Fetch all WLAN IAPs. + + @param [out] iapList List of WLAN IAPs. +*/ + +void WlanQtUtilsIapSettings::fetchIaps( + QList< QSharedPointer > &iapList) const +{ + OstTraceFunctionEntry0(WLANQTUTILSIAPSETTINGS_FETCHIAPS_ENTRY); + + // Clear the list content first for safety + iapList.clear(); + + QList iapIds; + try { + mCmManager->connectionMethod(iapIds, false); + } catch (const std::exception &ex) { + int error = qt_symbian_exception2Error(ex); + OstTrace1( + TRACE_NORMAL, + WLANQTUTILSIAPSETTINGS_FETCHIAPS_EXCEPTION, + "WlanQtUtilsIapSettings::fetchIaps exception;error=%d", + error); + } + + foreach (int iapId, iapIds) { + QSharedPointer wlanIap = fetchIap(iapId); + if (wlanIap) { + iapList.append(wlanIap); + } + } + + OstTraceFunctionExit0(WLANQTUTILSIAPSETTINGS_FETCHIAPS_EXIT); +} + +/*! + Fetch WLAN IAP with the given ID + + @param [in] iapId ID of IAP to fetch. + + @return Found IAP, NULL if not found. +*/ + +QSharedPointer WlanQtUtilsIapSettings::fetchIap(int iapId) const +{ + OstTraceFunctionEntry0(WLANQTUTILSIAPSETTINGS_FETCHIAP_ENTRY); + + OstTrace1( + TRACE_NORMAL, + WLANQTUTILSIAPSETTINGS_FETCHIAP, + "WlanQtUtilsIapSettings::fetchIap;iapId=%d", + iapId); + + QSharedPointer wlanIap; + try { + QScopedPointer iap( + mCmManager->connectionMethod(iapId)); + if (iap && iap->getIntAttribute(CMManagerShim::CmBearerType) == + KUidWlanBearerType) { + + // Get WLAN IAP parameters + int netId = iap->getIntAttribute(CMManagerShim::CmNetworkId); + QString name = iap->getStringAttribute(CMManagerShim::CmName); + QString ssid = iap->getStringAttribute(CMManagerShim::WlanSSID); + int secMode = iap->getIntAttribute( + CMManagerShim::WlanSecurityMode); + bool wpaPskUse = iap->getBoolAttribute( + CMManagerShim::WlanEnableWpaPsk); + + // Create a WLAN Qt Utils IAP + wlanIap = QSharedPointer(new WlanQtUtilsIap()); + wlanIap->setValue(WlanQtUtilsIap::ConfIdIapId, iapId); + wlanIap->setValue(WlanQtUtilsIap::ConfIdNetworkId, netId); + wlanIap->setValue(WlanQtUtilsIap::ConfIdName, name); + wlanIap->setValue(WlanQtUtilsAp::ConfIdSsid, ssid); + wlanIap->setValue(WlanQtUtilsAp::ConfIdSecurityMode, secMode); + wlanIap->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, wpaPskUse); + } + } catch (const std::exception &ex) { + int error = qt_symbian_exception2Error(ex); + OstTrace1( + TRACE_NORMAL, + WLANQTUTILSIAPSETTINGS_FETCHIAP_EXCEPTION, + "WlanQtUtilsIapSettings::fetchIap exception;error=%d", + error); + } + + OstTraceFunctionExit0(WLANQTUTILSIAPSETTINGS_FETCHIAP_EXIT); + return wlanIap; +} + +/*! + Create a new WLAN IAP as an uncategorized IAP. + + @param [in] wlanAp Information about the WLAN AP. + + @return ID of the created IAP, IapIdNone in error cases. +*/ + +int WlanQtUtilsIapSettings::createIap(const WlanQtUtilsAp *wlanAp) +{ + OstTraceFunctionEntry0(WLANQTUTILSIAPSETTINGS_CREATEIAP_ENTRY); + + int iapId = WlanQtUtils::IapIdNone; + + try { + // Create the new IAP + QScopedPointer iap( + mCmManager->createConnectionMethod(KUidWlanBearerType)); + storeSettings(wlanAp, iap.data()); + iapId = iap->getIntAttribute(CMManagerShim::CmIapId); + } catch (const std::exception &ex) { + // Trace error cause and return failure (default value) to caller. + int error = qt_symbian_exception2Error(ex); + OstTrace1( + TRACE_NORMAL, + WLANQTUTILSIAPSETTINGS_CREATEIAP_EXCEPTION, + "WlanQtUtilsIapSettings::createIap exception;error=%d", + error); + } + + OstTraceFunctionExit0(WLANQTUTILSIAPSETTINGS_CREATEIAP_EXIT); + return iapId; +} + +/*! + Update the WLAN IAP given as parameter. All settings are stored to + database (again) without checking whether they have actually changed + or not. + + @param [in] iapId ID of IAP to update. + @param [in] wlanAp Information about the WLAN AP. + + @return Was update succesful or not? +*/ + +bool WlanQtUtilsIapSettings::updateIap( + int iapId, + const WlanQtUtilsAp *wlanAp) +{ + OstTraceFunctionEntry0(WLANQTUTILSIAPSETTINGS_UPDATEIAP_ENTRY); + + bool success = false; + + try { + QScopedPointer iap( + mCmManager->connectionMethod(iapId)); + storeSettings(wlanAp, iap.data()); + success = true; + } catch (const std::exception &ex) { + // Trace error cause and return failure (default value) to caller. + int error = qt_symbian_exception2Error(ex); + OstTrace1( + TRACE_NORMAL, + WLANQTUTILSIAPSETTINGS_UPDATEIAP_EXCEPTION, + "WlanQtUtilsIapSettings::updateIap exception;error=%d", + error); + } + + OstTraceFunctionExit0(WLANQTUTILSIAPSETTINGS_UPDATEIAP_EXIT); + return success; +} + +/*! + Delete the WLAN IAP given as parameter. + + @param [in] iapId ID of IAP to delete. +*/ + +void WlanQtUtilsIapSettings::deleteIap(int iapId) +{ + OstTraceFunctionEntry0(WLANQTUTILSIAPSETTINGS_DELETEIAP_ENTRY); + + try { + QScopedPointer iap( + mCmManager->connectionMethod(iapId)); + iap->deleteConnectionMethod(); + } catch (const std::exception &ex) { + // Just trace error cause. It is not fatal, if we are not able to + // delete the IAP. No need to retry, since errors should be very + // rare and user can delete the IAP later from Control Panel, if + // needed. + int error = qt_symbian_exception2Error(ex); + OstTrace1( + TRACE_NORMAL, + WLANQTUTILSIAPSETTINGS_DELETEIAP_EXCEPTION, + "WlanQtUtilsIapSettings::deleteIap exception;error=%d", + error); + } + + OstTraceFunctionExit0(WLANQTUTILSIAPSETTINGS_DELETEIAP_EXIT); +} + +/*! + Move IAP to the Internet SNAP. + + @param [in] iapId ID of the IAP to move. +*/ + +void WlanQtUtilsIapSettings::moveIapToInternetSnap(int iapId) +{ + OstTraceFunctionEntry0(WLANQTUTILSIAPSETTINGS_MOVEIAPTOINTERNETSNAP_ENTRY); + + // Read all destination (SNAP) IDs + QList destinations; + try { + mCmManager->allDestinations(destinations); + foreach (int destId, destinations) { + QScopedPointer destination( + mCmManager->destination(destId)); + + // Internet destination will always exist in the system. It has + // SnapPurposeInternet set in its metadata. + if (destination->metadata(CMManagerShim::SnapMetadataPurpose) + == CMManagerShim::SnapPurposeInternet) { + QScopedPointer iap( + mCmManager->connectionMethod(iapId)); + destination->addConnectionMethod(iap.data()); + destination->update(); + break; + } + } + } catch (const std::exception &ex) { + int error = qt_symbian_exception2Error(ex); + OstTrace1( + TRACE_NORMAL, + WLANQTUTILSIAPSETTINGS_MOVEIAPTOINTERNETSNAP_EXCEPTION, + "WlanQtUtilsIapSettings::moveIapToInternetSnap exception;error=%d", + error); + } + + OstTraceFunctionExit0(WLANQTUTILSIAPSETTINGS_MOVEIAPTOINTERNETSNAP_EXIT); +} + +/*! + Stores the given Wlan AP settings to database using CM Manager Shim. + + @param [in] wlanAp WLAN AP settings to store. + @param [in] iap WLAN IAP to store to. +*/ + +void WlanQtUtilsIapSettings::storeSettings( + const WlanQtUtilsAp *wlanAp, + CmConnectionMethodShim *iap) +{ + OstTraceFunctionEntry0(WLANQTUTILSIAPSETTINGS_STORESETTINGS_ENTRY); + + int secMode = wlanAp->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(); + QString ssid = wlanAp->value(WlanQtUtilsAp::ConfIdSsid).toString(); + + // Store general values + iap->setStringAttribute(CMManagerShim::CmName, ssid); + iap->setStringAttribute(CMManagerShim::WlanSSID, ssid); + iap->setIntAttribute(CMManagerShim::WlanSecurityMode, secMode); + iap->setIntAttribute( + CMManagerShim::WlanConnectionMode, + wlanAp->value(WlanQtUtilsAp::ConfIdConnectionMode).toInt()); + + switch (secMode) { + case CMManagerShim::WlanSecModeWep: + // Store the 4 WEP keys (function does nothing, if a key is not set) + storeWepKey( + wlanAp->value(WlanQtUtilsAp::ConfIdWepKey1).toString(), + 1, + iap); + storeWepKey( + wlanAp->value(WlanQtUtilsAp::ConfIdWepKey2).toString(), + 2, + iap); + storeWepKey( + wlanAp->value(WlanQtUtilsAp::ConfIdWepKey3).toString(), + 3, + iap); + storeWepKey( + wlanAp->value(WlanQtUtilsAp::ConfIdWepKey4).toString(), + 4, + iap); + + iap->setIntAttribute( + CMManagerShim::WlanWepKeyIndex, + wlanAp->value(WlanQtUtilsAp::ConfIdWepDefaultIndex).toInt()); + break; + + case CMManagerShim::WlanSecModeWpa: + case CMManagerShim::WlanSecModeWpa2: + // Store WPA PSK values + bool usePsk = wlanAp->value(WlanQtUtilsAp::ConfIdWpaPskUse).toBool(); + iap->setBoolAttribute(CMManagerShim::WlanEnableWpaPsk, usePsk); + if (usePsk) { + QString wpaKey(wlanAp->value(WlanQtUtilsAp::ConfIdWpaPsk ).toString()); + iap->setString8Attribute(CMManagerShim::WlanWpaPreSharedKey, wpaKey); + } + break; + } + + iap->update(); + + OstTraceFunctionExit0(WLANQTUTILSIAPSETTINGS_STORESETTINGS_EXIT); +} + +/*! + Stores the given valid WEP key to database using CM Manager Shim. Ignores + keys with zero length. + + @note This method MUST not be called for invalid WEP Keys. Wlanwizard + validates keys, before accepting user input. + + @param [in] key Key to write. + @param [in] index Key index. Valid range is [0,4]. + @param [in] iap WLAN IAP to store the key into. +*/ + +void WlanQtUtilsIapSettings::storeWepKey( + const QString &key, + int index, + CmConnectionMethodShim *iap) +{ + OstTraceFunctionEntry0(WLANQTUTILSIAPSETTINGS_STOREWEPKEY_ENTRY); + + // Default value is set just to silence compiler, Q_ASSERTs take care + // that valid attribute is set below + CMManagerShim::ConnectionMethodAttribute attribute = + CMManagerShim::WlanWepKey1InHex; + + int length = key.length(); + if (length == WepHex64BitMaxLength || length == WepHex128BitMaxLength) { + // HEX + switch (index) { + case 1: + attribute = CMManagerShim::WlanWepKey1InHex; + break; + + case 2: + attribute = CMManagerShim::WlanWepKey2InHex; + break; + + case 3: + attribute = CMManagerShim::WlanWepKey3InHex; + break; + + case 4: + attribute = CMManagerShim::WlanWepKey4InHex; + break; + +#ifndef QT_NO_DEBUG + default: + // Invalid key index detected + Q_ASSERT(0); + break; +#endif + } + } else if (length == WepAscii64BitMaxLength || length == WepAscii128BitMaxLength) { + // ASCII + switch (index) { + case 1: + attribute = CMManagerShim::WlanWepKey1InAscii; + break; + + case 2: + attribute = CMManagerShim::WlanWepKey2InAscii; + break; + + case 3: + attribute = CMManagerShim::WlanWepKey3InAscii; + break; + + case 4: + attribute = CMManagerShim::WlanWepKey4InAscii; + break; + +#ifndef QT_NO_DEBUG + default: + // Invalid key index detected + Q_ASSERT(0); + break; +#endif + } + } + + if (length > 0) { + iap->setString8Attribute(attribute, key); + } // else: key is not set, ignore + + OstTraceFunctionExit0(WLANQTUTILSIAPSETTINGS_STOREWEPKEY_EXIT); +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/base/src/wlanqtutilswlanap.cpp --- a/wlanutilities/wlanqtutilities/base/src/wlanqtutilswlanap.cpp Fri May 14 10:30:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,109 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* 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". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* This is the source file for WlanQtUtilsWlanAp class. -*/ - -#include -#include "wlanqtutilscommon.h" -#include "wlanqtutilswlanap.h" - -WlanQtUtilsWlanAp::WlanQtUtilsWlanAp() : ssid_(""), bssid_(""), signalStrength_(0), connectionMode_(0), - securityMode_(WlanQtUtilsWlanSecModeOpen), securityKey_("") -{ -} - -WlanQtUtilsWlanAp::WlanQtUtilsWlanAp(const WlanQtUtilsWlanAp &ref) : - ssid_(ref.ssid()), - bssid_(ref.bssid()), - signalStrength_(ref.signalStrength()), - connectionMode_(ref.connectionMode()), - securityMode_(ref.securityMode()), - securityKey_(ref.securityKey()) -{ -} - -WlanQtUtilsWlanAp::WlanQtUtilsWlanAp( - QString ssid, - QString bssid, - int signalStrength, - int connectionMode, - WlanQtUtilsWlanSecMode securityMode) : ssid_(ssid), bssid_(bssid), signalStrength_(signalStrength), - connectionMode_(connectionMode), securityMode_(securityMode), securityKey_("") -{ -} - -WlanQtUtilsWlanAp::~WlanQtUtilsWlanAp() -{ -} - -QString WlanQtUtilsWlanAp::ssid() const -{ - return ssid_; -} - -QString WlanQtUtilsWlanAp::bssid() const -{ - return bssid_; -} - -int WlanQtUtilsWlanAp::signalStrength() const -{ - return signalStrength_; -} - -int WlanQtUtilsWlanAp::connectionMode() const -{ - return connectionMode_; -} - -WlanQtUtilsWlanSecMode WlanQtUtilsWlanAp::securityMode() const -{ - return securityMode_; -} - -QString WlanQtUtilsWlanAp::securityKey() const -{ - return securityKey_; -} - -void WlanQtUtilsWlanAp::setSsid(QString ssid) -{ - ssid_ = ssid; -} - -void WlanQtUtilsWlanAp::setBssid(QString bssid) -{ - bssid_ = bssid; -} - -void WlanQtUtilsWlanAp::setSignalStrength(int signalStrength) -{ - signalStrength_ = signalStrength; -} - -void WlanQtUtilsWlanAp::setConnectionMode(int connectionMode) -{ - connectionMode_ = connectionMode; -} - -void WlanQtUtilsWlanAp::setSecurityMode(WlanQtUtilsWlanSecMode securityMode) -{ - securityMode_ = securityMode; -} - -void WlanQtUtilsWlanAp::setSecurityKey(QString securityKey) -{ - securityKey_ = securityKey; -} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/base/src/wlanqtutilswlaniap.cpp --- a/wlanutilities/wlanqtutilities/base/src/wlanqtutilswlaniap.cpp Fri May 14 10:30:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* 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". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* This is a source file for WlanQtUtilsWlanIap class. -*/ - -#include -#include "wlanqtutilscommon.h" -#include "wlanqtutilsiap.h" -#include "wlanqtutilswlaniap.h" - -WlanQtUtilsWlanIap::WlanQtUtilsWlanIap() : WlanQtUtilsIap(), ssid_(""), signalStrength_(WlanQtUtilsWlanSignalUnavailable), securityMode_(WlanQtUtilsWlanSecModeOpen) -{ -} - -WlanQtUtilsWlanIap::WlanQtUtilsWlanIap(int id, int netId, QString name, WlanQtUtilsBearerType bearerType, QString ssid, WlanQtUtilsWlanSecMode secMode) : - WlanQtUtilsIap(id, netId, name, bearerType), ssid_(ssid), signalStrength_(WlanQtUtilsWlanSignalUnavailable), securityMode_(secMode) -{ -} - -WlanQtUtilsWlanIap::~WlanQtUtilsWlanIap() -{ -} - -/** Returns IAP's SSID */ -QString WlanQtUtilsWlanIap::ssid() const -{ - return ssid_; -} - -/** Returns IAP's signal strength */ -int WlanQtUtilsWlanIap::signalStrength() const -{ - return signalStrength_; -} - -/** Returns IAP's security mode */ -WlanQtUtilsWlanSecMode WlanQtUtilsWlanIap::securityMode() const -{ - return securityMode_; -} - -/** Sets IAP's SSID */ -void WlanQtUtilsWlanIap::setSsid(QString ssid) -{ - ssid_ = ssid; -} - -/** Sets IAP's signal strength */ -void WlanQtUtilsWlanIap::setSignalStrength(int signalStrength) -{ - signalStrength_ = signalStrength; -} - -/** Sets IAP's security mode */ -void WlanQtUtilsWlanIap::setSecurityMode(WlanQtUtilsWlanSecMode securityMode) -{ - securityMode_ = securityMode; -} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/bwins/wlanqtutilitiesu.def --- a/wlanutilities/wlanqtutilities/bwins/wlanqtutilitiesu.def Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanqtutilities/bwins/wlanqtutilitiesu.def Mon May 24 21:11:39 2010 +0300 @@ -1,80 +1,47 @@ EXPORTS - ?getStaticMetaObject@WlanQtUtilsWlanIap@@SAABUQMetaObject@@XZ @ 1 NONAME ; struct QMetaObject const & WlanQtUtilsWlanIap::getStaticMetaObject(void) - ?connectedWlanId@WlanQtUtils@@QBEHXZ @ 2 NONAME ; int WlanQtUtils::connectedWlanId(void) const - ?masterWlanStatus@WlanQtUtils@@IAEX_N@Z @ 3 NONAME ; void WlanQtUtils::masterWlanStatus(bool) - ?Start@RConnection@@QAEXAAVTConnPref@@AAVTRequestStatus@@@Z @ 4 NONAME ; void RConnection::Start(class TConnPref &, class TRequestStatus &) - ?connectionMode@WlanQtUtilsWlanAp@@QBEHXZ @ 5 NONAME ; int WlanQtUtilsWlanAp::connectionMode(void) const - ??1WlanQtUtilsIap@@UAE@XZ @ 6 NONAME ; WlanQtUtilsIap::~WlanQtUtilsIap(void) - ??0WlanQtUtilsWlanAp@@QAE@VQString@@0HHW4WlanQtUtilsWlanSecMode@@@Z @ 7 NONAME ; WlanQtUtilsWlanAp::WlanQtUtilsWlanAp(class QString, class QString, int, int, enum WlanQtUtilsWlanSecMode) - ?staticMetaObject@WlanQtUtilsWlanIap@@2UQMetaObject@@B @ 8 NONAME ; struct QMetaObject const WlanQtUtilsWlanIap::staticMetaObject - ?qt_metacall@WlanQtUtils@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 9 NONAME ; int WlanQtUtils::qt_metacall(enum QMetaObject::Call, int, void * *) - ?metaObject@WlanQtUtilsWlanIap@@UBEPBUQMetaObject@@XZ @ 10 NONAME ; struct QMetaObject const * WlanQtUtilsWlanIap::metaObject(void) const - ?tr@WlanQtUtilsWlanIap@@SA?AVQString@@PBD0H@Z @ 11 NONAME ; class QString WlanQtUtilsWlanIap::tr(char const *, char const *, int) - ?networkId@WlanQtUtilsIap@@QBEHXZ @ 12 NONAME ; int WlanQtUtilsIap::networkId(void) const - ?qt_metacall@WlanQtUtilsWlanIap@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 13 NONAME ; int WlanQtUtilsWlanIap::qt_metacall(enum QMetaObject::Call, int, void * *) + ?wlanScanDirectReady@WlanQtUtils@@IAEXXZ @ 1 NONAME ; void WlanQtUtils::wlanScanDirectReady(void) + ?iapName@WlanQtUtils@@QBE?AVQString@@H@Z @ 2 NONAME ; class QString WlanQtUtils::iapName(int) const + ??0WlanQtUtilsAp@@QAE@XZ @ 3 NONAME ; WlanQtUtilsAp::WlanQtUtilsAp(void) + ?updateIap@WlanQtUtils@@QAE_NHPBVWlanQtUtilsAp@@@Z @ 4 NONAME ; bool WlanQtUtils::updateIap(int, class WlanQtUtilsAp const *) + ?createIap@WlanQtUtils@@QAEHPBVWlanQtUtilsAp@@@Z @ 5 NONAME ; int WlanQtUtils::createIap(class WlanQtUtilsAp const *) + ?Start@RConnection@@QAEXAAVTConnPref@@AAVTRequestStatus@@@Z @ 6 NONAME ; void RConnection::Start(class TConnPref &, class TRequestStatus &) + ?value@WlanQtUtilsAp@@QBE?AVQVariant@@H@Z @ 7 NONAME ; class QVariant WlanQtUtilsAp::value(int) const + ??1WlanQtUtilsIap@@UAE@XZ @ 8 NONAME ; WlanQtUtilsIap::~WlanQtUtilsIap(void) + ?qt_metacast@WlanQtUtils@@UAEPAXPBD@Z @ 9 NONAME ; void * WlanQtUtils::qt_metacast(char const *) + ?qt_metacall@WlanQtUtils@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 10 NONAME ; int WlanQtUtils::qt_metacall(enum QMetaObject::Call, int, void * *) + ?availableWlanAps@WlanQtUtils@@QBEXAAV?$QList@V?$QSharedPointer@VWlanQtUtilsAp@@@@@@@Z @ 11 NONAME ; void WlanQtUtils::availableWlanAps(class QList > &) const + ??1WlanQtUtilsAp@@UAE@XZ @ 12 NONAME ; WlanQtUtilsAp::~WlanQtUtilsAp(void) + ?compare@WlanQtUtilsAp@@SA_NPBV1@0@Z @ 13 NONAME ; bool WlanQtUtilsAp::compare(class WlanQtUtilsAp const *, class WlanQtUtilsAp const *) ?staticMetaObject@WlanQtUtils@@2UQMetaObject@@B @ 14 NONAME ; struct QMetaObject const WlanQtUtils::staticMetaObject - ?disconnectIap@WlanQtUtils@@QAEXH@Z @ 15 NONAME ; void WlanQtUtils::disconnectIap(int) - ??0WlanQtUtilsIap@@QAE@HHVQString@@W4WlanQtUtilsBearerType@@@Z @ 16 NONAME ; WlanQtUtilsIap::WlanQtUtilsIap(int, int, class QString, enum WlanQtUtilsBearerType) - ?ssid@WlanQtUtilsWlanAp@@QBE?AVQString@@XZ @ 17 NONAME ; class QString WlanQtUtilsWlanAp::ssid(void) const - ??1WlanQtUtilsWlanAp@@UAE@XZ @ 18 NONAME ; WlanQtUtilsWlanAp::~WlanQtUtilsWlanAp(void) - ?bearerType@WlanQtUtilsIap@@QBE?AW4WlanQtUtilsBearerType@@XZ @ 19 NONAME ; enum WlanQtUtilsBearerType WlanQtUtilsIap::bearerType(void) const - ?GetPckgAttribute@RConnectionMonitor@@QBEXIIIAAVTDes16@@AAVTRequestStatus@@@Z @ 20 NONAME ; void RConnectionMonitor::GetPckgAttribute(unsigned int, unsigned int, unsigned int, class TDes16 &, class TRequestStatus &) const - ?signalStrength@WlanQtUtilsWlanIap@@QBEHXZ @ 21 NONAME ; int WlanQtUtilsWlanIap::signalStrength(void) const - ??_EWlanQtUtilsWlanIap@@UAE@I@Z @ 22 NONAME ; WlanQtUtilsWlanIap::~WlanQtUtilsWlanIap(unsigned int) - ?wlanNetworkOpened@WlanQtUtils@@IAEXH@Z @ 23 NONAME ; void WlanQtUtils::wlanNetworkOpened(int) - ?metaObject@WlanQtUtils@@UBEPBUQMetaObject@@XZ @ 24 NONAME ; struct QMetaObject const * WlanQtUtils::metaObject(void) const - ?setId@WlanQtUtilsIap@@QAEXH@Z @ 25 NONAME ; void WlanQtUtilsIap::setId(int) - ?setConnectionStatus@WlanQtUtilsIap@@QAEXW4WlanQtUtilsConnectionStatus@@@Z @ 26 NONAME ; void WlanQtUtilsIap::setConnectionStatus(enum WlanQtUtilsConnectionStatus) - ?createWlanIap@WlanQtUtils@@QAEHPBVWlanQtUtilsWlanAp@@@Z @ 27 NONAME ; int WlanQtUtils::createWlanIap(class WlanQtUtilsWlanAp const *) - ?setName@WlanQtUtilsIap@@QAEXVQString@@@Z @ 28 NONAME ; void WlanQtUtilsIap::setName(class QString) - ?setSsid@WlanQtUtilsWlanIap@@QAEXVQString@@@Z @ 29 NONAME ; void WlanQtUtilsWlanIap::setSsid(class QString) - ?setSecurityMode@WlanQtUtilsWlanIap@@QAEXW4WlanQtUtilsWlanSecMode@@@Z @ 30 NONAME ; void WlanQtUtilsWlanIap::setSecurityMode(enum WlanQtUtilsWlanSecMode) - ?tr@WlanQtUtils@@SA?AVQString@@PBD0H@Z @ 31 NONAME ; class QString WlanQtUtils::tr(char const *, char const *, int) - ?name@WlanQtUtilsIap@@QBE?AVQString@@XZ @ 32 NONAME ; class QString WlanQtUtilsIap::name(void) const - ?masterWlan@WlanQtUtils@@QBE_NXZ @ 33 NONAME ; bool WlanQtUtils::masterWlan(void) const - ?qt_metacast@WlanQtUtilsWlanIap@@UAEPAXPBD@Z @ 34 NONAME ; void * WlanQtUtilsWlanIap::qt_metacast(char const *) - ?securityKey@WlanQtUtilsWlanAp@@QBE?AVQString@@XZ @ 35 NONAME ; class QString WlanQtUtilsWlanAp::securityKey(void) const - ??0WlanQtUtilsIap@@QAE@XZ @ 36 NONAME ; WlanQtUtilsIap::WlanQtUtilsIap(void) - ?iap@WlanQtUtils@@QBEPAVWlanQtUtilsIap@@H@Z @ 37 NONAME ; class WlanQtUtilsIap * WlanQtUtils::iap(int) const - ??_EWlanQtUtilsWlanAp@@UAE@I@Z @ 38 NONAME ; WlanQtUtilsWlanAp::~WlanQtUtilsWlanAp(unsigned int) - ?tr@WlanQtUtilsWlanIap@@SA?AVQString@@PBD0@Z @ 39 NONAME ; class QString WlanQtUtilsWlanIap::tr(char const *, char const *) - ?setSecurityKey@WlanQtUtilsWlanAp@@QAEXVQString@@@Z @ 40 NONAME ; void WlanQtUtilsWlanAp::setSecurityKey(class QString) - ??0WlanQtUtilsWlanAp@@QAE@XZ @ 41 NONAME ; WlanQtUtilsWlanAp::WlanQtUtilsWlanAp(void) - ?qt_metacast@WlanQtUtils@@UAEPAXPBD@Z @ 42 NONAME ; void * WlanQtUtils::qt_metacast(char const *) - ?ssid@WlanQtUtilsWlanIap@@QBE?AVQString@@XZ @ 43 NONAME ; class QString WlanQtUtilsWlanIap::ssid(void) const - ?setNetworkId@WlanQtUtilsIap@@QAEXH@Z @ 44 NONAME ; void WlanQtUtilsIap::setNetworkId(int) - ?availableWlanAps@WlanQtUtils@@QAEXAAV?$QList@PAVWlanQtUtilsWlanIap@@@@AAV?$QList@PAVWlanQtUtilsWlanAp@@@@@Z @ 45 NONAME ; void WlanQtUtils::availableWlanAps(class QList &, class QList &) - ?trUtf8@WlanQtUtilsWlanIap@@SA?AVQString@@PBD0@Z @ 46 NONAME ; class QString WlanQtUtilsWlanIap::trUtf8(char const *, char const *) - ??0WlanQtUtilsWlanIap@@QAE@HHVQString@@W4WlanQtUtilsBearerType@@0W4WlanQtUtilsWlanSecMode@@@Z @ 47 NONAME ; WlanQtUtilsWlanIap::WlanQtUtilsWlanIap(int, int, class QString, enum WlanQtUtilsBearerType, class QString, enum WlanQtUtilsWlanSecMode) - ?tr@WlanQtUtils@@SA?AVQString@@PBD0@Z @ 48 NONAME ; class QString WlanQtUtils::tr(char const *, char const *) - ??0WlanQtUtilsWlanIap@@QAE@XZ @ 49 NONAME ; WlanQtUtilsWlanIap::WlanQtUtilsWlanIap(void) - ?setBssid@WlanQtUtilsWlanAp@@QAEXVQString@@@Z @ 50 NONAME ; void WlanQtUtilsWlanAp::setBssid(class QString) - ?setSsid@WlanQtUtilsWlanAp@@QAEXVQString@@@Z @ 51 NONAME ; void WlanQtUtilsWlanAp::setSsid(class QString) - ?signalStrength@WlanQtUtilsWlanAp@@QBEHXZ @ 52 NONAME ; int WlanQtUtilsWlanAp::signalStrength(void) const - ?setBearerType@WlanQtUtilsIap@@QAEXW4WlanQtUtilsBearerType@@@Z @ 53 NONAME ; void WlanQtUtilsIap::setBearerType(enum WlanQtUtilsBearerType) - ?setSignalStrength@WlanQtUtilsWlanAp@@QAEXH@Z @ 54 NONAME ; void WlanQtUtilsWlanAp::setSignalStrength(int) - ??1WlanQtUtils@@UAE@XZ @ 55 NONAME ; WlanQtUtils::~WlanQtUtils(void) - ?scanWlans@WlanQtUtils@@QAEXXZ @ 56 NONAME ; void WlanQtUtils::scanWlans(void) - ?setSignalStrength@WlanQtUtilsWlanIap@@QAEXH@Z @ 57 NONAME ; void WlanQtUtilsWlanIap::setSignalStrength(int) - ?EventType@CConnMonEventBase@@QBEHXZ @ 58 NONAME ; int CConnMonEventBase::EventType(void) const - ?setSecurityMode@WlanQtUtilsWlanAp@@QAEXW4WlanQtUtilsWlanSecMode@@@Z @ 59 NONAME ; void WlanQtUtilsWlanAp::setSecurityMode(enum WlanQtUtilsWlanSecMode) - ?trUtf8@WlanQtUtilsWlanIap@@SA?AVQString@@PBD0H@Z @ 60 NONAME ; class QString WlanQtUtilsWlanIap::trUtf8(char const *, char const *, int) - ?id@WlanQtUtilsIap@@QBEHXZ @ 61 NONAME ; int WlanQtUtilsIap::id(void) const - ??1WlanQtUtilsWlanIap@@UAE@XZ @ 62 NONAME ; WlanQtUtilsWlanIap::~WlanQtUtilsWlanIap(void) - ?securityMode@WlanQtUtilsWlanIap@@QBE?AW4WlanQtUtilsWlanSecMode@@XZ @ 63 NONAME ; enum WlanQtUtilsWlanSecMode WlanQtUtilsWlanIap::securityMode(void) const - ??_EWlanQtUtilsIap@@UAE@I@Z @ 64 NONAME ; WlanQtUtilsIap::~WlanQtUtilsIap(unsigned int) - ??_EWlanQtUtils@@UAE@I@Z @ 65 NONAME ; WlanQtUtils::~WlanQtUtils(unsigned int) - ?wlanScanReady@WlanQtUtils@@IAEXXZ @ 66 NONAME ; void WlanQtUtils::wlanScanReady(void) - ?wlanNetworkClosed@WlanQtUtils@@IAEXH@Z @ 67 NONAME ; void WlanQtUtils::wlanNetworkClosed(int) - ?bssid@WlanQtUtilsWlanAp@@QBE?AVQString@@XZ @ 68 NONAME ; class QString WlanQtUtilsWlanAp::bssid(void) const - ??0WlanQtUtilsWlanAp@@QAE@ABV0@@Z @ 69 NONAME ; WlanQtUtilsWlanAp::WlanQtUtilsWlanAp(class WlanQtUtilsWlanAp const &) - ??0WlanQtUtils@@QAE@XZ @ 70 NONAME ; WlanQtUtils::WlanQtUtils(void) - ?getStaticMetaObject@WlanQtUtils@@SAABUQMetaObject@@XZ @ 71 NONAME ; struct QMetaObject const & WlanQtUtils::getStaticMetaObject(void) - ?setConnectionMode@WlanQtUtilsWlanAp@@QAEXH@Z @ 72 NONAME ; void WlanQtUtilsWlanAp::setConnectionMode(int) - ?trUtf8@WlanQtUtils@@SA?AVQString@@PBD0@Z @ 73 NONAME ; class QString WlanQtUtils::trUtf8(char const *, char const *) - ?setMasterWlan@WlanQtUtils@@QAEX_N@Z @ 74 NONAME ; void WlanQtUtils::setMasterWlan(bool) - ?connectionStatus@WlanQtUtilsIap@@QBE?AW4WlanQtUtilsConnectionStatus@@XZ @ 75 NONAME ; enum WlanQtUtilsConnectionStatus WlanQtUtilsIap::connectionStatus(void) const - ?securityMode@WlanQtUtilsWlanAp@@QBE?AW4WlanQtUtilsWlanSecMode@@XZ @ 76 NONAME ; enum WlanQtUtilsWlanSecMode WlanQtUtilsWlanAp::securityMode(void) const - ?connectIap@WlanQtUtils@@QAEXH@Z @ 77 NONAME ; void WlanQtUtils::connectIap(int) - ?trUtf8@WlanQtUtils@@SA?AVQString@@PBD0H@Z @ 78 NONAME ; class QString WlanQtUtils::trUtf8(char const *, char const *, int) + ??0WlanQtUtilsAp@@QAE@ABV0@@Z @ 15 NONAME ; WlanQtUtilsAp::WlanQtUtilsAp(class WlanQtUtilsAp const &) + ??_EWlanQtUtilsAp@@UAE@I@Z @ 16 NONAME ; WlanQtUtilsAp::~WlanQtUtilsAp(unsigned int) + ?disconnectIap@WlanQtUtils@@QAEXH@Z @ 17 NONAME ; void WlanQtUtils::disconnectIap(int) + ?scanWlanDirect@WlanQtUtils@@QAEXABVQString@@@Z @ 18 NONAME ; void WlanQtUtils::scanWlanDirect(class QString const &) + ?tr@WlanQtUtils@@SA?AVQString@@PBD0@Z @ 19 NONAME ; class QString WlanQtUtils::tr(char const *, char const *) + ?wlanNetworkClosed@WlanQtUtils@@IAEXHH@Z @ 20 NONAME ; void WlanQtUtils::wlanNetworkClosed(int, int) + ?connectionStatus@WlanQtUtils@@QBE?AW4ConnStatus@1@XZ @ 21 NONAME ; enum WlanQtUtils::ConnStatus WlanQtUtils::connectionStatus(void) const + ?setValue@WlanQtUtilsAp@@QAEXHVQVariant@@@Z @ 22 NONAME ; void WlanQtUtilsAp::setValue(int, class QVariant) + ??1WlanQtUtils@@UAE@XZ @ 23 NONAME ; WlanQtUtils::~WlanQtUtils(void) + ?scanWlans@WlanQtUtils@@QAEXXZ @ 24 NONAME ; void WlanQtUtils::scanWlans(void) + ?EventType@CConnMonEventBase@@QBEHXZ @ 25 NONAME ; int CConnMonEventBase::EventType(void) const + ?activeIap@WlanQtUtils@@QBEHXZ @ 26 NONAME ; int WlanQtUtils::activeIap(void) const + ?GetPckgAttribute@RConnectionMonitor@@QBEXIIIAAVTDes16@@AAVTRequestStatus@@@Z @ 27 NONAME ; void RConnectionMonitor::GetPckgAttribute(unsigned int, unsigned int, unsigned int, class TDes16 &, class TRequestStatus &) const + ?scanWlanAps@WlanQtUtils@@QAEXXZ @ 28 NONAME ; void WlanQtUtils::scanWlanAps(void) + ?wlanNetworkOpened@WlanQtUtils@@IAEXH@Z @ 29 NONAME ; void WlanQtUtils::wlanNetworkOpened(int) + ?connectIap@WlanQtUtils@@QAEXH_N@Z @ 30 NONAME ; void WlanQtUtils::connectIap(int, bool) + ??_EWlanQtUtilsIap@@UAE@I@Z @ 31 NONAME ; WlanQtUtilsIap::~WlanQtUtilsIap(unsigned int) + ?metaObject@WlanQtUtils@@UBEPBUQMetaObject@@XZ @ 32 NONAME ; struct QMetaObject const * WlanQtUtils::metaObject(void) const + ??_EWlanQtUtils@@UAE@I@Z @ 33 NONAME ; WlanQtUtils::~WlanQtUtils(unsigned int) + ?wlanScanReady@WlanQtUtils@@IAEXXZ @ 34 NONAME ; void WlanQtUtils::wlanScanReady(void) + ??0WlanQtUtils@@QAE@XZ @ 35 NONAME ; WlanQtUtils::WlanQtUtils(void) + ?stopWlanScan@WlanQtUtils@@QAEXXZ @ 36 NONAME ; void WlanQtUtils::stopWlanScan(void) + ?availableWlans@WlanQtUtils@@QBEXAAV?$QList@V?$QSharedPointer@VWlanQtUtilsIap@@@@@@AAV?$QList@V?$QSharedPointer@VWlanQtUtilsAp@@@@@@@Z @ 37 NONAME ; void WlanQtUtils::availableWlans(class QList > &, class QList > &) const + ?tr@WlanQtUtils@@SA?AVQString@@PBD0H@Z @ 38 NONAME ; class QString WlanQtUtils::tr(char const *, char const *, int) + ?getStaticMetaObject@WlanQtUtils@@SAABUQMetaObject@@XZ @ 39 NONAME ; struct QMetaObject const & WlanQtUtils::getStaticMetaObject(void) + ?trUtf8@WlanQtUtils@@SA?AVQString@@PBD0@Z @ 40 NONAME ; class QString WlanQtUtils::trUtf8(char const *, char const *) + ?deleteIap@WlanQtUtils@@QAEXH@Z @ 41 NONAME ; void WlanQtUtils::deleteIap(int) + ?wlanScanApReady@WlanQtUtils@@IAEXXZ @ 42 NONAME ; void WlanQtUtils::wlanScanApReady(void) + ??0WlanQtUtilsIap@@QAE@XZ @ 43 NONAME ; WlanQtUtilsIap::WlanQtUtilsIap(void) + ?trUtf8@WlanQtUtils@@SA?AVQString@@PBD0H@Z @ 44 NONAME ; class QString WlanQtUtils::trUtf8(char const *, char const *, int) + ?ictResult@WlanQtUtils@@IAEXH_N@Z @ 45 NONAME ; void WlanQtUtils::ictResult(int, bool) diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/eabi/wlanqtutilitiesu.def --- a/wlanutilities/wlanqtutilities/eabi/wlanqtutilitiesu.def Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanqtutilities/eabi/wlanqtutilitiesu.def Mon May 24 21:11:39 2010 +0300 @@ -1,89 +1,53 @@ EXPORTS - _ZN11WlanQtUtils10connectIapEi @ 1 NONAME + _ZN11WlanQtUtils10connectIapEib @ 1 NONAME _ZN11WlanQtUtils11qt_metacallEN11QMetaObject4CallEiPPv @ 2 NONAME _ZN11WlanQtUtils11qt_metacastEPKc @ 3 NONAME - _ZN11WlanQtUtils13createWlanIapEPK17WlanQtUtilsWlanAp @ 4 NONAME - _ZN11WlanQtUtils13disconnectIapEi @ 5 NONAME - _ZN11WlanQtUtils13setMasterWlanEb @ 6 NONAME + _ZN11WlanQtUtils11scanWlanApsEv @ 4 NONAME + _ZN11WlanQtUtils12stopWlanScanEv @ 5 NONAME + _ZN11WlanQtUtils13disconnectIapEi @ 6 NONAME _ZN11WlanQtUtils13wlanScanReadyEv @ 7 NONAME - _ZN11WlanQtUtils16availableWlanApsER5QListIP18WlanQtUtilsWlanIapERS0_IP17WlanQtUtilsWlanApE @ 8 NONAME - _ZN11WlanQtUtils16masterWlanStatusEb @ 9 NONAME + _ZN11WlanQtUtils14scanWlanDirectERK7QString @ 8 NONAME + _ZN11WlanQtUtils15wlanScanApReadyEv @ 9 NONAME _ZN11WlanQtUtils16staticMetaObjectE @ 10 NONAME DATA 16 - _ZN11WlanQtUtils17wlanNetworkClosedEi @ 11 NONAME + _ZN11WlanQtUtils17wlanNetworkClosedEii @ 11 NONAME _ZN11WlanQtUtils17wlanNetworkOpenedEi @ 12 NONAME _ZN11WlanQtUtils19getStaticMetaObjectEv @ 13 NONAME - _ZN11WlanQtUtils9scanWlansEv @ 14 NONAME - _ZN11WlanQtUtilsC1Ev @ 15 NONAME - _ZN11WlanQtUtilsC2Ev @ 16 NONAME - _ZN11WlanQtUtilsD0Ev @ 17 NONAME - _ZN11WlanQtUtilsD1Ev @ 18 NONAME - _ZN11WlanQtUtilsD2Ev @ 19 NONAME - _ZN14WlanQtUtilsIap12setNetworkIdEi @ 20 NONAME - _ZN14WlanQtUtilsIap13setBearerTypeE21WlanQtUtilsBearerType @ 21 NONAME - _ZN14WlanQtUtilsIap19setConnectionStatusE27WlanQtUtilsConnectionStatus @ 22 NONAME - _ZN14WlanQtUtilsIap5setIdEi @ 23 NONAME - _ZN14WlanQtUtilsIap7setNameE7QString @ 24 NONAME - _ZN14WlanQtUtilsIapC1Eii7QString21WlanQtUtilsBearerType @ 25 NONAME - _ZN14WlanQtUtilsIapC1Ev @ 26 NONAME - _ZN14WlanQtUtilsIapC2Eii7QString21WlanQtUtilsBearerType @ 27 NONAME - _ZN14WlanQtUtilsIapC2Ev @ 28 NONAME - _ZN14WlanQtUtilsIapD0Ev @ 29 NONAME - _ZN14WlanQtUtilsIapD1Ev @ 30 NONAME - _ZN14WlanQtUtilsIapD2Ev @ 31 NONAME - _ZN17WlanQtUtilsWlanAp14setSecurityKeyE7QString @ 32 NONAME - _ZN17WlanQtUtilsWlanAp15setSecurityModeE22WlanQtUtilsWlanSecMode @ 33 NONAME - _ZN17WlanQtUtilsWlanAp17setConnectionModeEi @ 34 NONAME - _ZN17WlanQtUtilsWlanAp17setSignalStrengthEi @ 35 NONAME - _ZN17WlanQtUtilsWlanAp7setSsidE7QString @ 36 NONAME - _ZN17WlanQtUtilsWlanAp8setBssidE7QString @ 37 NONAME - _ZN17WlanQtUtilsWlanApC1E7QStringS0_ii22WlanQtUtilsWlanSecMode @ 38 NONAME - _ZN17WlanQtUtilsWlanApC1ERKS_ @ 39 NONAME - _ZN17WlanQtUtilsWlanApC1Ev @ 40 NONAME - _ZN17WlanQtUtilsWlanApC2E7QStringS0_ii22WlanQtUtilsWlanSecMode @ 41 NONAME - _ZN17WlanQtUtilsWlanApC2ERKS_ @ 42 NONAME - _ZN17WlanQtUtilsWlanApC2Ev @ 43 NONAME - _ZN17WlanQtUtilsWlanApD0Ev @ 44 NONAME - _ZN17WlanQtUtilsWlanApD1Ev @ 45 NONAME - _ZN17WlanQtUtilsWlanApD2Ev @ 46 NONAME - _ZN18WlanQtUtilsWlanIap11qt_metacallEN11QMetaObject4CallEiPPv @ 47 NONAME - _ZN18WlanQtUtilsWlanIap11qt_metacastEPKc @ 48 NONAME - _ZN18WlanQtUtilsWlanIap15setSecurityModeE22WlanQtUtilsWlanSecMode @ 49 NONAME - _ZN18WlanQtUtilsWlanIap16staticMetaObjectE @ 50 NONAME DATA 16 - _ZN18WlanQtUtilsWlanIap17setSignalStrengthEi @ 51 NONAME - _ZN18WlanQtUtilsWlanIap19getStaticMetaObjectEv @ 52 NONAME - _ZN18WlanQtUtilsWlanIap7setSsidE7QString @ 53 NONAME - _ZN18WlanQtUtilsWlanIapC1Eii7QString21WlanQtUtilsBearerTypeS0_22WlanQtUtilsWlanSecMode @ 54 NONAME - _ZN18WlanQtUtilsWlanIapC1Ev @ 55 NONAME - _ZN18WlanQtUtilsWlanIapC2Eii7QString21WlanQtUtilsBearerTypeS0_22WlanQtUtilsWlanSecMode @ 56 NONAME - _ZN18WlanQtUtilsWlanIapC2Ev @ 57 NONAME - _ZN18WlanQtUtilsWlanIapD0Ev @ 58 NONAME - _ZN18WlanQtUtilsWlanIapD1Ev @ 59 NONAME - _ZN18WlanQtUtilsWlanIapD2Ev @ 60 NONAME - _ZNK11WlanQtUtils10masterWlanEv @ 61 NONAME - _ZNK11WlanQtUtils10metaObjectEv @ 62 NONAME - _ZNK11WlanQtUtils15connectedWlanIdEv @ 63 NONAME - _ZNK11WlanQtUtils3iapEi @ 64 NONAME - _ZNK14WlanQtUtilsIap10bearerTypeEv @ 65 NONAME - _ZNK14WlanQtUtilsIap16connectionStatusEv @ 66 NONAME - _ZNK14WlanQtUtilsIap2idEv @ 67 NONAME - _ZNK14WlanQtUtilsIap4nameEv @ 68 NONAME - _ZNK14WlanQtUtilsIap9networkIdEv @ 69 NONAME - _ZNK17WlanQtUtilsWlanAp11securityKeyEv @ 70 NONAME - _ZNK17WlanQtUtilsWlanAp12securityModeEv @ 71 NONAME - _ZNK17WlanQtUtilsWlanAp14connectionModeEv @ 72 NONAME - _ZNK17WlanQtUtilsWlanAp14signalStrengthEv @ 73 NONAME - _ZNK17WlanQtUtilsWlanAp4ssidEv @ 74 NONAME - _ZNK17WlanQtUtilsWlanAp5bssidEv @ 75 NONAME - _ZNK18WlanQtUtilsWlanIap10metaObjectEv @ 76 NONAME - _ZNK18WlanQtUtilsWlanIap12securityModeEv @ 77 NONAME - _ZNK18WlanQtUtilsWlanIap14signalStrengthEv @ 78 NONAME - _ZNK18WlanQtUtilsWlanIap4ssidEv @ 79 NONAME - _ZTI11WlanQtUtils @ 80 NONAME - _ZTI14WlanQtUtilsIap @ 81 NONAME - _ZTI17WlanQtUtilsWlanAp @ 82 NONAME - _ZTI18WlanQtUtilsWlanIap @ 83 NONAME - _ZTV11WlanQtUtils @ 84 NONAME - _ZTV14WlanQtUtilsIap @ 85 NONAME - _ZTV17WlanQtUtilsWlanAp @ 86 NONAME - _ZTV18WlanQtUtilsWlanIap @ 87 NONAME + _ZN11WlanQtUtils19wlanScanDirectReadyEv @ 14 NONAME + _ZN11WlanQtUtils9createIapEPK13WlanQtUtilsAp @ 15 NONAME + _ZN11WlanQtUtils9deleteIapEi @ 16 NONAME + _ZN11WlanQtUtils9ictResultEib @ 17 NONAME + _ZN11WlanQtUtils9scanWlansEv @ 18 NONAME + _ZN11WlanQtUtils9updateIapEiPK13WlanQtUtilsAp @ 19 NONAME + _ZN11WlanQtUtilsC1Ev @ 20 NONAME + _ZN11WlanQtUtilsC2Ev @ 21 NONAME + _ZN11WlanQtUtilsD0Ev @ 22 NONAME + _ZN11WlanQtUtilsD1Ev @ 23 NONAME + _ZN11WlanQtUtilsD2Ev @ 24 NONAME + _ZN13WlanQtUtilsAp7compareEPKS_S1_ @ 25 NONAME + _ZN13WlanQtUtilsAp8setValueEi8QVariant @ 26 NONAME + _ZN13WlanQtUtilsApC1ERKS_ @ 27 NONAME + _ZN13WlanQtUtilsApC1Ev @ 28 NONAME + _ZN13WlanQtUtilsApC2ERKS_ @ 29 NONAME + _ZN13WlanQtUtilsApC2Ev @ 30 NONAME + _ZN13WlanQtUtilsApD0Ev @ 31 NONAME + _ZN13WlanQtUtilsApD1Ev @ 32 NONAME + _ZN13WlanQtUtilsApD2Ev @ 33 NONAME + _ZN14WlanQtUtilsIapC1Ev @ 34 NONAME + _ZN14WlanQtUtilsIapC2Ev @ 35 NONAME + _ZN14WlanQtUtilsIapD0Ev @ 36 NONAME + _ZN14WlanQtUtilsIapD1Ev @ 37 NONAME + _ZN14WlanQtUtilsIapD2Ev @ 38 NONAME + _ZNK11WlanQtUtils10metaObjectEv @ 39 NONAME + _ZNK11WlanQtUtils14availableWlansER5QListI14QSharedPointerI14WlanQtUtilsIapEERS0_IS1_I13WlanQtUtilsApEE @ 40 NONAME + _ZNK11WlanQtUtils16availableWlanApsER5QListI14QSharedPointerI13WlanQtUtilsApEE @ 41 NONAME + _ZNK11WlanQtUtils16connectionStatusEv @ 42 NONAME + _ZNK11WlanQtUtils7iapNameEi @ 43 NONAME + _ZNK11WlanQtUtils9activeIapEv @ 44 NONAME + _ZNK13WlanQtUtilsAp5valueEi @ 45 NONAME + _ZTI11WlanQtUtils @ 46 NONAME + _ZTI13WlanQtUtilsAp @ 47 NONAME + _ZTI14WlanQtUtilsIap @ 48 NONAME + _ZTV11WlanQtUtils @ 49 NONAME + _ZTV13WlanQtUtilsAp @ 50 NONAME + _ZTV14WlanQtUtilsIap @ 51 NONAME diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/rom/wlanqtutilities.iby --- a/wlanutilities/wlanqtutilities/rom/wlanqtutilities.iby Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanqtutilities/rom/wlanqtutilities.iby Mon May 24 21:11:39 2010 +0300 @@ -12,7 +12,7 @@ * Contributors: * * Description: -* +* WLAN Qt Utilities IBY file. */ #ifndef WLANQTUTILITIES_IBY diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/traces/OstTraceDefinitions.h --- a/wlanutilities/wlanqtutilities/traces/OstTraceDefinitions.h Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanqtutilities/traces/OstTraceDefinitions.h Mon May 24 21:11:39 2010 +0300 @@ -1,18 +1,19 @@ /* - * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * This component and the accompanying materials are made available - * 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". - * - * Initial Contributors: - * Nokia Corporation - initial contribution. - * - * Contributors: - * - * Description: - */ +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* OST trace definition header. +*/ #ifndef __OSTTRACEDEFINITIONS_H__ #define __OSTTRACEDEFINITIONS_H__ diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/traces/trace.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/traces/trace.properties Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,71 @@ + + + + ConfIdSsid + ConfIdSignalStrength + ConfIdConnectionMode + ConfIdSecurityMode + ConfIdWpaPskUse + ConfIdWpaPsk + ConfIdWepKey1 + ConfIdWepKey2 + ConfIdWepKey3 + ConfIdWepKey4 + ConfIdWepDefaultIndex + ConfIdHidden + ConfIdWpsSupported + + ConfIdIapId + ConfIdName + ConfIdNetworkId + + + ConnStatusNone + ConnStatusConnecting + ConnStatusConnected + ConnStatusDisconnected + + + + EConnMonCreateConnection + EConnMonDeleteConnection + EConnMonCreateSubConnection + EConnMonDeleteSubConnection + EConnMonDownlinkDataThreshold + EConnMonUplinkDataThreshold + EConnMonNetworkStatusChange + EConnMonConnectionStatusChange + EConnMonConnectionActivityChange + EConnMonNetworkRegistrationChange + EConnMonBearerChange + EConnMonSignalStrengthChange + EConnMonBearerAvailabilityChange + EConnMonIapAvailabilityChange + EConnMonTransmitPowerChange + EConnMonSNAPsAvailabilityChange + EConnMonNewWLANNetworkDetected + EConnMonOldWLANNetworkLost + EConnMonPacketDataAvailable + EConnMonPacketDataUnavailable + EConnMonBearerInfoChange + EConnMonBearerGroupChange + + + + KConnectionUninitialised + KStartingSelection + KFinishedSelection + KConnectionFailure + KDataTransferTemporarilyBlocked + KLinkLayerOpen + KLinkLayerClosed + KConfigDaemonLoading + KConfigDaemonLoaded + KConfigDaemonStartingRegistration + KConfigDaemonFinishedRegistration + KConfigDaemonStartingDeregistration + KConfigDaemonFinishedDeregistrationStop + KConfigDaemonUnloading + KConfigDaemonUnloaded + + diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/tsrc/context/wlanqtutilstestcontext.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/tsrc/context/wlanqtutilstestcontext.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,254 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* This is the source file for Connection Utilities test context. +*/ + +#include +#include +#include +#include +#include +#include + +#include "wlanqtutils.h" +#include "wlanqtutilstestcontext.h" +#include "wlanqtutilsap.h" +#include "wlanqtutilsconnection.h" + +// --------------------------------------------------------- +// class WlanQtUtilsCtxEsock +// --------------------------------------------------------- + +WlanQtUtilsCtxEsock::WlanQtUtilsCtxEsock() : + startRetValue_(KErrNone) +{ +} + +WlanQtUtilsCtxEsock::~WlanQtUtilsCtxEsock() +{ +} + +void WlanQtUtilsCtxEsock::initialize() +{ + startRetValue_ = KErrNone; +} + +// --------------------------------------------------------- +// class WlanQtUtilsCtxActiveConn +// --------------------------------------------------------- + +WlanQtUtilsCtxActiveConn::WlanQtUtilsCtxActiveConn() : + WlanQtUtilsConnection(), connMonBearerType_(EBearerUnknown), connMonConnectionStatus_( + KConnectionUninitialised), connMonWlanConnectionMode_(-1), connMonWlanSecurityMode_(-1), + applicationUids_() +{ +} + +WlanQtUtilsCtxActiveConn::~WlanQtUtilsCtxActiveConn() +{ +} + +// --------------------------------------------------------- +// class WlanQtUtilsCtxActiveConnections +// --------------------------------------------------------- + +WlanQtUtilsCtxActiveConnections::WlanQtUtilsCtxActiveConnections() : + activeConnList_() +{ +} + +WlanQtUtilsCtxActiveConnections::~WlanQtUtilsCtxActiveConnections() +{ + clearActiveConnList(); +} + +void WlanQtUtilsCtxActiveConnections::initialize() +{ + clearActiveConnList(); +} + +void WlanQtUtilsCtxActiveConnections::createDefaultActiveConnList(int numberOfActiveConns, + int firstIapId) +{ + clearActiveConnList(); + for (int i = 0; i < numberOfActiveConns; i++) { + WlanQtUtilsCtxActiveConn *activeConn = new WlanQtUtilsCtxActiveConn(); + + activeConn->setConnectionId((i + 1) * 100); + activeConn->setIapId(firstIapId + i); + activeConn->connMonConnectionStatus_ = KLinkLayerOpen; + activeConn->setConnectionStatus(WlanQtUtils::ConnStatusConnected); + + // WLAN connection. + activeConn->connMonBearerType_ = EBearerWLAN; + activeConn->connMonWlanSecurityMode_ = EConnMonSecurityOpen; + activeConn->connMonWlanConnectionMode_ = EConnMonInfraStructure; + activeConnList_.append(activeConn); + } +} + +void WlanQtUtilsCtxActiveConnections::clearActiveConnList() +{ + Q_FOREACH(WlanQtUtilsCtxActiveConn* activeConn, activeConnList_) + { + delete activeConn; + } + activeConnList_.clear(); +} + +void WlanQtUtilsCtxActiveConnections::verifyActiveConnList( + QList activeConnList) +{ + QCOMPARE(activeConnList.count(), activeConnList_.count()); + + for (int i = 0; i < activeConnList_.count(); i++) { + QCOMPARE(activeConnList[i]->connectionId(), activeConnList_[i]->connectionId()); + QCOMPARE(activeConnList[i]->iapId(), activeConnList_[i]->iapId()); + QCOMPARE(activeConnList[i]->connectionStatus(), activeConnList_[i]->connectionStatus()); + } +} + +WlanQtUtilsCtxActiveConn *WlanQtUtilsCtxActiveConnections::findActiveConn(uint connectionId) const +{ + WlanQtUtilsCtxActiveConn *activeConn = NULL; + for (int i = 0; i < activeConnList_.count(); i++) { + if (activeConnList_[i]->connectionId() == connectionId) { + activeConn = activeConnList_[i]; + } + } + Q_ASSERT(activeConn != NULL); + return activeConn; +} + +// --------------------------------------------------------- +// class WlanQtUtilsWlanScanResult +// --------------------------------------------------------- + +WlanQtUtilsWlanScanResult::WlanQtUtilsWlanScanResult() : + wlanScanResultList_(), + completeWlanScan_(true), + scanRetValue_(KErrNone) +{ +} + +WlanQtUtilsWlanScanResult::~WlanQtUtilsWlanScanResult() +{ + clearWlanScanResultList(); +} + +void WlanQtUtilsWlanScanResult::initialize() +{ + clearWlanScanResultList(); + completeWlanScan_ = true; + scanRetValue_ = KErrNone; +} + +void WlanQtUtilsWlanScanResult::createDefaultWlanScanResultList(int numberOfWlanAps) +{ + clearWlanScanResultList(); + for (int i = 0; i < numberOfWlanAps; i++) { + WlanQtUtilsAp *ap = new WlanQtUtilsAp(); + ap->setValue(WlanQtUtilsAp::ConfIdSsid, "TestWlanAp" + QString::number(i + 1)); + ap->setValue(WlanQtUtilsAp::ConfIdSignalStrength, 20); + ap->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra); + ap->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen); + ap->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false); + // TODO: Create constructor to WlanQtUtilsWlanAp which takes all member variables as parameter. + wlanScanResultList_.append(ap); + } +} + +void WlanQtUtilsWlanScanResult::clearWlanScanResultList() +{ + Q_FOREACH(WlanQtUtilsAp* ap, wlanScanResultList_) + { + delete ap; + } + wlanScanResultList_.clear(); +} + +void WlanQtUtilsWlanScanResult::verifyWlanScanResultList( + QList > wlanApList) +{ + QCOMPARE(wlanApList.count(), wlanScanResultList_.count()); + + for (int i = 0; i < wlanScanResultList_.count(); i++) { + QCOMPARE(wlanApList[i]->value(WlanQtUtilsAp::ConfIdSsid), + wlanScanResultList_[i]->value(WlanQtUtilsAp::ConfIdSsid)); + QCOMPARE(wlanApList[i]->value(WlanQtUtilsAp::ConfIdSignalStrength), + wlanScanResultList_[i]->value(WlanQtUtilsAp::ConfIdSignalStrength)); + QCOMPARE(wlanApList[i]->value(WlanQtUtilsAp::ConfIdConnectionMode), + wlanScanResultList_[i]->value(WlanQtUtilsAp::ConfIdConnectionMode)); + QCOMPARE(wlanApList[i]->value(WlanQtUtilsAp::ConfIdSecurityMode), + wlanScanResultList_[i]->value(WlanQtUtilsAp::ConfIdSecurityMode)); + QCOMPARE(wlanApList[i]->value(WlanQtUtilsAp::ConfIdWpaPskUse), + wlanScanResultList_[i]->value(WlanQtUtilsAp::ConfIdWpaPskUse)); + } +} + +// --------------------------------------------------------- +// class WlanQtUtilsCtxConnMon +// --------------------------------------------------------- + +WlanQtUtilsCtxConnMon::WlanQtUtilsCtxConnMon() : + wlanScanResult_() +{ +} + +WlanQtUtilsCtxConnMon::~WlanQtUtilsCtxConnMon() +{ +} + +void WlanQtUtilsCtxConnMon::initialize() +{ + wlanScanResult_.initialize(); + activeConnections_.initialize(); +} + +// --------------------------------------------------------- +// class WlanQtUtilsCtxIct +// --------------------------------------------------------- + +WlanQtUtilsCtxIct::WlanQtUtilsCtxIct() +{ +} + +WlanQtUtilsCtxIct::~WlanQtUtilsCtxIct() +{ +} + +void WlanQtUtilsCtxIct::initialize() +{ +} + +// --------------------------------------------------------- +// class WlanQtUtilsTestContext +// --------------------------------------------------------- + +WlanQtUtilsTestContext::WlanQtUtilsTestContext() : + esock_(), connMon_(), ict_() +{ +} + +WlanQtUtilsTestContext::~WlanQtUtilsTestContext() +{ +} + +void WlanQtUtilsTestContext::initialize() +{ + esock_.initialize(); + connMon_.initialize(); + ict_.initialize(); +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/tsrc/context/wlanqtutilstestcontext.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/tsrc/context/wlanqtutilstestcontext.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,258 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* This is the header file for Wlan Qt Utilities test context. +*/ + +#ifndef WLANQTUTILSTESTCONTEXT_H +#define WLANQTUTILSTESTCONTEXT_H + +#include +#include +#include "wlanqtutilsconnection.h" + +class WlanQtUtilsAp; + +/** + * This is context for esock library. + */ +class WlanQtUtilsCtxEsock : public QObject +{ + Q_OBJECT + +public: + WlanQtUtilsCtxEsock(); + ~WlanQtUtilsCtxEsock(); + + /** + * Initializes context. + */ + void initialize(); + + /** Return value of RConnection::Start(). */ + int startRetValue_; +}; + +/** + * This class is a helper class for testing purposes. It derives all properties of WlanQtUtilsConnection. + * In addition, this class contains member variables for setting some Connection Monitor specific + * values which cannot be easily generated from member variables of WlanQtUtilsConnection. + * E.g., connection status has different enum in Connection Monitor and Wlan Qt Utilities. This class + * enables setting both of those. Connmon version is set so that the stub can return it when + * requested, and Wlan Qt Utilities version is used for verifying that tested code returns right + * value. + */ +class WlanQtUtilsCtxActiveConn : public WlanQtUtilsConnection +{ +public: + WlanQtUtilsCtxActiveConn(); + ~WlanQtUtilsCtxActiveConn(); + + /** Bearer type in connmon format. */ + int connMonBearerType_; + /** Connection status in connmon format. */ + int connMonConnectionStatus_; + /** WLAN connection mode in connmon format. */ + int connMonWlanConnectionMode_; + /** WLAN security mode in connmon format. */ + int connMonWlanSecurityMode_; + /** Application UIDs that map to application strings. */ + QList applicationUids_; +}; + +/** + * This class represents active connections. + */ +class WlanQtUtilsCtxActiveConnections : public QObject +{ + Q_OBJECT + +public: + WlanQtUtilsCtxActiveConnections(); + ~WlanQtUtilsCtxActiveConnections(); + + /** + * Initializes context. + */ + void initialize(); + + /** + * Creates a list of active connections for scan results. + * + * @param[in] numberOfActiveConns Number of active connections that are created. + * @param[in] firstIapId IAP ID of the first connection to be created. + */ + void createDefaultActiveConnList(int numberOfActiveConns, int firstIapId); + + /** + * Verifies that the given active connection list returned by the real application matches + * with the one in the context. + * + * @param[in] activeConnList Active connections that are verified against the context. + */ + void verifyActiveConnList(QList activeConnList); + + /** + * Finds an active connection matching with the given connection ID from the context. + * Asserts if connection with given connection ID is not found. + * + * @param connectionId Connection ID. + * @return Active connection. + */ + WlanQtUtilsCtxActiveConn *findActiveConn(uint connectionId) const; + + /** + * List of active connections that RConnectionMonitor stub will return in response to + * RConnectionMonitor::Get*Attribute() functions. + */ + QList activeConnList_; + + // TODO: We need return values for all different RConnectionMonitor::Get*Attribute() functions + // to test error cases. + +private: + + /** + * Destroys and clears the list of WLAN APs. + */ + void clearActiveConnList(); +}; + +/** + * This class represents WLAN APs that represent the results of WLAN scanning triggered by + * RConnectionMonitor::GetPckgAttribute() + */ +class WlanQtUtilsWlanScanResult : public QObject +{ + Q_OBJECT + +public: + WlanQtUtilsWlanScanResult(); + ~WlanQtUtilsWlanScanResult(); + + /** + * Initializes context. + */ + void initialize(); + + /** + * Creates a list of WLAN APs for scan results. + * + * @param[in] numberOfWlanAps Number of WLAN APs that are created. + */ + void createDefaultWlanScanResultList(int numberOfWlanAps); + + /** + * Verifies that the given WLAN AP list returned by the real application matches + * with the one in the context. + * + * @param[in] wlanApList WLAN APs that are verified against the context. + */ + void verifyWlanScanResultList( + QList< QSharedPointer > wlanApList); // TODO: Maybe boolean return value + + /** + * List of WLAN access points that RConnectionMonitor stub will return in response to + * RConnectionMonitor::GetPckgAttribute(). + */ + QList wlanScanResultList_; + + /** + * Should scan be completed immediately or not? + */ + bool completeWlanScan_; + + /** Return value of RConnectionMonitor::GetPckgAttribute(). */ + int scanRetValue_; + +private: + + /** + * Destroys and clears the list of WLAN APs. + */ + void clearWlanScanResultList(); +}; + +/** + * Test context for RConnectionMonitor. + */ +class WlanQtUtilsCtxConnMon : public QObject +{ + Q_OBJECT + +public: + WlanQtUtilsCtxConnMon(); + ~WlanQtUtilsCtxConnMon(); + + /** + * Initializes context. + */ + void initialize(); + + /** Results of WLAN scanning. */ + WlanQtUtilsWlanScanResult wlanScanResult_; + + /** List of active connections. */ + WlanQtUtilsCtxActiveConnections activeConnections_; +}; + +/** + * Test context for Internet connectivity test library. + */ +class WlanQtUtilsCtxIct : public QObject +{ + Q_OBJECT + +public: + WlanQtUtilsCtxIct(); + ~WlanQtUtilsCtxIct(); + + /** + * Initializes context. + */ + void initialize(); +}; + +/** + * Test context. The purpose of this context is to provide values that are used in stubs + * and in verification of outputs in test cases. + * + * In stubs, context is used to verify the inputs of parameters and to set output + * parameters into a specific value. + * + * In test cases, context is used to verify that the output parameters match with the once + * set in the stub. + */ +class WlanQtUtilsTestContext : public QObject +{ + Q_OBJECT + +public: + WlanQtUtilsTestContext(); + ~WlanQtUtilsTestContext(); + + /** + * Initializes context. + */ + void initialize(); + + /** Context for esock library. */ + WlanQtUtilsCtxEsock esock_; + /** Context for connmon library. */ + WlanQtUtilsCtxConnMon connMon_; + /** Context for ICTS library. */ + WlanQtUtilsCtxIct ict_; +}; + +#endif // WLANQTUTILSTESTCONTEXT_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/tsrc/stubs/wlanqtutilsconnmonstub.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/tsrc/stubs/wlanqtutilsconnmonstub.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,704 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* This is a source file for connmon library stub functions +*/ + +#include +#include +#include +#include +#include +#include + +#include "wlanqtutilsap.h" + +#ifdef __WINS__ + +// TODO: This function is copied from ConnMonWLANNetworksArrayPckg_v2.cpp because this +// function, although being in rconnmon.h, is not in the interface because IMPORT_C/EXPORT_C +// declarations are not used for this particular constructor. The only change that was made to +// this version was to remove traces and some empty lines. This function is needed when +// creating output in RConnectionMonitor::GetPckgAttribute() for WLAN scan results. +// This is needed for both UT and emulator compilation. +CConnMonWlanNetworksPtrArrayPckg::CConnMonWlanNetworksPtrArrayPckg( + const RPointerArray& aRef, + TUint aBufLen ) + { + RPointerArray items; + TUint len( 0 ); + + for ( TUint i( 0 ); i < aRef.Count(); ++i ) + { + const HBufC* item( aRef[i]->ToBuf() ); + if ( item ) + { + // Is there room in buffer + TUint countFields( 3 ); // aRef.Count(); items->Count(); item->Length() + if ( (countFields + len + item->Length()) > aBufLen ) + { + delete item; + item = NULL; + break; + } + items.Append( item ); + ++( len += item->Length() ); // ++ is for item's size + } + else + { + ; // There was a trace. + } + } + // Check that given buflen (aBufLen) is not smaller than one + // item (TConnMonWLANNetwork) + aRef count + items count + // + item length + if ( items.Count() == 0 && aRef.Count() > 0 ) + { + aBufLen = 2; // aRef.Count(), items.Count() + } + + iBuf = HBufC::New( aBufLen ); // Set size exactly to a buffer length + if ( !iBuf ) + { + items.ResetAndDestroy(); + items.Close(); + return; + } + iBuf->Des().Append( aRef.Count() ); // Total amount of data + iBuf->Des().Append( items.Count() ); // Amount of transferring data + for ( TUint i(0); iDes().Append( items[i]->Length() ); + iBuf->Des().Append( *items[i] ); + } + items.ResetAndDestroy(); + items.Close(); + } + +// ----------------------------------------------------------------------------- +// CConnMonEventBase::CConnMonEventBase +// ----------------------------------------------------------------------------- +// +CConnMonEventBase::CConnMonEventBase( const TInt aEventType, const TUint aConnectionId ) + { + iEventType = aEventType; + iConnectionId = aConnectionId; + } + +// Destructor +CConnMonEventBase::~CConnMonEventBase() + { + } + +// ----------------------------------------------------------------------------- +// CConnMonEventBase::EventType +// ----------------------------------------------------------------------------- +// +TInt CConnMonEventBase::EventType() const + { + return iEventType; + } + +// ----------------------------------------------------------------------------- +// CConnMonConnectionStatusChange::CConnMonConnectionStatusChange +// ----------------------------------------------------------------------------- +// +CConnMonConnectionStatusChange::CConnMonConnectionStatusChange( + const TUint aConnectionId, + const TUint aSubConnectionId, + const TInt aConnectionStatus ) : + CConnMonEventBase(EConnMonConnectionStatusChange, aConnectionId) + { + iSubConnectionId = aSubConnectionId; + iConnectionStatus = aConnectionStatus; + } + +// Destructor +CConnMonConnectionStatusChange::~CConnMonConnectionStatusChange() + { + } + +#ifdef WLANQTUTILS_T_WLANQTUTILS_UT_FLAG + +// ---------------------------------------------- +// Stub functions for connmon library, used in UT +// ---------------------------------------------- + +#include "wlanqtutilstestcontext.h" + +extern WlanQtUtilsTestContext testContext; + +// Request status for canceling stubbed async request +TRequestStatus* iStubRequestStatus = 0; + +EXPORT_C void RConnectionMonitor::CancelAsyncRequest( + TInt aReqToCancel) +{ + (void)aReqToCancel; + User::RequestComplete(iStubRequestStatus, KErrCancel); + iStubRequestStatus = 0; +} + +EXPORT_C void RConnectionMonitor::GetConnectionCount( + TUint& aConnectionCount, + TRequestStatus& aStatus) +{ + aConnectionCount = testContext.connMon_.activeConnections_.activeConnList_.count(); + User::RequestComplete(&aStatus, KErrNone); +} + +EXPORT_C TInt RConnectionMonitor::GetConnectionInfo( + const TUint aIndex, + TUint& aConnectionId, + TUint& aSubConnectionCount ) const +{ + aConnectionId = testContext.connMon_.activeConnections_.activeConnList_[aIndex - 1]->connectionId(); + aSubConnectionCount = 0; + return KErrNone; // TODO: put return value into context. +} + +EXPORT_C void RConnectionMonitor::GetIntAttribute( + const TUint aConnectionId, + const TUint /* aSubConnectionId */, + const TUint aAttribute, + TInt& aValue, + TRequestStatus& aStatus ) +{ + WlanQtUtilsCtxActiveConn *activeConn = testContext.connMon_.activeConnections_.findActiveConn(aConnectionId); + if (aAttribute == KBearer) { + aValue = activeConn->connMonBearerType_; + } else if (aAttribute == KConnectionStatus) { + aValue = activeConn->connMonConnectionStatus_; + } else { + Q_ASSERT(false); + } + User::RequestComplete(&aStatus, KErrNone); // TODO: Take return value from the context. +} + +EXPORT_C void RConnectionMonitor::GetUintAttribute( + const TUint aConnectionId, + const TUint /* aSubConnectionId */, + const TUint aAttribute, + TUint& aValue, + TRequestStatus& aStatus ) +{ + WlanQtUtilsCtxActiveConn *activeConn = testContext.connMon_.activeConnections_.findActiveConn(aConnectionId); + if (aAttribute == KIAPId) { + aValue = activeConn->iapId(); + } else { + Q_ASSERT(false); + } + + User::RequestComplete(&aStatus, KErrNone); // TODO: Take return value from the context. +} + +EXPORT_C void RConnectionMonitor::GetPckgAttribute( + const TUint aConnectionId, + const TUint aSubConnectionId, + const TUint aAttribute, + TDes8& aValue, + TRequestStatus& aStatus ) const +{ + // This is copy-paste from real implementation and we'll use that for other requests. + TIpcArgs args(aConnectionId, aSubConnectionId, aAttribute, &aValue); + SendReceive(EReqGetPckgAttribute, args, aStatus); +} + +// --------------------------------------------------------- +// connUtils2ConnMonSecModeMap() +// Local function to map WlanQtUtilsWlanSecMode into Connection +// monitor's security mode. Currently for UT use only. +// --------------------------------------------------------- +// +static TUint connUtils2ConnMonSecModeMap(int connUtilsWlanSecMode, bool pskUse) +{ + TUint ret; + switch (connUtilsWlanSecMode) { + case CMManagerShim::WlanSecModeWep: + ret = EConnMonSecurityV2WepOpen; + break; + case CMManagerShim::WlanSecMode802_1x: + ret = EConnMonSecurityV2802d1x; + break; + case CMManagerShim::WlanSecModeWpa: + if (pskUse) { + ret = EConnMonSecurityV2WpaPsk; + } else { + ret = EConnMonSecurityV2Wpa; + } + break; + case CMManagerShim::WlanSecModeWpa2: + if (pskUse) { + ret = EConnMonSecurityV2Wpa2Psk; + } else { + ret = EConnMonSecurityV2Wpa2; + } + break; + case CMManagerShim::WlanSecModeWapi: + if (pskUse) { + ret = EConnMonSecurityV2WapiPsk; + } else { + ret = EConnMonSecurityV2Wapi; + } + break; + default: + ret = EConnMonSecurityV2Open; + break; + } + return ret; +} + + +// --------------------------------------------------------- +// connUtils2ConnMonConModeMap() +// --------------------------------------------------------- +// +static TUint connUtils2ConnMonConModeMap(int connUtilsWlanConMode) +{ + TUint ret; + switch (connUtilsWlanConMode) { + case CMManagerShim::Adhoc: + ret = EConnMonAdHoc; + break; + case CMManagerShim::Infra: + ret = EConnMonInfraStructure; + break; + } + return ret; +} + + +EXPORT_C void RConnectionMonitor::GetPckgAttribute( + const TUint /* aConnectionId */, + const TUint /* aSubConnectionId */, + const TUint /* aAttribute */, + TDes16& aValue, + TRequestStatus& aStatus ) const + { + // TODO: verify input parameters, i.e., first three params... + + RConnMonWlanNetworksPtrArray wlanPtrArray; + RBuf vendorData; + + for (int i = 0; i < testContext.connMon_.wlanScanResult_.wlanScanResultList_.count(); i++) { + WlanQtUtilsAp* ap = testContext.connMon_.wlanScanResult_.wlanScanResultList_[i]; + TBufC name(ap->value(WlanQtUtilsAp::ConfIdSsid).toString().utf16()); + + TBufC bssid16(QString("addMAC").utf16()); + TBuf8 bssid; + bssid.Copy(bssid16); + + CConnMonWlanNetwork* wlanAp = CConnMonWlanNetwork::NewL( + name, + connUtils2ConnMonConModeMap(ap->value(WlanQtUtilsAp::ConfIdConnectionMode).toInt()), + ap->value(WlanQtUtilsAp::ConfIdSignalStrength).toInt(), + 0, // old security mode not used anymore + connUtils2ConnMonSecModeMap( + ap->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(), + ap->value(WlanQtUtilsAp::ConfIdWpaPskUse).toBool()), + 0, + bssid, + vendorData ); + wlanPtrArray.Append(wlanAp); + } + + CConnMonWlanNetworksPtrArrayPckg wlanBuf(wlanPtrArray, 2560); + aValue.Copy(wlanBuf.Buf()->Des()); + + if (testContext.connMon_.wlanScanResult_.completeWlanScan_) { + User::RequestComplete(&aStatus, testContext.connMon_.wlanScanResult_.scanRetValue_); + } else { + iStubRequestStatus = &aStatus; + } + } + +#else // WLANQTUTILS_T_WLANQTUTILS_UT_FLAG + +// ---------------------------------------------------- +// Stub functions for connmon library, used in emulator +// ---------------------------------------------------- + +#if 0 +// In emulator, there are always two active connections. +// The following functions return different properties of these active connection +// so that it's easy to test in emulator. + +EXPORT_C void RConnectionMonitor::GetConnectionCount( + TUint& aConnectionCount, + TRequestStatus& aStatus) +{ + aConnectionCount = 2; + User::RequestComplete(&aStatus, KErrNone); +} + +EXPORT_C TInt RConnectionMonitor::GetConnectionInfo( + const TUint aIndex, + TUint& aConnectionId, + TUint& aSubConnectionCount ) const +{ + if (aIndex == 1) { + aConnectionId = 10; + } else if (aIndex == 2) { + aConnectionId = 20; + } else { + Q_ASSERT(false); + } + + aSubConnectionCount = 0; + return KErrNone; +} + +EXPORT_C void RConnectionMonitor::GetIntAttribute( + const TUint aConnectionId, + const TUint /* aSubConnectionId */, + const TUint aAttribute, + TInt& aValue, + TRequestStatus& aStatus ) +{ + if (aAttribute == KBearer) { + if (aConnectionId == 10) { + aValue = EBearerGPRS; + } else if (aConnectionId == 20) { + aValue = EBearerWLAN; + } else { + Q_ASSERT(false); + } + } else if (aAttribute == KConnectionStatus) { + if (aConnectionId == 10) { + aValue = KConnectionOpen; + } else if (aConnectionId == 20) { + aValue = KStartingConnection; + } else { + Q_ASSERT(false); + } + } else if (aAttribute == KSignalStrength) { + if (aConnectionId == 10) { + Q_ASSERT(false); + } else if (aConnectionId == 20) { + aValue = 78; + } else { + Q_ASSERT(false); + } + } else if (aAttribute == KNetworkMode) { + if (aConnectionId == 10) { + Q_ASSERT(false); + } else if (aConnectionId == 20) { + aValue = EConnMonInfraStructure; + } else { + Q_ASSERT(false); + } + } else if (aAttribute == KSecurityMode) { + if (aConnectionId == 10) { + Q_ASSERT(false); + } else if (aConnectionId == 20) { + aValue = EConnMonSecurityWpaPsk; + } else { + Q_ASSERT(false); + } + } else { + Q_ASSERT(false); + } + User::RequestComplete(&aStatus, KErrNone); +} + +EXPORT_C void RConnectionMonitor::GetUintAttribute( + const TUint aConnectionId, + const TUint /* aSubConnectionId */, + const TUint aAttribute, + TUint& aValue, + TRequestStatus& aStatus ) +{ + if (aAttribute == KIAPId) { + if (aConnectionId == 10) { + aValue = 1; + } else if (aConnectionId == 20) { + aValue = 10; + } else { + Q_ASSERT(false); + } + } else if (aAttribute == KDownlinkData) { + if (aConnectionId == 10) { + aValue = 123; + } else if (aConnectionId == 20) { + aValue = 12345; + } else { + Q_ASSERT(false); + } + } else if (aAttribute == KUplinkData) { + if (aConnectionId == 10) { + aValue = 987654321; + } else if (aConnectionId == 20) { + aValue = 1234567890; + } else { + Q_ASSERT(false); + } + } else if (aAttribute == KTransmitPower) { + if (aConnectionId == 10) { + Q_ASSERT(false); + } else if (aConnectionId == 20) { + aValue = 50; + } else { + Q_ASSERT(false); + } + } else { + Q_ASSERT(false); + } + + User::RequestComplete(&aStatus, KErrNone); +} + +EXPORT_C void RConnectionMonitor::GetBoolAttribute( + const TUint aConnectionId, + const TUint /* aSubConnectionId */, + const TUint aAttribute, + TBool& aValue, + TRequestStatus& aStatus ) +{ + if (aAttribute == KConnectionActive) { + if (aConnectionId == 10) { + aValue = EFalse; + } else if (aConnectionId == 20) { + aValue = ETrue; + } else { + Q_ASSERT(false); + } + } else { + Q_ASSERT(false); + } + + User::RequestComplete(&aStatus, KErrNone); +} + +EXPORT_C void RConnectionMonitor::GetStringAttribute( + const TUint aConnectionId, + const TUint /* aSubConnectionId */, + const TUint aAttribute, + TDes& aValue, + TRequestStatus& aStatus ) const +{ + if (aAttribute == KIAPName) { + if (aConnectionId == 10) { + _LIT(iapNameLit, "PACKET DATA 1"); + TBufC iapName(iapNameLit); + aValue = iapName.Des(); + } else if (aConnectionId == 20) { + _LIT(iapNameLit, "WLAN IAP 3"); + TBufC iapName(iapNameLit); + aValue = iapName.Des(); + } else { + Q_ASSERT(false); + } + } else if (aAttribute == KNetworkName) { + if (aConnectionId == 10) { + Q_ASSERT(false); + } else if (aConnectionId == 20) { + _LIT(ssidLit, "WLAN SSID 3"); + TBufC ssid(ssidLit); + aValue = ssid.Des(); + } else { + Q_ASSERT(false); + } + } else if (aAttribute == KAccessPointName) { + if (aConnectionId == 10) { + _LIT(iapNameLit, "PACKET DATA 1"); + TBufC iapName(iapNameLit); + aValue = iapName.Des(); + } else if (aConnectionId == 20) { + Q_ASSERT(false); + } else { + Q_ASSERT(false); + } + } else { + Q_ASSERT(false); + } + + User::RequestComplete(&aStatus, KErrNone); +} + +EXPORT_C void RConnectionMonitor::GetPckgAttribute( + const TUint aConnectionId, + const TUint aSubConnectionId, + const TUint aAttribute, + TDes8& aValue, + TRequestStatus& aStatus ) const +{ + if (aAttribute == KStartTime) { + if (aConnectionId == 10) { + TDateTime dateTime(2009, EMarch, 31-1, 15, 15, 15, 0); + TTime time(dateTime); + TConnMonTimeBuf timePckg(time); + aValue.Copy(timePckg); + } else if (aConnectionId == 20) { + TTime time; + time.UniversalTime(); + TConnMonTimeBuf timePckg(time); + aValue.Copy(timePckg); + } else { + Q_ASSERT(false); + } + User::RequestComplete(&aStatus, KErrNone); + } else if (aAttribute == KClientInfo) { + TConnMonClientEnum applications; + if (aConnectionId == 10) { + applications.iCount = 1; + applications.iUid[0].iUid = 0x10008D39; // Web + applications.iUid[1].iUid = 0; + applications.iUid[2].iUid = 0; + applications.iUid[3].iUid = 0; + applications.iUid[4].iUid = 0; + applications.iUid[5].iUid = 0; + applications.iUid[6].iUid = 0; + applications.iUid[7].iUid = 0; + applications.iUid[8].iUid = 0; + applications.iUid[9].iUid = 0; + } else if (aConnectionId == 20) { + applications.iCount = 7; + applications.iUid[0].iUid = 0x101fd9c5; // KBannedServerUID + applications.iUid[1].iUid = 0x1020728E; // KFeedsServerUid + applications.iUid[2].iUid = 0x10008D60; // KDownloadMgrServerUid + applications.iUid[3].iUid = 0x1000484b; // KMessagingServerUid + applications.iUid[4].iUid = 0x102033E6; // KJavaVMUid + applications.iUid[5].iUid = 0x102073CA; // KSUPLServerUid + applications.iUid[6].iUid = 0x200212F3; // Connect Screen + applications.iUid[7].iUid = 0; + applications.iUid[8].iUid = 0; + applications.iUid[9].iUid = 0; + } else { + Q_ASSERT(false); + } + TPckgBuf< TConnMonClientEnum > applicationsPckg( applications ); + aValue.Copy(applicationsPckg); + User::RequestComplete(&aStatus, KErrNone); + } else { + // This is copy-paste from real implementation and we'll use that for other requests. + TIpcArgs args( aConnectionId, aSubConnectionId, aAttribute, &aValue ); + SendReceive( EReqGetPckgAttribute, args, aStatus ); + } +} +#endif + +// This function returns WLAN scan results. +// Six results in every second scan and the others have two. +EXPORT_C void RConnectionMonitor::GetPckgAttribute( + const TUint /* aConnectionId */, + const TUint /* aSubConnectionId */, + const TUint aAttribute, + TDes16& aValue, + TRequestStatus& aStatus ) const { + + if (aAttribute == KWlanNetworks) { + RConnMonWlanNetworksPtrArray wlanPtrArray; + RBuf vendorData; + + TBufC bssid16(QString("addMAC").utf16()); + TBuf8 bssid; + bssid.Copy(bssid16); + + static bool refresh = true; + + _LIT(wlanAp1Name, "Test AP 1"); + TBufC name1(wlanAp1Name); + CConnMonWlanNetwork* wlanAp1 = CConnMonWlanNetwork::NewL( + name1, + EConnMonInfraStructure, + 20, + EConnMonSecurityOpen, + EConnMonSecurityV2Open, + 0, + bssid, + vendorData ); + wlanPtrArray.Append(wlanAp1); + + _LIT(wlanAp2Name, "Test AP 2"); + TBufC name2(wlanAp2Name); + CConnMonWlanNetwork* wlanAp2 = CConnMonWlanNetwork::NewL( + name2, + EConnMonAdHoc, + (refresh == true) ? 20 : 90, // signal strength variates between refreshes + EConnMonSecurityOpen, + EConnMonSecurityV2Open, + 0, + bssid, + vendorData ); + wlanPtrArray.Append(wlanAp2); + + if (refresh) { + _LIT(wlanAp3Name, "Test AP 3"); + TBufC name3(wlanAp3Name); + CConnMonWlanNetwork* wlanAp3 = CConnMonWlanNetwork::NewL( + name3, + EConnMonInfraStructure, + 20, + EConnMonSecurityWep, + EConnMonSecurityV2WepOpen, + 0, + bssid, + vendorData ); + wlanPtrArray.Append(wlanAp3); + + _LIT(wlanAp4Name, "Test AP 4"); + TBufC name4(wlanAp4Name); + CConnMonWlanNetwork* wlanAp4 = CConnMonWlanNetwork::NewL( + name4, + EConnMonInfraStructure, + 20, + EConnMonSecurityOpen, + EConnMonSecurityV2Open, + 0, + bssid, + vendorData ); + wlanPtrArray.Append(wlanAp4); + + _LIT(wlanAp5Name, "Test AP 5"); + TBufC name5(wlanAp5Name); + CConnMonWlanNetwork* wlanAp5 = CConnMonWlanNetwork::NewL( + name5, + EConnMonInfraStructure, + 20, + EConnMonSecurityWpa, + EConnMonSecurityV2Wpa, + 0, + bssid, + vendorData ); + wlanPtrArray.Append(wlanAp5); + + _LIT(wlanAp6Name, "Test AP 6"); + TBufC name6(wlanAp6Name); + CConnMonWlanNetwork* wlanAp6 = CConnMonWlanNetwork::NewL( + name6, + EConnMonInfraStructure, + 20, + EConnMonSecurityWpaPsk, + EConnMonSecurityV2WpaPsk, + 0, + bssid, + vendorData ); + wlanPtrArray.Append(wlanAp6); + + refresh = false; + } else { + refresh = true; + } + + CConnMonWlanNetworksPtrArrayPckg wlanBuf(wlanPtrArray, 2560); // TODO: buffer size to more dynamic or use constant + aValue.Copy(wlanBuf.Buf()->Des()); + } else { + Q_ASSERT(false); + } + + User::RequestComplete(&aStatus, KErrNone); +} + +#endif // WLANQTUTILS_T_WLANQTUTILS_UT_FLAG +#endif // __WINS__ diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/tsrc/stubs/wlanqtutilsconnteststub.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/tsrc/stubs/wlanqtutilsconnteststub.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* This is a source file for connmon library stub functions +*/ + +#include + +#ifdef __WINS__ + +#ifdef WLANQTUTILS_T_WLANQTUTILS_UT_FLAG + +// ---------------------------------------------- +// Stub functions for ICT library, used in UT +// ---------------------------------------------- + +#include "wlanqtutilstestcontext.h" + +extern WlanQtUtilsTestContext testContext; + +// ---------------------------------------------------- +// NewL is not stubbed -> parameters are not checked at all +// ---------------------------------------------------- + +/** + * Empty implementation to prevent actual ICT from starting. Result callback is called directly + * in the test cases. + */ +EXPORT_C void CIctsClientInterface::StartL() + { + } + +#endif // WLANQTUTILS_T_WLANQTUTILS_UT_FLAG + +// ---------------------------------------------------- +// No stubs used in emulator +// ---------------------------------------------------- +#endif // __WINS__ diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/tsrc/stubs/wlanqtutilsesockstub.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/tsrc/stubs/wlanqtutilsesockstub.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* This is a source file for esock library stub functions +*/ + +#include + +#ifdef __WINS__ + +#ifdef WLANQTUTILS_T_WLANQTUTILS_UT_FLAG + +// ---------------------------------------------- +// Stub functions for esock library, used in UT +// ---------------------------------------------- + +#include "wlanqtutilstestcontext.h" + +extern WlanQtUtilsTestContext testContext; + +/** + * Returns value from test context. + * + * TConnPref value cannot be verified easily because the real value passed to the function is + * TCommDbConnPref. Dynamic cast from TConnPref to TCommDbConnPref does not work because + * TConnPref does not have virtual functions which means that type information for the + * class hierarchy is not created by the compiler. + */ +void RConnection::Start(class TConnPref &, class TRequestStatus &aStatus) +{ + User::RequestComplete(&aStatus, testContext.esock_.startRetValue_); +} + +#else // WLANQTUTILS_T_WLANQTUTILS_UT_FLAG + +// ---------------------------------------------------- +// Stub functions for esock library, used in emulator +// ---------------------------------------------------- + +/** + * Return always success in emulator. + */ +void RConnection::Start(class TConnPref &, class TRequestStatus &aStatus) +{ + User::RequestComplete(&aStatus, KErrNone); +} + +#endif // WLANQTUTILS_T_WLANQTUTILS_UT_FLAG +#endif // __WINS__ diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/tsrc/testwlanqtutils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/tsrc/testwlanqtutils.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,1228 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* This is the source file for testing Wlan Qt Utilities library. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "wlanqtutilsap.h" +#include "wlanqtutilsiap.h" +#include "wlanqtutils.h" +#include "wlanqtutils_p.h" +#include "wlanqtutilsconmonwrapper.h" +#include "wlanqtutilsconmonwrapperinfo_s60_p.h" +#include "wlanqtutilsconntestwrapper.h" +#include "wlanqtutilsconntestwrapper_s60_p.h" +#include "testwlanqtutils.h" +#include "wlanqtutilstestcontext.h" + +WlanQtUtilsTestContext testContext; + +const QString TestWlanQtUtils::commsDatDefault_ = "default.cre"; + +// --------------------------------------------------------- +// FRAMEWORK FUNCTIONS +// --------------------------------------------------------- + +/** + * Test main function. Runs all test cases. + */ +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + char *pass[3]; + pass[0] = argv[0]; + pass[1] = "-o"; + pass[2] = "c:\\data\\wlanqtutils_qtest_log.txt"; + + TestWlanQtUtils tc; + int res = QTest::qExec(&tc, 3, pass); + + return res; +} + +/** + * This function will be called before the first test function is executed. + */ +void TestWlanQtUtils::initTestCase() +{ + wlanQtUtils_ = NULL; + signalScanReady_ = NULL; + signalWlanNetworkOpened_ = NULL; + signalWlanNetworkClosed_ = NULL; + signalIctResult_ = NULL; + + //If Active scheduler exists then don't install a new one as it will cause panic + if (CActiveScheduler::Current() == NULL) { + CActiveScheduler *scheduler = new CActiveScheduler(); + CActiveScheduler::Install(scheduler); + } +} + +/** + * This function will be called after the last test function was executed. + */ +void TestWlanQtUtils::cleanupTestCase() +{ + // CommsDat file is initialized. + subTestLoadCommsDatFile(commsDatDefault_); +} + +/** + * This function will be called before each test function is executed. + */ +void TestWlanQtUtils::init() +{ + // CommsDat file is initialized. + subTestLoadCommsDatFile(commsDatDefault_); + + testContext.initialize(); + + QVERIFY(wlanQtUtils_ == NULL); + QVERIFY(signalScanReady_ == NULL); + QVERIFY(signalWlanNetworkOpened_ == NULL); + QVERIFY(signalWlanNetworkClosed_ == NULL); + QVERIFY(signalIctResult_ == NULL); + subTestNewWlanQtUtils(); +} + +/** + * This function will be called after each test function is executed. + */ +void TestWlanQtUtils::cleanup() +{ + delete wlanQtUtils_; + wlanQtUtils_ = NULL; + + QCOMPARE(signalScanReady_->count(), 0); + delete signalScanReady_; + signalScanReady_ = NULL; + + QCOMPARE(signalWlanNetworkOpened_->count(), 0); + delete signalWlanNetworkOpened_; + signalWlanNetworkOpened_ = NULL; + + QCOMPARE(signalWlanNetworkClosed_->count(), 0); + delete signalWlanNetworkClosed_; + signalWlanNetworkClosed_ = NULL; + + QCOMPARE(signalIctResult_->count(), 0); + delete signalIctResult_; + signalIctResult_ = NULL; +} + +// --------------------------------------------------------- +// TEST CASES +// --------------------------------------------------------- + +/** + * Test available WLAN APs when scan is triggered by client. + */ +void TestWlanQtUtils::testAvailableWlan() +{ + testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(4); + + // Request a scan to get result signal + wlanQtUtils_->scanWlans(); + + // Let active object run and verify signal. + subTestSignalWaitAndTake(signalScanReady_, NULL); + + // Get and verify the list of available WLAN APs. + QList< QSharedPointer > iaps; + QList< QSharedPointer > aps; + wlanQtUtils_->availableWlans(iaps, aps); + + testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps); + QCOMPARE(iaps.count(), 0); + aps.clear(); +} + +/** + * Test available WLAN APs when scan is triggered by client. + * Two scan results have the same SSID and the latter one of those will be removed. + * Two scan results have the same SSID but different security mode + * Two scan results have the same SSID and security mode but different WpaPsk value + * and both are included in the results. + */ +void TestWlanQtUtils::testAvailableWlanDuplicates() +{ + testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(10); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[0]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID"); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[2]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID"); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID, different SecMode"); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[5]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[6]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID, different SecMode"); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeOpen); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[7]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID & SecMode diff Psk"); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[7]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa2); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[9]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID & SecMode diff Psk"); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[9]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa2); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[9]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true); + + // Request a scan to get result signal + wlanQtUtils_->scanWlans(); + + // Let active object run and verify signal. + subTestSignalWaitAndTake(signalScanReady_, NULL); + + // Get and verify the list of available WLAN APs. + QList< QSharedPointer > iaps; + QList< QSharedPointer > aps; + wlanQtUtils_->availableWlans(iaps, aps); + + // First remove AP that has duplicate SSID. + testContext.connMon_.wlanScanResult_.wlanScanResultList_.removeAt(2); + testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps); + QCOMPARE(iaps.count(), 0); + aps.clear(); +} + +/** + * Test available WLAN APs when scan is triggered by client. + * Include all supported security modes. + */ +void TestWlanQtUtils::testAvailableWlanSecModes() +{ + testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(9); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[0]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeOpen); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[0]->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Adhoc); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[1]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWep); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[2]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecMode802_1x); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[3]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[4]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[4]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[5]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa2); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa2); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[6]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[7]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWapi); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[8]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWapi); + // Let's trick the stub to return WapiPsk by putting WpaPskUse on * + testContext.connMon_.wlanScanResult_.wlanScanResultList_[8]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true); + + // Request a scan to get result signal + wlanQtUtils_->scanWlans(); + + // Let active object run and verify signal. + subTestSignalWaitAndTake(signalScanReady_, NULL); + + // Get and verify the list of available WLAN APs. + QList< QSharedPointer > iaps; + QList< QSharedPointer > aps; + wlanQtUtils_->availableWlans(iaps, aps); + + // Remove the trick *. WapiPsk and Wapi both map to just Wapi + testContext.connMon_.wlanScanResult_.wlanScanResultList_[8]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,false); + testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps); + QCOMPARE(iaps.count(), 0); + aps.clear(); +} + +/** + * Test available WLAN APs when scan is triggered by client. + * Include some exotic ssids. + */ +void TestWlanQtUtils::testAvailableWlanSsids() +{ + testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(6); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[1]->setValue(WlanQtUtilsAp::ConfIdSsid, " "); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[2]->setValue(WlanQtUtilsAp::ConfIdSsid, " whitespace around ssid "); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[3]->setValue(WlanQtUtilsAp::ConfIdSsid, QString(QChar())); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[4]->setValue(WlanQtUtilsAp::ConfIdSsid, "maximum length ssid that is 32 c"); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "A"); + + // Request a scan to get result signal + wlanQtUtils_->scanWlans(); + + // Let active object run and verify signal. + subTestSignalWaitAndTake(signalScanReady_, NULL); + + // Get and verify the list of available WLAN APs. + QList< QSharedPointer > iaps; + QList< QSharedPointer > aps; + wlanQtUtils_->availableWlans(iaps, aps); + + // Empty ssids are removed from results + testContext.connMon_.wlanScanResult_.wlanScanResultList_.removeAt(3); + testContext.connMon_.wlanScanResult_.wlanScanResultList_.removeAt(1); + testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps); + QCOMPARE(iaps.count(), 0); + aps.clear(); +} + +/** + * Test available WLAN APs when there are also WLAN IAPs available. + */ +void TestWlanQtUtils::testAvailableWlanWithIaps() +{ + testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(7); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[1]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 3"); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[1]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[1]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 1"); + // SSID is found in Internet Snap, but security mode does not match: + testContext.connMon_.wlanScanResult_.wlanScanResultList_[6]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 2"); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); + + // Request a scan to get result signal + wlanQtUtils_->scanWlans(); + + // Let active object run and verify signal. + subTestSignalWaitAndTake(signalScanReady_, NULL); + + // Get and verify the list of available WLAN APs. + QList< QSharedPointer > iaps; + QList< QSharedPointer > aps; + wlanQtUtils_->availableWlans(iaps, aps); + + // Verify WLAN AP list. First, remove scan results that will not appear + // because they are WLAN IAPs. + testContext.connMon_.wlanScanResult_.wlanScanResultList_.removeAt(5); + testContext.connMon_.wlanScanResult_.wlanScanResultList_.removeAt(1); + testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps); + + // Verify WLAN IAP list + QCOMPARE(iaps.count(), 2); + QCOMPARE(iaps[0]->value(WlanQtUtilsIap::ConfIdIapId).toInt(), 5); + QCOMPARE(iaps[0]->value(WlanQtUtilsIap::ConfIdName).toString(), QString("WLAN IAP 1")); + QCOMPARE(iaps[0]->value(WlanQtUtilsAp::ConfIdSsid).toString(), QString("WLAN IAP 1")); + QCOMPARE(iaps[1]->value(WlanQtUtilsIap::ConfIdIapId).toInt(), 7); + QCOMPARE(iaps[1]->value(WlanQtUtilsIap::ConfIdName).toString(), QString("WLAN IAP 3")); + QCOMPARE(iaps[1]->value(WlanQtUtilsAp::ConfIdSsid).toString(), QString("WLAN IAP 3")); + iaps.clear(); + aps.clear(); +} + +/** + * Test refereshing of WLAN APs when client requests sequential scans. + */ +void TestWlanQtUtils::testAvailableWlanSequence() +{ + // **************** Before 1st scan ******************** + QList< QSharedPointer > iaps; + QList< QSharedPointer > aps; + wlanQtUtils_->availableWlans(iaps, aps); + // Verify we have no results + QCOMPARE(aps.count(), 0); + QCOMPARE(iaps.count(), 0); + + // **************** 1st scan ******************** + // 6 APs are required for this scan + testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(6); + + wlanQtUtils_->scanWlans(); + subTestSignalWaitAndTake(signalScanReady_, NULL); + + // Get the results for the 1st scan + wlanQtUtils_->availableWlans(iaps, aps); + // Verify the results for the scan + testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps); + QCOMPARE(iaps.count(), 0); + aps.clear(); + + // **************** 2nd scan ******************** + // 2 APs are required for this scan + testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(2); + + wlanQtUtils_->scanWlans(); + subTestSignalWaitAndTake(signalScanReady_, NULL); + + // Get the results for the 2nd scan + wlanQtUtils_->availableWlans(iaps, aps); + // Verify the results for the scan + testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps); + QCOMPARE(iaps.count(), 0); + aps.clear(); + + // **************** 3rd scan ******************** + // 4 APs are required for the 3rd scan + testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(4); + + wlanQtUtils_->scanWlans(); + subTestSignalWaitAndTake(signalScanReady_, NULL); + + // Get the results for the 3rd scan + wlanQtUtils_->availableWlans(iaps, aps); + // Verify the results for the scan + testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps); + QCOMPARE(iaps.count(), 0); + aps.clear(); +} + +/** + * This function tests creation of WLAN IAP in a succesful manner. + * - WLAN scan is made because otherwise we cannot verify that IAP creation is successful. + * - Check that there are no available WLAN IAPs. + * - Fetch SNAP list. + * - Create WLAN IAP. + * - Check that WLAN IAP has been created and that this IAP is not in WLAN AP scan results. + */ +void TestWlanQtUtils::testCreateIapOk() +{ + testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(1); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[0]->setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapOk"); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[0]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); + testContext.connMon_.wlanScanResult_.wlanScanResultList_[0]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true); + + // Request a scan to get result signal + wlanQtUtils_->scanWlans(); + + // Let active object run and verify signal. + subTestSignalWaitAndTake(signalScanReady_, NULL); + + // Ensure there are no WLAN IAPs but there is one scan result. + QList< QSharedPointer > iaps; + QList< QSharedPointer > aps; + wlanQtUtils_->availableWlans(iaps, aps); + + QCOMPARE(iaps.count(), 0); + testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps); + + // Execute createIap() function + WlanQtUtilsAp wlanAp; + wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapOk"); + wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90 ); + wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra); + wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPsk, "100euronlounas"); + int iapId = wlanQtUtils_->createIap(&wlanAp); + QVERIFY(iapId != WlanQtUtils::IapIdNone); + + // Verify that created IAP is in the IAP list and AP list is empty. + wlanQtUtils_->availableWlans(iaps, aps); + QCOMPARE(iaps.count(), 1); + QCOMPARE(iaps[0]->value(WlanQtUtilsIap::ConfIdIapId).toInt(), iapId); + QCOMPARE(iaps[0]->value(WlanQtUtilsIap::ConfIdName).toString(), QString("testCreateIapOk")); + QCOMPARE(iaps[0]->value(WlanQtUtilsAp::ConfIdSsid).toString(), QString("testCreateIapOk")); + QCOMPARE(iaps[0]->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(), (int)(CMManagerShim::WlanSecModeWpa)); + QCOMPARE(iaps[0]->value(WlanQtUtilsAp::ConfIdWpaPskUse).toBool(), true); + QCOMPARE(aps.count(), 0); + iaps.clear(); +} + +/** + * This function tests creation of WLAN IAP in unsuccesful manner. + */ +void TestWlanQtUtils::testCreateIapErr() +{ + // Execute createIap() function with invalid parameters + WlanQtUtilsAp wlanAp; + wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapErr"); + wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90 ); + wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false); + // Invalid security mode -> exception + wlanAp.setValue( + WlanQtUtilsAp::ConfIdSecurityMode, + CMManager::EWlanSecModeWAPI + 1111); + int iapId = wlanQtUtils_->createIap(&wlanAp); + QVERIFY(iapId == WlanQtUtils::IapIdNone); +} + +/** + * This function tests creation of WLAN IAPs with different WEP keys. + */ +void TestWlanQtUtils::testCreateIapWepKeys() +{ + // Create the IAPs with different kind of WEP keys + WlanQtUtilsAp wlanAp; + wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapWepKeys"); + wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90); + wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra); + wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWep); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, 1); + // All keys in HEX format + wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey1, "1234567891"); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey2, "1234567891"); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey3, "1234567891"); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey4, "1234567891"); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false); + + int iapId = wlanQtUtils_->createIap(&wlanAp); + QVERIFY(iapId != WlanQtUtils::IapIdNone); + + wlanAp.setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, 2); + // All keys in ASCII format + wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey1, "12345"); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey2, "12345"); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey3, "12345"); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey4, "12345"); + + iapId = wlanQtUtils_->createIap(&wlanAp); + QVERIFY(iapId != WlanQtUtils::IapIdNone); + + wlanAp.setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, 3); + // Different keys, including a missing one + wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey1, ""); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey2, "12345678911234567892123456"); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey3, "12345"); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey4, "1234567891123"); + + iapId = wlanQtUtils_->createIap(&wlanAp); + QVERIFY(iapId != WlanQtUtils::IapIdNone); +} + +/** + * This function tests updating of WLAN IAP in a succesful manner. + */ +void TestWlanQtUtils::testUpdateIapOk() +{ + // Create an IAP that can be updated + WlanQtUtilsAp wlanAp; + wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testUpdateIapOk"); + wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90); + wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra); + wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false); + int iapId = wlanQtUtils_->createIap(&wlanAp); + + // Update the name and verify it changed + wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "UPDATED_testUpdateIapOk"); + + bool success = wlanQtUtils_->updateIap(iapId, &wlanAp); + QVERIFY(success == true); + QString name = wlanQtUtils_->iapName(iapId); + QCOMPARE(name, QString("UPDATED_testUpdateIapOk")); +} + +/** + * This function tests updating of WLAN IAP in unsuccesful manner. + */ +void TestWlanQtUtils::testUpdateIapErr() +{ + // Try to update a non-existing IAP + WlanQtUtilsAp wlanAp; + bool success = wlanQtUtils_->updateIap(200, &wlanAp); + QVERIFY(success == false); +} + +/** + * This function tests deletion of WLAN IAP in a succesful manner. + */ +void TestWlanQtUtils::testDeleteIapOk() +{ + // Create an IAP that can be deleted + WlanQtUtilsAp wlanAp; + wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testDeleteIapOk"); + wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90 ); + wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra); + wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false); + int iapId = wlanQtUtils_->createIap(&wlanAp); + + // Check that IAP now exists + QString name = wlanQtUtils_->iapName(iapId); + QCOMPARE(name, QString("testDeleteIapOk")); + + // Delete it and verify it does not exist anymore + wlanQtUtils_->deleteIap(iapId); + name = wlanQtUtils_->iapName(iapId); + QVERIFY(name.isEmpty()); +} + +/** + * This function tests deletion of WLAN IAP in unsuccesful manner. + */ +void TestWlanQtUtils::testDeleteIapErr() +{ + // Try to delete a non-existing IAP + wlanQtUtils_->deleteIap(200); + + // No signals or return values to verify +} + +/** + * This function tests connecting to IAP in a succesful manner. + */ +void TestWlanQtUtils::testConnectIapOk() +{ + testContext.esock_.startRetValue_ = KErrNone; + + // Esock stub completes connection creation immediately + wlanQtUtils_->connectIap(5); + + // Connection creation in ConnMon interface + testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, 5); + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase( + EConnMonCreateConnection, + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId())); + + // Connection status change in ConnMon interface + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KConnectionOpen)); + + // Receive signal for connection opening (caused by connectIap, which completed immediately) + QList arguments; + subTestSignalWaitAndTake(signalWlanNetworkOpened_, &arguments); + QCOMPARE(arguments.at(0).toInt(), 5); + + // Connection status change to opened in ConnMon interface. Sub test cases between test + // cases check that no extra signals are sent + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KLinkLayerOpen)); +} + +/** + * This function tests connecting to IAP in unsuccesful manner. + */ +void TestWlanQtUtils::testConnectIapErr() +{ + testContext.esock_.startRetValue_ = KErrGeneral; + + wlanQtUtils_->connectIap(7); + + testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, 7); + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase( + EConnMonCreateConnection, + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId())); + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KConnectionOpen)); + + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase( + EConnMonDeleteConnection, + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId())); + + QList arguments; + subTestSignalWaitAndTake(signalWlanNetworkClosed_, &arguments); + QCOMPARE(arguments.at(0).toInt(), 7); + QCOMPARE(arguments.at(1).toInt(), KErrGeneral); +} + +// TODO: testDisconnectFail cases are needed when fail branches are +// implemented into the connmon wrapper +/** + * This function tests IAP disconnecting functionality. + */ +void TestWlanQtUtils::testDisconnectIapOk() +{ + // Create and connect an IAP we can then disconnect + WlanQtUtilsAp wlanAp; + wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testDisconnectIapOk"); + wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90 ); + wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra); + wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false); + + int iapId = wlanQtUtils_->createIap(&wlanAp); + testContext.esock_.startRetValue_ = KErrNone; + wlanQtUtils_->connectIap(iapId); + QList arguments; + subTestSignalWaitAndTake(signalWlanNetworkOpened_, &arguments); + QCOMPARE(arguments.at(0).toInt(), iapId); + + // Make sure there is the newly created connection active and also + // another one to gain coverage + testContext.connMon_.activeConnections_.createDefaultActiveConnList(2, iapId - 1); + // The disconnect function does not have any return values or + // signals related to the disconnection, thus plain + // function call is done for the test. + wlanQtUtils_->disconnectIap(iapId); +} + +/** + * This function tests IAP disconnecting functionality when there is no + * IAP to disconnect. + */ +void TestWlanQtUtils::testDisconnectIapIgnored() +{ + testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, 150); + wlanQtUtils_->disconnectIap(200); + wlanQtUtils_->disconnectIap(WlanQtUtils::IapIdNone); +} + +/** + * This function tests connection status getter. + */ +void TestWlanQtUtils::testConnectionStatus() +{ + // Request status when there is no connection + WlanQtUtils::ConnStatus status = wlanQtUtils_->connectionStatus(); + QCOMPARE(status, WlanQtUtils::ConnStatusDisconnected); + + // Make a connection and request its status + testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, 5); + // Send event for connection creation. + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase( + EConnMonCreateConnection, + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId())); + // Send events for connection status change -> connecting + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KStartingConnection)); + + // Request status when there is connection in connecting state + status = wlanQtUtils_->connectionStatus(); + QCOMPARE(status, WlanQtUtils::ConnStatusConnecting); + + // Send events for connection status change -> connected + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KLinkLayerOpen)); + + QList arguments; + subTestSignalWaitAndTake(signalWlanNetworkOpened_, &arguments); + QCOMPARE(arguments.at(0).toInt(), 5); + + // Request status when there is connection in connected state + status = wlanQtUtils_->connectionStatus(); + QCOMPARE(status, WlanQtUtils::ConnStatusConnected); +} + +/** + * This function tests IAP name getter with existing IAP ID. + */ +void TestWlanQtUtils::testIapNameFound() +{ + // Create the IAP we want to find with the getter + WlanQtUtilsAp wlanAp; + wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testIapFound"); + wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90 ); + wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra); + wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa2); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false); + + int iapId = wlanQtUtils_->createIap(&wlanAp); + + // Execute the function under test and check that we got the correct name + QString name = wlanQtUtils_->iapName(iapId); + QCOMPARE(name, QString("testIapFound")); +} + +/** + * This function tests IAP name getter with non-existing IAP ID. + */ +void TestWlanQtUtils::testIapNameNotFound() +{ + // Execute the function under test and check that we get no name as result + QString name = wlanQtUtils_->iapName(200); // id in valid range, but not found -> KErrNotFound + QVERIFY(name.isEmpty()); + + name = wlanQtUtils_->iapName(1000); // id not in valid range -> KErrArgument + QVERIFY(name.isEmpty()); + + name = wlanQtUtils_->iapName(3); // id of cellular IAP -> discarded + QVERIFY(name.isEmpty()); +} + +/** + * This function tests active WLAN IAP getter with existing connection. + */ +void TestWlanQtUtils::testActiveIapFound() +{ + // Create the IAP we want to find with the getter + WlanQtUtilsAp wlanAp; + wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testConnectedWlanIdFound"); + wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90 ); + wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra); + wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false); + + int iapId = wlanQtUtils_->createIap(&wlanAp); + + testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, iapId); + + // Send event for connection creation. + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase( + EConnMonCreateConnection, + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId())); + + // Send events for connection status change -> opened. + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KStartingConnection)); + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KLinkLayerOpen)); + + QList arguments; + subTestSignalWaitAndTake(signalWlanNetworkOpened_, &arguments); + QCOMPARE(arguments.at(0).toInt(), iapId); + + // Execute the function under test and check that we get valid ID as result + int id = wlanQtUtils_->activeIap(); + QCOMPARE(id, iapId); +} + +/** + * This function tests active WLAN IAP getter with connection existing already during dll construction. + */ +void TestWlanQtUtils::testActiveIapFoundConstructor() +{ + // IAP IDs 4 and 5 exist in default commsdat file, 4 is GPRS, 5 is WLAN + testContext.connMon_.activeConnections_.createDefaultActiveConnList(2, 4); + testContext.connMon_.activeConnections_.activeConnList_[0]->connMonBearerType_ = EBearerGPRS; + + // Create a new instance in order to test functionality triggered in constructor. + WlanQtUtils *utils = new WlanQtUtils(); + + // Execute the function under test and check that we get valid ID as result + int id = utils->activeIap(); + QCOMPARE(id, 5); + + delete utils; +} + +/** + * This function tests active WLAN IAP getter without existing connection. + */ +void TestWlanQtUtils::testActiveIapNotFound() +{ + // Execute the function under test and check that we get invalid ID as result + int id = wlanQtUtils_->activeIap(); + QCOMPARE(id, WlanQtUtils::IapIdNone); +} + +/** + * Test WLAN scan triggering interface. + */ +void TestWlanQtUtils::testScanWlans() +{ + // Execute function under test + wlanQtUtils_->scanWlans(); + + // No need to verify scan results here, testAvailableWlan* test cases + // are for that. Just make sure the result signal is received. + subTestSignalWaitAndTake(signalScanReady_, NULL); +} + +/** + * Test WLAN scan triggering interface with two consecutive requests. + */ +void TestWlanQtUtils::testScanWlansIgnored() +{ + // Do not complete scan request immediately + testContext.connMon_.wlanScanResult_.completeWlanScan_ = false; + + // Execute function under test + wlanQtUtils_->scanWlans(); + + // Execute function under test again -> this one is ignored + wlanQtUtils_->scanWlans(); + + // Ongoing scan is cancelled in destructors +} + +/** + * Test WLAN scan stopping interface when scan is active. + */ +void TestWlanQtUtils::testStopWlanScanOk() +{ + // Do not complete scan request immediately + testContext.connMon_.wlanScanResult_.completeWlanScan_ = false; + // Start a scan + wlanQtUtils_->scanWlans(); + // Execute function under test + wlanQtUtils_->stopWlanScan(); + + // No return values or signals to verify +} + +/** + * Test WLAN scan stopping interface when no scan is ongoing. + */ +void TestWlanQtUtils::testStopWlanScanIgnored() +{ + // Execute function under test + wlanQtUtils_->stopWlanScan(); + + // No return values or signals to verify +} + +/** + * This function tests Wlan network opening signal when network is not opened by the dll. + */ +void TestWlanQtUtils::testWlanNetworkOpened() +{ + testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, 5); + + // Send event for connection creation. + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase( + EConnMonCreateConnection, + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId())); + + // Send events for connection status change -> opened. + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KConnectionOpen)); + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KConfigDaemonFinishedRegistration)); + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KLinkLayerOpen)); + + QList arguments; + subTestSignalWaitAndTake(signalWlanNetworkOpened_, &arguments); + QCOMPARE(arguments.at(0).toInt(), 5); + + // Send uninteresting event to gain coverage + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase( + EConnMonNetworkStatusChange, + 10)); +} + +/** + * This function tests Wlan network closing signal when network is not closed by the dll. + */ +void TestWlanQtUtils::testWlanNetworkClosed() +{ + // First create a connection + testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, 5); + + // Send event for connection creation. + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase( + EConnMonCreateConnection, + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId())); + + // Send events for connection status change -> opened. + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KConnectionOpen)); + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KLinkLayerOpen)); + + QList arguments; + subTestSignalWaitAndTake(signalWlanNetworkOpened_, &arguments); + QCOMPARE(arguments.at(0).toInt(), 5); + + // Send event for connection status change -> closed. + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KLinkLayerClosed)); + + // Send event for connection deletion. + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase( + EConnMonDeleteConnection, + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId())); + + subTestSignalWaitAndTake(signalWlanNetworkClosed_, &arguments); + QCOMPARE(arguments.at(0).toInt(), 5); + QCOMPARE(arguments.at(1).toInt(), KErrNone); +} + +/** + * This function tests WlanQtUtilsAp copy constructor. + */ +void TestWlanQtUtils::testApCopyConstructor() +{ + WlanQtUtilsAp firstAp; + firstAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testApCopyConstructor"); + firstAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90 ); + firstAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra); + firstAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa); + firstAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true); + firstAp.setValue(WlanQtUtilsAp::ConfIdWpaPsk, "100euronlounas"); + + // Create the copy AP + WlanQtUtilsAp secondAp(firstAp); + QCOMPARE(secondAp.value(WlanQtUtilsAp::ConfIdSsid).toString(), QString("testApCopyConstructor")); + QCOMPARE(secondAp.value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(), (int)(CMManagerShim::WlanSecModeWpa)); + QCOMPARE(secondAp.value(WlanQtUtilsAp::ConfIdWpaPskUse).toBool(), true); + QCOMPARE(secondAp.value(WlanQtUtilsAp::ConfIdSignalStrength).toInt(), 90); + QCOMPARE(secondAp.value(WlanQtUtilsAp::ConfIdConnectionMode).toInt(), (int)(CMManagerShim::Infra)); + QCOMPARE(secondAp.value(WlanQtUtilsAp::ConfIdWpaPsk).toString(), QString("100euronlounas")); +} + +/** + * This function tests ICT when connection test passes. + */ +void TestWlanQtUtils::testConnectionTestOk() +{ + // Create new IAP to test + WlanQtUtilsAp wlanAp; + wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testConnectionTestOk"); + wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90 ); + wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra); + wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false); + int iapId = wlanQtUtils_->createIap(&wlanAp); + QVERIFY(iapId != WlanQtUtils::IapIdNone); + + testContext.esock_.startRetValue_ = KErrNone; + + // Esock stub completes connection creation immediately + wlanQtUtils_->connectIap(iapId, true); + + // Connection creation in ConnMon interface + testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, iapId); + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase( + EConnMonCreateConnection, + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId())); + + // Connection status change in ConnMon interface + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KConnectionOpen)); + + // Receive signal for connection opening (caused by connectIap, which completed immediately) + QList arguments; + subTestSignalWaitAndTake(signalWlanNetworkOpened_, &arguments); + QCOMPARE(arguments.at(0).toInt(), iapId); + + // Connection status change to opened in ConnMon interface. Sub test cases between test + // cases check that no extra signals are sent + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KLinkLayerOpen)); + + // Connection test automatically started at this point. Call result function explicitly + // No interface exists that we could check that the IAP is moved to Internet SNAP correctly + TBuf<5> string; + wlanQtUtils_->d_ptr->mConnTestWrapper->d_ptr_->ConnectivityObserver(EConnectionOk, string); + + subTestSignalWaitAndTake(signalIctResult_, &arguments); + QCOMPARE(arguments.at(0).toInt(), iapId); + QCOMPARE(arguments.at(1).toBool(), true); +} + +/** + * This function tests ICT when connection test fails. + */ +void TestWlanQtUtils::testConnectionTestErr() +{ + // Create and connect an IAP and request ICT to be run + WlanQtUtilsAp wlanAp; + wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testConnectionTestErr"); + wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90 ); + wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra); + wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false); + + int iapId = wlanQtUtils_->createIap(&wlanAp); + wlanQtUtils_->connectIap(iapId, true); + + testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, iapId); + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase( + EConnMonCreateConnection, + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId())); + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KConnectionOpen)); + QList arguments; + subTestSignalWaitAndTake(signalWlanNetworkOpened_, &arguments); + QCOMPARE(arguments.at(0).toInt(), iapId); + + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KLinkLayerOpen)); + + // Connection test automatically started at this point. Call result function explicitly + // No interface exists that we could check that IAP is not moved to another SNAP + TBuf<5> string; + wlanQtUtils_->d_ptr->mConnTestWrapper->d_ptr_->ConnectivityObserver(EHttpAuthenticationNeeded, string); + + subTestSignalWaitAndTake(signalIctResult_, &arguments); + QCOMPARE(arguments.at(0).toInt(), iapId); + QCOMPARE(arguments.at(1).toBool(), false); +} + +/** + * This function tests that Gprs connection events are ignored. + */ +void TestWlanQtUtils::testConnMonEventGprs() +{ + // First create a connection + testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, 4); + testContext.connMon_.activeConnections_.activeConnList_[0]->connMonBearerType_ = EBearerGPRS; + + // Send event for connection creation. + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase( + EConnMonCreateConnection, + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId())); + + // Send events for connection status change -> opened. + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KConnectionOpen)); + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KLinkLayerOpen)); + + // Send event for connection status change -> closed. + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KLinkLayerClosed)); + + // Send event for connection deletion. + wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase( + EConnMonDeleteConnection, + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId())); +} + +/** + * This function tests ConnMon event handling with connection existing already during dll construction. + */ +void TestWlanQtUtils::testConnMonEventCreatedBeforeConstructor() +{ + // IAP ID 5 exists in default commsdat file + testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, 5); + + // Create a new instance in order to test functionality triggered in constructor. + WlanQtUtils *utils = new WlanQtUtils(); + + QSignalSpy *signalWlanNetworkOpened = new QSignalSpy(utils, SIGNAL(wlanNetworkOpened(int))); + QVERIFY(signalWlanNetworkOpened->isValid() == true); + QSignalSpy *signalWlanNetworkClosed = new QSignalSpy(utils, SIGNAL(wlanNetworkClosed(int, int))); + QVERIFY(signalWlanNetworkClosed->isValid() == true); + + // Send events for connection status change -> opened. + utils->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KConnectionOpen)); + utils->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KLinkLayerOpen)); + + QList arguments; + subTestSignalWaitAndTake(signalWlanNetworkOpened, &arguments); + QCOMPARE(arguments.at(0).toInt(), 5); + + // Send event for connection status change -> closed. + utils->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange( + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(), + 0, + KLinkLayerClosed)); + + // Send event for connection deletion. + utils->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase( + EConnMonDeleteConnection, + testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId())); + + subTestSignalWaitAndTake(signalWlanNetworkClosed, &arguments); + QCOMPARE(arguments.at(0).toInt(), 5); + QCOMPARE(arguments.at(1).toInt(), KErrNone); + + delete signalWlanNetworkOpened; + delete signalWlanNetworkClosed; + delete utils; +} + +// --------------------------------------------------------- +// SUB TEST CASES +// --------------------------------------------------------- + +/** + * This function waits for active objects to get time to run, takes the arguments of the + * first signal and returns them from the given signal spy. + * This function also verifies that the number of signals is 1. + * + * @param[in] spy Signal spy. + * @param[out] arguments Arguments of the first signal in the given signal spy. NULL if arguments not needed. + */ +void TestWlanQtUtils::subTestSignalWaitAndTake(QSignalSpy* spy, QList* arguments) +{ + QTest::qWait(1); + QCOMPARE(spy->count(), 1); + QList arguments_tmp = spy->takeFirst(); + if (arguments != NULL) { + *arguments = arguments_tmp; + } +} + +/** + * This function loads given CommsDat file, replacing current one. + * If CommsDat file doesn't exist, it can be re-created by commanding WST script. + * Using help switch is a quick way: + * run_wst HELP + * + * @param newCommsdatFilename Filename of the new CommsDat to be loaded. + */ +void TestWlanQtUtils::subTestLoadCommsDatFile(QString newCommsdatFilename) +{ + // EPOC's CommsDat filename + const QString epocCommsdatFilename("cccccc00.cre"); + // EPOC's directory for CommsDat file + const QString commsdatDir("c:\\private\\10202be9\\persists\\"); + // Created backup directory under EPOC for CommsDat files + const QString storeDir("c:\\private\\10202be9\\persists\\backup\\"); + QString nameOld = commsdatDir + epocCommsdatFilename; + QString nameDefault = storeDir + newCommsdatFilename; + + // First remove the old CommsDat file. + Q_ASSERT(QFile::remove(nameOld) == TRUE); + + // Copy the stored default CommsDat file. + Q_ASSERT(QFile::copy(nameDefault, nameOld) == TRUE); +} + +/** + * + */ +void TestWlanQtUtils::subTestNewWlanQtUtils() +{ + if (wlanQtUtils_ != NULL) { + delete wlanQtUtils_; + } + wlanQtUtils_ = new WlanQtUtils(); + + if (signalScanReady_ != NULL) { + delete signalScanReady_; + } + signalScanReady_ = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanScanReady())); + QVERIFY(signalScanReady_->isValid() == true); + + if (signalWlanNetworkOpened_ != NULL) { + delete signalWlanNetworkOpened_; + } + signalWlanNetworkOpened_ = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanNetworkOpened(int))); + QVERIFY(signalWlanNetworkOpened_->isValid() == true); + + if (signalWlanNetworkClosed_ != NULL) { + delete signalWlanNetworkClosed_; + } + signalWlanNetworkClosed_ = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanNetworkClosed(int, int))); + QVERIFY(signalWlanNetworkClosed_->isValid() == true); + + if (signalIctResult_ != NULL) { + delete signalIctResult_; + } + signalIctResult_ = new QSignalSpy(wlanQtUtils_, SIGNAL(ictResult(int, bool))); + QVERIFY(signalIctResult_->isValid() == true); +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/tsrc/testwlanqtutils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/tsrc/testwlanqtutils.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,121 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* This is the header file for testing Wlan Qt Utilities library. +*/ + +#ifndef TESTWLANQTUTILS_H +#define TESTWLANQTUTILS_H + +#include + +class QSignalSpy; +class WlanQtUtils; + +class TestWlanQtUtils: public QObject +{ + Q_OBJECT + +private slots: + + // Functions from QTest framework. + void initTestCase(); + void cleanupTestCase(); + void init(); + void cleanup(); + + // Test functions for public interface. + void testAvailableWlan(); + void testAvailableWlanDuplicates(); + void testAvailableWlanSecModes(); + void testAvailableWlanSsids(); + void testAvailableWlanWithIaps(); + void testAvailableWlanSequence(); + + void testCreateIapOk(); + void testCreateIapErr(); + void testCreateIapWepKeys(); + + void testUpdateIapOk(); + void testUpdateIapErr(); + + void testDeleteIapOk(); + void testDeleteIapErr(); + + void testConnectIapOk(); + void testConnectIapErr(); + + void testDisconnectIapOk(); + void testDisconnectIapIgnored(); + + void testConnectionStatus(); + + void testIapNameFound(); + void testIapNameNotFound(); + + void testActiveIapFound(); + void testActiveIapFoundConstructor(); + void testActiveIapNotFound(); + + void testScanWlans(); + void testScanWlansIgnored(); + + void testStopWlanScanOk(); + void testStopWlanScanIgnored(); + + void testWlanNetworkOpened(); + void testWlanNetworkClosed(); + + void testApCopyConstructor(); + + // Test functions for private implementation (tested via public interface) + void testConnectionTestOk(); + void testConnectionTestErr(); + + void testConnMonEventGprs(); + void testConnMonEventCreatedBeforeConstructor(); + +private: + + // Helper functions, that is, sub test cases. + void subTestSignalWaitAndTake(QSignalSpy *spy, QList *arguments); + void subTestLoadCommsDatFile(QString newCommsdatFilename); + void subTestNewWlanQtUtils(); + + // Member variables. + WlanQtUtils *wlanQtUtils_; + QSignalSpy *signalScanReady_; + QSignalSpy *signalWlanNetworkOpened_; + QSignalSpy *signalWlanNetworkClosed_; + QSignalSpy *signalIctResult_; + + /* Default CommsDat file name + SNAP ID=3: Internet: + IAP ID = 1: packet data 1 + IAP ID = 3: packet data 2 + IAP ID = 4: packet data 3 + IAP ID = 5: WLAN IAP 1, EWlanSecModeOpen + IAP ID = 6: WLAN IAP 2, EWlanSecModeWep, w2key + IAP ID = 7: WLAN IAP 3, EWlanSecModeWpa, wlan3key + SNAP ID = 4: Multimedia msg. + SNAP ID = 5: WAP services + SNAP ID = 6: My Snap: + IAP ID = 8: Home WLAN, EWlanSecModeOpen + IAP ID = 9: Streaming + */ + static const QString commsDatDefault_; +}; + +#endif // TESTWLANQTUTILS_H + diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/tsrc/testwlanqtutils.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/tsrc/testwlanqtutils.pro Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,95 @@ +# +# Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# 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". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# Test library for WlanQtUtils class. +# + +QT += testlib + +TEMPLATE = app +TARGET = t_wlanqtutils + +TARGET.CAPABILITY = ALL -TCB + +DEPENDPATH += . + +#Store generated .moc files to their own directory +MOC_DIR = moc + +# Temporary solution to fix tracecompiler +# When tracecompiler is fixed, this can be removed +symbian: { + MMP_RULES += "USERINCLUDE traces" +} + +#BUILD_DLL macro is used to define export macro +DEFINES += BUILD_WLANQTUTILITIES_DLL + +INCLUDEPATH += \ + . \ + ../base/inc \ + ../wrapper/inc \ + ../traces + +# Input +HEADERS += \ + testwlanqtutils.h \ + context/wlanqtutilstestcontext.h \ + ../base/inc/wlanqtutils.h \ + ../base/inc/wlanqtutils_p.h \ + ../base/inc/wlanqtutilsiap.h \ + ../base/inc/wlanqtutilsiapsettings.h \ + ../base/inc/wlanqtutilsap.h \ + ../base/inc/wlanqtutilsconnection.h \ + ../wrapper/inc/wlanqtutilsconmonwrapper.h \ + ../wrapper/inc/wlanqtutilsconntestwrapper.h \ + ../wrapper/inc/wlanqtutilsesockwrapper.h \ + ../traces/OstTraceDefinitions.h + +SOURCES += \ + testwlanqtutils.cpp \ + context/wlanqtutilstestcontext.cpp \ + ../base/src/wlanqtutils.cpp \ + ../base/src/wlanqtutils_p.cpp \ + ../base/src/wlanqtutilsiap.cpp \ + ../base/src/wlanqtutilsap.cpp \ + ../base/src/wlanqtutilsconnection.cpp \ + ../base/src/wlanqtutilsiapsettings.cpp \ + ../wrapper/src/wlanqtutilsconmonwrapper.cpp \ + ../wrapper/src/wlanqtutilsconntestwrapper.cpp \ + ../wrapper/src/wlanqtutilsesockwrapper.cpp + +symbian: { + HEADERS += \ + ../wrapper/inc/wlanqtutilsconmonwrapperdisconnect_s60_p.h \ + ../wrapper/inc/wlanqtutilsconmonwrapperinfo_s60_p.h \ + ../wrapper/inc/wlanqtutilsconmonwrapperscan_s60_p.h \ + ../wrapper/inc/wlanqtutilsconntestwrapper_s60_p.h \ + ../wrapper/inc/wlanqtutilsesockwrapper_s60_p.h + + SOURCES += \ + ../wrapper/src/wlanqtutilsconmonwrapperdisconnect_s60.cpp \ + ../wrapper/src/wlanqtutilsconmonwrapperinfo_s60.cpp \ + ../wrapper/src/wlanqtutilsconmonwrapperscan_s60.cpp \ + ../wrapper/src/wlanqtutilsconntestwrapper_s60.cpp \ + ../wrapper/src/wlanqtutilsesockwrapper_s60.cpp \ + stubs/wlanqtutilsconnmonstub.cpp \ + stubs/wlanqtutilsconnteststub.cpp \ + stubs/wlanqtutilsesockstub.cpp +} + +LIBS += -lconnmon -lconnection_settings_shim -lextendedconnpref -lnetmeta -lesock -lictsclientinterface + +#UT flag is set, used in stub codes +DEFINES += WLANQTUTILS_T_WLANQTUTILS_UT_FLAG diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/tsrc/tools/default.cre Binary file wlanutilities/wlanqtutilities/tsrc/tools/default.cre has changed diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/tsrc/tools/make_wst.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/tsrc/tools/make_wst.bat Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,197 @@ +::============================================================================= +:: Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +:: All rights reserved. +:: This component and the accompanying materials are made available +:: 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". +:: +:: Initial Contributors: +:: Nokia Corporation - initial contribution. +:: +:: Contributors: +:: +:: Description: +:: Wlan Qt Utilities test execution script +::============================================================================= +:: +:: Following commands are implemented: +:: - CLEAN_OLD_FILES +:: - COMPILE_WLANQTUTILS +:: - COMPILE_TEST_CASES +:: - RUN_TEST_CASES +:: - GENERATE_REPORTS +:: - SHOW_RESULTS +:: - START_BROWSER +::============================================================================= + +::----------------------------------------------------------------------------- +:: Do the preparations: +:: - Don't show the commands +:: - Use local parameters -- don't pollute the global one +::----------------------------------------------------------------------------- +@echo off + +echo *** WST_MAKE: START: +setlocal + +::----------------------------------------------------------------------------- +:: Check input +:: +:: Parameters that are required: +:: 1) wst_root_dir +:: 2) log_file_name +:: 3) the command +::----------------------------------------------------------------------------- + +:: (1) +if not exist %1 goto ERROR +if [%1]==[] goto ERROR +set wst_root_dir=%1 +set wst_log_dir=%1\wst_log +set wst_report_dir=%1\wst_report +set wlanqtutils_root_dir=%1\..\.. +set wlanqtutils_test_dir=%1\.. + +:: (2) +if [%2]==[] goto ERROR +set log_file_name=%2 +set log_file=%wst_log_dir%\%log_file_name% +if not exist %log_file% goto ERROR +echo *** DATE AND TIME: %date%, %time% >> %log_file% +echo *** WST_MAKE: INFO: Wlan Qt Utilities root dir: %wlanqtutils_root_dir% +echo *** WST_MAKE: INFO: Wlan Qt Utilities test dir: %wlanqtutils_test_dir% +echo *** WST_MAKE: INFO: WST log dir: %wst_log_dir% +echo *** WST_MAKE: INFO: WST log file: %log_file% + +:: (3) +if [%3]==[] goto ERROR +goto %3 + +:: Error if label not found. +goto ERROR + +::----------------------------------------------------------------------------- +:CLEAN_OLD_FILES +::----------------------------------------------------------------------------- + +echo *** WST_MAKE: CLEAN_OLD_FILES: +echo *** WST_LOG: CLEAN_OLD_FILES >> %log_file% + +move %wst_log_dir%\%log_file_name% %wst_root_dir% +del /F /S /Q %wst_log_dir%\* +del /F /S /Q %wst_report_dir%\* +rmdir /S /Q %wst_log_dir%\CMTHTML +rmdir /S /Q %wst_log_dir%\CTCHTML +move %wst_root_dir%\%log_file_name% %wst_log_dir% +del \epoc32\winscw\c\data\wlanqtutils_qtest_log.txt + +goto THE_END + +::----------------------------------------------------------------------------- +:COMPILE_WLANQTUTILS +::----------------------------------------------------------------------------- + +echo *** WST_MAKE: COMPILE_WLANQTUTILS: +echo *** WST_LOG: COMPILE_WLANQTUTILS >> %log_file% + +cd %wlanqtutils_root_dir% +call qmake >> %log_file% 2>&1 +call sbs -c winscw reallyclean >> %log_file% 2>&1 +call sbs -c winscw_udeb >> %log_file% 2>&1 + +goto THE_END + +::----------------------------------------------------------------------------- +:COMPILE_TEST_CASES +::----------------------------------------------------------------------------- + +echo *** WST_MAKE: COMPILE_TEST_CASES: +echo *** WST_LOG: COMPILE_TEST_CASES >> %log_file% + +cd %wlanqtutils_test_dir% +call qmake "CONFIG -= debug" >> %log_file% 2>&1 +call sbs -c winscw reallyclean >> %log_file% 2>&1 +:: Call CTC instrumentation script. Source directories hard coded, because NO_EXCLUDE does not like % characters... +call ctcwrap -C EXCLUDE=* -C NO_EXCLUDE+..\base\src\*.cpp,..\wrapper\src\*.cpp -2comp -n %wst_log_dir%\MON.sym -i m -v sbs -c winscw_udeb >> %log_file% 2>&1 + +goto THE_END + +::----------------------------------------------------------------------------- +:RUN_TEST_CASES +::----------------------------------------------------------------------------- + +echo *** WST_MAKE: RUN_TEST_CASES: +echo *** WST_LOG: RUN_TEST_CASES >> %log_file% + +call \epoc32\release\winscw\udeb\t_wlanqtutils.exe -o c:\data\wlanqtutils_qtest_log.txt + +goto THE_END + +::----------------------------------------------------------------------------- +:GENERATE_REPORTS +::----------------------------------------------------------------------------- + +echo *** WST_MAKE: GENERATE_REPORTS: +echo *** WST_LOG: GENERATE_REPORTS >> %log_file% + +cd %wst_log_dir% + +call ctcpost -p %wst_log_dir%\ctc_coverage.txt +call ctc2html -nsb -i %wst_log_dir%\ctc_coverage.txt + +call dir /s /b %wlanqtutils_root_dir%\*.cpp > %wst_log_dir%\raw_filelist.txt + +call findstr /I /V "moc_" %wst_log_dir%\raw_filelist.txt > %wst_log_dir%\filelist.txt +call cmt -f %wst_log_dir%\filelist.txt -o cmt_metrics.txt >> %log_file% +call cmt2html -nsb -i cmt_metrics.txt + +:: Clean up temp files +call del %wst_log_dir%\*filelist.txt + +echo *** WST_MAKE: COPY LOGS: +call copy %TEMP%\epocwind.out %wst_log_dir%\epocwind.txt + +goto THE_END + +::----------------------------------------------------------------------------- +:SHOW_RESULTS +::----------------------------------------------------------------------------- + +echo *** WST_MAKE: SHOW_RESULTS: +echo *** WST_LOG: SHOW_RESULTS >> %log_file% +echo *** Module tests: +call findstr /C:"Totals: " \epoc32\winscw\c\data\wlanqtutils_qtest_log.txt +echo *** Coverage: +call findstr /C:"Number of " %wst_log_dir%\ctc_coverage.txt +call findstr /C:"TER " %wst_log_dir%\ctc_coverage.txt + +goto THE_END + +::----------------------------------------------------------------------------- +:START_BROWSER +::----------------------------------------------------------------------------- + +echo *** WST_MAKE: START_BROWSER: +echo *** WST_LOG: START_BROWSER >> %log_file% +echo. +echo Starting up browser to show the results + +start %wst_root_dir%\wst_report\coverage.html + +goto THE_END + +::----------------------------------------------------------------------------- +:ERROR +::----------------------------------------------------------------------------- + +echo *** WST_MAKE: ERROR: +endlocal +echo wst_make *** Error (unknown parameter) >> %log_file% + +goto THE_END + +::----------------------------------------------------------------------------- +:THE_END +::----------------------------------------------------------------------------- +echo *** WST_MAKE: END: diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/tsrc/tools/run_wst.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/tsrc/tools/run_wst.bat Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,173 @@ +::============================================================================= +:: Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +:: All rights reserved. +:: This component and the accompanying materials are made available +:: 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". +:: +:: Initial Contributors: +:: Nokia Corporation - initial contribution. +:: +:: Contributors: +:: +:: Description: +:: Wlan Qt Utilities test execution script +::============================================================================= + +:: Script(s) uses following environment settings: +:: - CD +:: - DATE +:: - TIME +:: - TEMP + + +::----------------------------------------------------------------------------- +:: Do the preparations: +:: - Don't show the commands +:: - Use local parameters -- don't pollute the global one +:: - Dim the lights for time of script execution +:: - Store the current working directory +::----------------------------------------------------------------------------- + +@echo off +echo *** RUN_WST: START: +setlocal +color 08 +pushd . +if not exist run_wst.bat goto INVALID_DIR + + +::----------------------------------------------------------------------------- +:: Set the local variables +::----------------------------------------------------------------------------- + +echo *** RUN_WST: SET VARIABLES: +set wst_root_dir=%cd% +set wst_log_dir=%wst_root_dir%\wst_log +set wst_report_dir=%wst_root_dir%\wst_report +set log_file=%wst_log_dir%\wst_log.txt +set build_script=make_wst.bat +set epoc_commsdat_dir=\epoc32\winscw\c\private\10202be9\persists +if not exist %epoc_commsdat_dir% goto INVALID_DIR +set epoc_backup_dir=%epoc_commsdat_dir%\backup +set ut_commsdat_dir=%wst_root_dir% +if not exist %ut_commsdat_dir% goto INVALID_DIR +set ut_commsdat_file_default=%ut_commsdat_dir%\default.cre +if not exist %ut_commsdat_file_default% goto INVALID_DIR +set ut_commsdat_files=%ut_commsdat_dir%\*.cre +if not exist %ut_commsdat_files% goto INVALID_DIR + + +::----------------------------------------------------------------------------- +:: Copy commsdat file to emulator directory and also to backup directory +::----------------------------------------------------------------------------- + +echo *** RUN_WST: COPY FILES: +copy %ut_commsdat_file_default% %epoc_commsdat_dir%\cccccc00.cre /y +if not exist %epoc_backup_dir% mkdir %epoc_backup_dir% +copy %ut_commsdat_files% %epoc_backup_dir% /y + + +::----------------------------------------------------------------------------- +:: Check that script exists +::----------------------------------------------------------------------------- + +echo *** RUN_WST: SOME CHECKS: +if not exist %build_script% goto INVALID_DIR +:: Create output directory if it does not exist +if not exist %wst_log_dir% mkdir %wst_log_dir% +if not exist %wst_report_dir% mkdir %wst_report_dir% +:: Create log file +echo *** WST_LOG: BEGIN *** > %log_file% + + +::----------------------------------------------------------------------------- +:: Check parameters +::----------------------------------------------------------------------------- + +set command=ERROR +if [%1]==[] set command=CLEAN_OLD_FILES COMPILE_WLANQTUTILS COMPILE_TEST_CASES RUN_TEST_CASES GENERATE_REPORTS SHOW_RESULTS +if [%1]==[CLEAN_OLD] set command=CLEAN_OLD_FILES +if [%1]==[WLANQTUTILS] set command=COMPILE_WLANQTUTILS +if [%1]==[CASES] set command=COMPILE_TEST_CASES +if [%1]==[RUN] set command=RUN_TEST_CASES +if [%1]==[REPORTS] set command=GENERATE_REPORTS +if [%1]==[RESULTS] set command=SHOW_RESULTS +if [%1]==[BROWSE] set command=START_BROWSER +if [%1]==[/?] goto HELP +if [%1]==[HELP] goto HELP +if [%1]==[/h] goto HELP +if [%1]==[-h] goto HELP + +::----------------------------------------------------------------------------- +:PARSE_COMMANDS +::----------------------------------------------------------------------------- + +echo *** RUN_WST: COMMAND: %command% +echo *** RUN_WST: CALL SCRIPT: +for %%i IN ( %command% ) DO ( + call %build_script% %wst_root_dir% wst_log.txt %%i + for /f "tokens=3 delims= " %%x in ('find /C " Error " %log_file%') do ( + if not [%%x]==[0] goto ERROR + ) +) + +goto THE_END + + +::----------------------------------------------------------------------------- +:INVALID_DIR +::----------------------------------------------------------------------------- + +echo *** RUN_WST: INVALID DIR: +echo *** Test script sub-script not found! +echo *** Please be sure to run the script in same directory, +echo *** i.e. .\run_wst.bat , and NOT .\tools\run_wst.bat + +goto THE_END + + +::----------------------------------------------------------------------------- +:ERROR +::----------------------------------------------------------------------------- + +echo *** RUN_WST: ERROR: +color 48 +echo Error in compilation: +findstr /C:" Error " < %log_file% +echo. +Echo Quitting WST. + +goto THE_END + + +::----------------------------------------------------------------------------- +:HELP +::----------------------------------------------------------------------------- + +echo *** RUN_WST: HELP: +echo Run Wlan Qt Utilities Workstation Testing +echo. +echo RUN_WST [param] +echo. +echo param +echo [none] - Do all, from CLEAN_OLD to RESULTS +echo. +echo CLEAN_OLD - Clean metrics and other generated files +echo WLANQTUTILS - Build only Wlan Qt Utilities components +echo CASES - Build only Tester components +echo RUN - Run Tester +echo REPORTS - Generate reports +echo RESULTS - Show results +echo BROWSE - Start browser +echo. + + +::----------------------------------------------------------------------------- +:THE_END +::----------------------------------------------------------------------------- + +echo *** RUN_WST: END: +color +popd diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wlanqtutilities.pro --- a/wlanutilities/wlanqtutilities/wlanqtutilities.pro Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanqtutilities/wlanqtutilities.pro Mon May 24 21:11:39 2010 +0300 @@ -1,5 +1,5 @@ # -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). # All rights reserved. # This component and the accompanying materials are made available # under the terms of "Eclipse Public License v1.0" @@ -12,11 +12,12 @@ # Contributors: # # Description: +# WLAN Qt Utilities project file. # TEMPLATE = lib TARGET = wlanqtutilities -TARGET.CAPABILITY = ALL -TCB +TARGET.CAPABILITY = CAP_GENERAL_DLL #BUILD_DLL macro is used to define export macro DEFINES += BUILD_WLANQTUTILITIES_DLL @@ -31,68 +32,63 @@ MMP_RULES += "USERINCLUDE traces" } -#Following macros MW_LAYER_SYSTEMINCLUDE and OS_LAYER_SYSTEMINCLUDE are defined -#in X:\QT\mkspecs\features\symbian\platform_paths.prf that is always inluded in -#QT compilation - -INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE \ - $$OS_LAYER_SYSTEMINCLUDE \ - base/inc \ - wrapper/inc \ - traces +INCLUDEPATH += \ + base/inc \ + wrapper/inc \ + traces -HEADERS += base/inc/wlanqtutils.h \ - base/inc/wlanqtutils_p.h \ - base/inc/wlanqtutilsactiveconn.h \ - base/inc/wlanqtutilscommon.h \ - base/inc/wlanqtutilswlanap.h \ - base/inc/wlanqtutilswlaniap.h \ - base/inc/wlanqtutilsiap.h \ - wrapper/inc/wlanqtutilsconmonwrapper.h \ - wrapper/inc/wlanqtutilscmmwrapper.h \ - wrapper/inc/wlanqtutilsconntestwrapper.h \ - wrapper/inc/wlanqtutilsesockwrapper.h \ - traces/OstTraceDefinitions.h +HEADERS += \ + base/inc/wlanqtutils.h \ + base/inc/wlanqtutils_p.h \ + base/inc/wlanqtutilsap.h \ + base/inc/wlanqtutilsconnection.h \ + base/inc/wlanqtutilsiap.h \ + base/inc/wlanqtutilsiapsettings.h \ + wrapper/inc/wlanqtutilsconmonwrapper.h \ + wrapper/inc/wlanqtutilsconntestwrapper.h \ + wrapper/inc/wlanqtutilsesockwrapper.h \ + traces/OstTraceDefinitions.h -SOURCES += base/src/wlanqtutils.cpp \ - base/src/wlanqtutils_p.cpp \ - base/src/wlanqtutilsactiveconn.cpp \ - base/src/wlanqtutilswlanap.cpp \ - base/src/wlanqtutilswlaniap.cpp \ - base/src/wlanqtutilsiap.cpp \ - wrapper/src/wlanqtutilsconmonwrapper.cpp \ - wrapper/src/wlanqtutilscmmwrapper.cpp \ - wrapper/src/wlanqtutilsconntestwrapper.cpp \ - wrapper/src/wlanqtutilsesockwrapper.cpp +SOURCES += \ + base/src/wlanqtutils.cpp \ + base/src/wlanqtutils_p.cpp \ + base/src/wlanqtutilsap.cpp \ + base/src/wlanqtutilsconnection.cpp \ + base/src/wlanqtutilsiap.cpp \ + base/src/wlanqtutilsiapsettings.cpp \ + wrapper/src/wlanqtutilsconmonwrapper.cpp \ + wrapper/src/wlanqtutilsconntestwrapper.cpp \ + wrapper/src/wlanqtutilsesockwrapper.cpp -mmpRuleDeffile = \ - "$${LITERAL_HASH}ifdef WINSCW" \ - "DEFFILE ./bwins/wlanqtutilities.def" \ - "$${LITERAL_HASH}else" \ - "DEFFILE ./eabi/wlanqtutilities.def" \ - "$${LITERAL_HASH}endif" +# Common libraries +LIBS += -lconnection_settings_shim symbian: { - HEADERS += wrapper/inc/wlanqtutilsconmonwrapper_s60_p.h \ - wrapper/inc/wlanqtutilscmmwrapper_s60_p.h \ - wrapper/inc/wlanqtutilsconntestwrapper_s60_p.h \ - wrapper/inc/wlanqtutilsesockwrapper_s60_p.h - SOURCES += wrapper/src/wlanqtutilsconmonwrapper_s60.cpp \ - wrapper/src/wlanqtutilscmmwrapper_s60.cpp \ - wrapper/src/wlanqtutilsconntestwrapper_s60.cpp \ - wrapper/src/wlanqtutilsesockwrapper_s60.cpp \ - ut/stubs/wlanqtutilsconnmonstub.cpp \ - ut/stubs/wlanqtutilsesockstub.cpp + HEADERS += \ + wrapper/inc/wlanqtutilsconmonwrapperdisconnect_s60_p.h \ + wrapper/inc/wlanqtutilsconmonwrapperinfo_s60_p.h \ + wrapper/inc/wlanqtutilsconmonwrapperscan_s60_p.h \ + wrapper/inc/wlanqtutilsconntestwrapper_s60_p.h \ + wrapper/inc/wlanqtutilsesockwrapper_s60_p.h + SOURCES += \ + wrapper/src/wlanqtutilsconmonwrapperdisconnect_s60.cpp \ + wrapper/src/wlanqtutilsconmonwrapperinfo_s60.cpp \ + wrapper/src/wlanqtutilsconmonwrapperscan_s60.cpp \ + wrapper/src/wlanqtutilsconntestwrapper_s60.cpp \ + wrapper/src/wlanqtutilsesockwrapper_s60.cpp \ + tsrc/stubs/wlanqtutilsconnmonstub.cpp \ + tsrc/stubs/wlanqtutilsesockstub.cpp + TARGET.EPOCALLOWDLLDATA = 1 TARGET.UID3 = 0x20029F52 - SYMBIAN_PLATFORMS = WINSCW ARMV5 - MMP_RULES += mmpRuleDeffile + defFilePath = . + BLD_INF_RULES.prj_exports += "rom/wlanqtutilities.iby CORE_MW_LAYER_IBY_EXPORT_PATH(wlanqtutilities.iby)" - BLD_INF_RULES.prj_exports += "base/inc/wlanqtutils.h |../inc/wlanqtutils.h" \ - "base/inc/wlanqtutilscommon.h |../inc/wlanqtutilscommon.h" \ - "base/inc/wlanqtutilswlanap.h |../inc/wlanqtutilswlanap.h" \ - "base/inc/wlanqtutilsiap.h |../inc/wlanqtutilsiap.h" \ - "base/inc/wlanqtutilswlaniap.h |../inc/wlanqtutilswlaniap.h" + BLD_INF_RULES.prj_exports += \ + "base/inc/wlanqtutils.h |../inc/wlanqtutils.h" \ + "base/inc/wlanqtutilsap.h |../inc/wlanqtutilsap.h" \ + "base/inc/wlanqtutilsiap.h |../inc/wlanqtutilsiap.h" + + # S60 libraries + LIBS += -lconnmon -lesock -lextendedconnpref -lnetmeta -lictsclientinterface } - -symbian*::LIBS += -lconnmon -lcmmanager -lesock -lcommdb -lictsclientinterface \ No newline at end of file diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilscmmwrapper.h --- a/wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilscmmwrapper.h Fri May 14 10:30:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,95 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* 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". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -*/ - -#ifndef WLANQTUTILSCMMWRAPPER_H_ -#define WLANQTUTILSCMMWRAPPER_H_ - -// INCLUDES -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -// FORWARD DECLARATIONS -class CmmWrapperPrivate; -class WlanQtUtilsIap; -class WlanQtUtilsWlanIap; -class WlanQtUtilsWlanAp; - -// CLASS DECLARATION - -/** - * CmmWrapper class. - */ -class CmmWrapper : public QObject -{ -Q_OBJECT - -public: // Constructor and destructor - - /** - * Default constructor - */ - CmmWrapper( QObject *parent = 0 ); - - /** - * Destructor - */ - ~CmmWrapper(); - -public: - - /** - * Fetch all IAPs - * - * @param[in/out] iapList List of IAPs - */ - int fetchIaps( QList& iapList ); - - /** - * Create a new WLAN IAP as uncategorized - * - * @param[in] wlanAp Information about the WLAN AP - * @return New IAP class - */ - WlanQtUtilsWlanIap *createWlanIap(const WlanQtUtilsWlanAp *wlanAp); - - /** - * Move IAP to the Internet SNAP - * - * @param[in] iapId Which IAP to move - * @param[in] snapId Where to move it - */ - void moveIapToInternetSnap(int iapId); - -private: // Data - - /** - * d_ptr pointer to CmmWrapperPrivate - * Owned by CmmWrapper object, instantiated in - * constructor. - */ - CmmWrapperPrivate *d_ptr; -}; - -QT_END_HEADER - -QT_END_NAMESPACE - -#endif /* WLANQTUTILSCMMWRAPPER_H_ */ - -// End of file diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilscmmwrapper_s60_p.h --- a/wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilscmmwrapper_s60_p.h Fri May 14 10:30:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,156 +0,0 @@ -/* - * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * This component and the accompanying materials are made available - * 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". - * - * Initial Contributors: - * Nokia Corporation - initial contribution. - * - * Contributors: - * - * Description: - */ - -#ifndef WLANQTUTILSCMMWRAPPER_S60_P_H_ -#define WLANQTUTILSCMMWRAPPER_S60_P_H_ - -// INCLUDES -#include -#include "wlanqtutilscommon.h" - -QT_BEGIN_NAMESPACE - -//definitions taken from cmpluginwlandef.h and cmpluginpacketdatadef.h -const TUint KUidPacketDataBearerType = 0x10207378; - -class WlanQtUtilsIap; -class WlanQtUtilsWlanIap; - -// CLASS DECLARATION - -/** - * CmmWrapperPrivate class. - */ -class CmmWrapperPrivate - { - -public: - - /** - * Default constructor - */ - CmmWrapperPrivate(CmmWrapper *wrapper); - - /** - * Destructor - */ - ~CmmWrapperPrivate(); - -public: - // New functions - - /** - * Fetches IAPs from CMM - * - * @iapList, list of IAPs - * @return error code - */ - int fetchIaps(QList &iapList); - - /** - * Creates a new WLAN IAP through CMM - * - * @aWlanAp WLAN parameters to store in IAP - * @return Created IAP, NULL in error cases - */ - WlanQtUtilsWlanIap *createWlanIap(const WlanQtUtilsWlanAp *aWlanAp); - - /** - * Move IAP to the Internet SNAP - * - * @param[in] iapId Which IAP to move - */ - void moveIapToInternetSnap(TInt32 aIapId); - -private: - - /** - * Fetches IAPs from CMM, leaves in error cases - * - * @iapList, list of IAPs - */ - void fetchIapsL(QList &iapList); - - /** - * Creates a new WLAN IAP through CMM, leaves in error cases - * - * @aWlanAp WLAN parameters to store in IAP - * @return Created IAP - */ - WlanQtUtilsWlanIap *createWlanIapL(const WlanQtUtilsWlanAp *aWlanAp); - - /** - * Move IAP to the Internet SNAP, leaves in error cases - * - * @param[in] iapId Which IAP to move - */ - void moveIapToInternetSnapL(TInt32 aIapId); - - /** - * Fetches IAPs of the given SNAP from CMM - * - * @param[in] aSnapId ID of the SNAP whose IAPS are requested - * @param[out] aSnapsIapList Where to store IAPs - * @return Error code - */ - int getIapListFromSnap( - TUint32 aSnapId, - QList& aSnapsIapList); - - /** - * Fetches IAP information of the given ConnectionMethod from CMM - * - * @param[in] aConnectionMethod Where to read info - * @return Created IAP - */ - WlanQtUtilsIap *getIapInfoL( - RCmConnectionMethodExt aConnectionMethod); - - /** - * Maps CMManager's WLAN security mode into WlanQtUtilsWlanSecMode. - * - * @aSecModeFromCmManager security mode read from CMManager - * @return: Mapped security mode to be used in Wlan Qt Utilities. - */ - WlanQtUtilsWlanSecMode cmm2WlanQtUtilsSecModeMap(int aSecModeFromCmManager); - - /** - * Maps WlanQtUtilsWlanSecMode into CMManager's WLAN security mode. - * - * @aWlanQtUtilsSecMode: Wlan Qt Utilities' WLAN security mode - * @return: Mapped CMManager's WLAN security mode. - */ - int wlanQtUtils2CmmSecModeMap(WlanQtUtilsWlanSecMode aWlanQtUtilsSecMode); - -private: - // Data - - /** - * q_ptr pointer to CmmWrapper - * Owned by CmmWrapperPrivate object, instantiated in - * constructor. - */ - CmmWrapper *q_ptr; - - RCmManagerExt iCmManagerExt; - - }; - -QT_END_NAMESPACE - -#endif /* WLANQTUTILSCMMWRAPPER_S60_P_H_ */ - -// End of file diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsconmonwrapper.h --- a/wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsconmonwrapper.h Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsconmonwrapper.h Mon May 24 21:11:39 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -12,173 +12,126 @@ * Contributors: * * Description: -* +* Wrapper for Symbian Connection Monitor library. */ #ifndef WLANQTUTILSCONMONWRAPPER_H #define WLANQTUTILSCONMONWRAPPER_H -// INCLUDES +// System includes + #include #include -#include - -QT_BEGIN_HEADER +#include +#include -QT_BEGIN_NAMESPACE +// User includes -#include "wlanqtutilscommon.h" +#include "wlanqtutils.h" + +// Forward declarations -// FORWARD DECLARATIONS -class WlanQtUtilsWlanAp; -class WlanQtUtilsActiveConn; -class ConnMonScanWlanAps; -class ConnMonConnInfo; -class ConnMonConnDisconnect; +class WlanQtUtilsAp; +class WlanQtUtilsConnection; +class WlanQtUtilsConMonWrapperScan; +class WlanQtUtilsConMonWrapperInfo; +class WlanQtUtilsConMonWrapperDisconnect; -// CLASS DECLARATION +// External data types + +// Constants -/** -* ConMonWrapper class. -*/ -class ConMonWrapper : public QObject +// Class declaration + +class WlanQtUtilsConMonWrapper : public QObject { Q_OBJECT public: - - /** - * Constructor. - */ - ConMonWrapper(QObject *parent = 0); - - /** - * Destructor. - */ - ~ConMonWrapper(); - /** - * Requests wlan scanning - * - * @return ???. - */ - int scanAvailableWlanAPs(); - - /** - * Emits available WLANs to engine. - * - * @param[in] availableWlanAPs Available WLAN access points found in scan. - */ - void emitAvailableWlans(QList &availableWlanAPs); + // Data types - /** - * Emits signal indicating that a new connection has been created. - * - * @param[in] connectionId Connection ID. - */ - void emitConnCreatedEvent(uint connectionId); + WlanQtUtilsConMonWrapper(QObject *parent = 0); - /** - * Emits signal indicating that a connection has been deleted. - * - * @param[in] connectionId Connection ID. - */ - void emitConnDeletedEvent(uint connectionId); - - /** - * Emits signal indicating that status of a connection has changed. - * - * @param[in] connectionId Connection ID. - * @param[in] connectionStatus Connection status. - */ - void emitConnStatusEvent(uint connectionId, WlanQtUtilsConnectionStatus connectionStatus); + ~WlanQtUtilsConMonWrapper(); - /** - * Return active connection information. - * - * @return Information of active connection, if one exists. - */ - WlanQtUtilsActiveConn *activeConnection(); + void scanAvailableWlanAPs(); + + void stopScan(); + + WlanQtUtilsConnection *activeConnection() const; - /** - * Returns information of a connection with the given connection ID. - * - * @param[in] connectionId Connection ID. - * @return Information of the given connection, if one exists. - */ - WlanQtUtilsActiveConn *connectionInfo(uint connectionId); + WlanQtUtilsConnection *connectionInfo(uint connectionId) const; - /** - * Stops given connection regardless of how many applications are using it. - * - * @param[in] iapId IAP ID to disconnect. - */ void disconnectIap(int iapId); signals: - /** - * Signal indicating available WLAN access points. - * - * @param[in] availableWlans Available WLAN access points found in scan. + /*! + Signal indicating available WLAN access points. + + @param [in] availableWlans Available WLAN access points found in scan. */ - void availableWlanApsFromWrapper(QList &availableWlans); + void availableWlanApsFromWrapper( + QList< QSharedPointer > &availableWlans); - /** - * Signal indicating that a new connection has been created. - * - * @param[in] connectionId Connection ID. + /*! + Signal indicating that a new connection has been created. + + @param [in] connectionId Connection ID. */ void connCreatedEventFromWrapper(uint connectionId); - /** - * Signal indicating that a connection has been deleted. - * - * @param[in] connectionId Connection ID. + /*! + Signal indicating that a connection has been deleted. + + @param [in] connectionId Connection ID. */ void connDeletedEventFromWrapper(uint connectionId); - /** - * Signal indicating that status of a connection has changed. - * - * @param[in] connectionId Connection ID. - * @param[in] connectionStatus Connection status. + /*! + Signal indicating that status of a connection has changed. + + @param [in] connectionId Connection ID. + @param [in] connectionStatus Connection status. */ - void connStatusEventFromWrapper(uint connectionId, WlanQtUtilsConnectionStatus connectionStatus); + void connStatusEventFromWrapper( + uint connectionId, + WlanQtUtils::ConnStatus connectionStatus); -private: // Data - - /** - * d_ptrScanWlans pointer to ConMonWrapperPrivate - * Owned by ConMonWrapper object, instantiated in - * constructor. - */ - ConnMonScanWlanAps *d_ptrScanWlans; +public slots: + +protected: + +protected slots: + +private: + +private slots: + +private: // data - /** - * d_ptrConnInfo pointer to ConMonWrapperPrivate - * Owned by ConMonWrapper object, instantiated in - * constructor. - */ - ConnMonConnInfo *d_ptrConnInfo; + // Owned data + + //! Private implementation of scan interface + QScopedPointer d_ptrScan; + + //! Private implementation of connection info interface + QScopedPointer d_ptrInfo; - /** - * d_ptrConnDisconnect pointer to ConMonWrapperPrivate - * Owned by ConMonWrapper object, instantiated in - * constructor. - */ - ConnMonConnDisconnect *d_ptrConnDisconnect; + //! Private implementation of connection disconnect interface + QScopedPointer d_ptrDisconnect; -private: // Friend classes - // TestWlanQtUtils is defined as a friend class in order to be able to - // call event handlers of wrappers. + // Friend classes + + // These are defined as friend classes in order to be able to emit + // public signals directly from private implementation classes. + friend class WlanQtUtilsConMonWrapperScan; + friend class WlanQtUtilsConMonWrapperInfo; + + // This is defined as a friend class in order to be able to call + // event handlers of wrappers from unit tests. friend class TestWlanQtUtils; }; -QT_END_HEADER - -QT_END_NAMESPACE - -#endif /* WLANQTUTILSCONMONWRAPPER_H */ - -// End of file +#endif // WLANQTUTILSCONMONWRAPPER_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsconmonwrapper_s60_p.h --- a/wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsconmonwrapper_s60_p.h Fri May 14 10:30:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,293 +0,0 @@ -/* - * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * This component and the accompanying materials are made available - * 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". - * - * Initial Contributors: - * Nokia Corporation - initial contribution. - * - * Contributors: - * - * Description: - * This is a header file for following classes: - * ConnMonScanWlanAps. - */ - -#ifndef WLANQTUTILSCONMONWRAPPER_S60_P_H_ -#define WLANQTUTILSCONMONWRAPPER_S60_P_H_ - -// INCLUDES -#include -#include -#include "wlanqtutilscommon.h" - -class ConMonWrapper; - -QT_BEGIN_NAMESPACE - -// CLASS DECLARATION - -/** - * ConnMonScanWlanAps class. - */ -class ConnMonScanWlanAps : public CActive - { - -public: - // Constructor and destructor - - /** - * Default constructor - */ - ConnMonScanWlanAps(ConMonWrapper *wrapper); - - /** - * Destructor - */ - ~ConnMonScanWlanAps(); - -public: - // New functions - - /** - * scanAvailableWlanAPs - * scans all available WLAN APs - * @return error code - */ - int scanAvailableWlanAPs(); - -private: - // From CActive - - /** - * Implements cancellation of an outstanding request. - */ - void DoCancel(); - - /** - * Handles an active object's request completion event. - */ - void RunL(); - - /** - * conMon2WlanQtUtilsSecModeMap - * Maps Connection monitor's WLAN security mode value into WlanQtUtilsWlanSecMode. - * @aSecMode: security mode, ConnMon style, - * @return: security mode, Wlan Qt Utilities style. - */ - WlanQtUtilsWlanSecMode conMon2WlanQtUtilsSecModeMap(TUint aSecMode); - -private: - // Data - - /** - * q_ptr pointer to ConMonWrapper - * Owned by ConnMonScanWlanAps object, instantiated in - * constructor. - */ - ConMonWrapper *q_ptr; - - /** - * Handle to Connection Monitor Server - */ - RConnectionMonitor iMonitor; - - /** - * Scan package used with Connection Monitor Server scan request - * Owned by ConnMonScanWlanAps object. - */ - CConnMonWlanNetworksPtrArrayPckg* wlanBuf; - - /** - * wlan pointer variable used with Connection Monitor Server scan request - */ - TPtr wlanPtr; - }; - -// CLASS DECLARATION - -/** - * ConnMonConnInfo class. - */ -class ConnMonConnInfo : public MConnectionMonitorObserver - { -public: - // Constructor and destructor - - /** - * Default constructor - */ - ConnMonConnInfo(ConMonWrapper *wrapper); - - /** - * Destructor - */ - ~ConnMonConnInfo(); - -public: - // New functions - - /** - * Return active connection information. - * - * @return Information of active connection, if one exists. - */ - WlanQtUtilsActiveConn *activeConnection(); - - /** - * Returns information of a connection with the given connection ID. - * - * @param[in] connectionId Connection ID. - * @return Information of the given connection, if one exists. - */ - WlanQtUtilsActiveConn *connectionInfo(uint connectionId); - - /** - * Updates information of a given active connection. Missing information will be filled in - * and information that is dynamic in nature will be updated. - * - * @param[in] activeConn Current data of an active connection which will be updated. - * Connection ID and bearer type have to be valid. - */ - void activeConnInfoUpdate( WlanQtUtilsActiveConn *activeConn ); - -private: - // New private functions - - /** - * Starts monitoring observer events - */ - void StartMonitoringL(); - - /** - * Stops monitoring observer events - */ - void StopMonitoring(); - - /** - * Event method is called every time an event occures - */ - void EventL(const CConnMonEventBase& aConnMonEvent); - - /** - * Maps Connection Monitor's WLAN connection mode value into - * WlanQtUtilsWlanConnMode. - * - * @param aConnMode Connection mode in Connection Monitor's style. - * @return Connection mode in Wlan Qt Utilities style. - */ - static WlanQtUtilsWlanConnMode connMon2WlanQtUtilsConnModeMap(TInt aConnMode); - - /** - * Maps Connection Monitor's connection status value into WlanQtUtilsConnectionStatus. - * - * @param aConnectionStatus Connection status as used by Connection Monitor server. - * These status are defined in nifvar.h. - * @return Connection status in Wlan Qt Utilities style. - */ - static WlanQtUtilsConnectionStatus connMon2WlanQtUtilsConnectionStatusMap(TInt aConnectionStatus); - - /** - * Maps Connection Monitor's bearer type value into WlanQtUtilsBearerType. - * - * @param aBearerType Bearer type as used by Connection Monitor server. - * @return Bearer type in Wlan Qt Utilities style. - */ - static WlanQtUtilsBearerType connMon2WlanQtUtilsBearerTypeMap(TInt aBearerType); - - bool isWlan(uint connectionId); - -private: - // Data - - /** - * q_ptr pointer to ConMonWrapper - * Owned by ConMonWrapperPrivate object, instantiated in - * constructor. - */ - ConMonWrapper *q_ptr; - - /** Handle to Connection Monitor Server. */ - RConnectionMonitor iMonitor; - - /** Request status. */ - TRequestStatus iStatus; - - /** Indicates whether connection monitoring is ON. */ - TBool iMonitoring; - -private: // Friend classes - - // TestWlanQtUtils is defined as a friend class in order to be able to - // call event handlers of wrappers. - friend class TestWlanQtUtils; - }; - -// CLASS DECLARATION - -/** - * ConnMonConnDisconnect class. - */ -class ConnMonConnDisconnect : public CActive - { - -public: - // Constructor and destructor - - /** - * Default constructor - */ - ConnMonConnDisconnect(ConMonWrapper *wrapper); - - /** - * Destructor - */ - ~ConnMonConnDisconnect(); - -public: - // New functions - - /** - * disconnectConnection - * Stop connection - */ - void disconnectConnection(int iapId); - -private: - // From CActive - - /** - * Implements cancellation of an outstanding request. - */ - void DoCancel(); - - /** - * Handles an active object's request completion event. - */ - void RunL(); - -private: - // Data - - /** - * q_ptr pointer to ConMonWrapper - * Owned by ConMonWrapperPrivate object, instantiated in - * constructor. - */ - ConMonWrapper *q_ptr; - - /** - * Handle to Connection Monitor Server - */ - RConnectionMonitor iMonitor; - }; - -QT_END_NAMESPACE - -#endif /* WLANQTUTILSCONMONWRAPPER_S60_P_H_ */ - -// End of file - diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsconmonwrapperdisconnect_s60_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsconmonwrapperdisconnect_s60_p.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Private implementation of wrapper for Symbian Connection Monitor +* library's connection disconnect interface. +*/ + +#ifndef WLANQTUTILSCONMONWRAPPERDISCONNECT_S60_P_H +#define WLANQTUTILSCONMONWRAPPERDISCONNECT_S60_P_H + +// System includes + +#include + +// User includes + +// Forward declarations + +class WlanQtUtilsConMonWrapper; + +// External data types + +// Constants + +// Class declaration + +class WlanQtUtilsConMonWrapperDisconnect +{ +public: + + // Data types + + WlanQtUtilsConMonWrapperDisconnect(WlanQtUtilsConMonWrapper *wrapper); + + ~WlanQtUtilsConMonWrapperDisconnect(); + + void DisconnectConnection(int iapId); + +protected: + +private: + +private: // data + + // Owned data + + RConnectionMonitor iMonitor; //!< Handle to Connection Monitor Server + + // Not owned data + + //! Public implementation to report progress to + WlanQtUtilsConMonWrapper *q_ptr; + + // Friend classes +}; + +#endif // WLANQTUTILSCONMONWRAPPERDISCONNECT_S60_P_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsconmonwrapperinfo_s60_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsconmonwrapperinfo_s60_p.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Private implementation of wrapper for Symbian Connection Monitor +* library's connection info interface. +*/ + +#ifndef WLANQTUTILSCONMONWRAPPERINFO_S60_P_H +#define WLANQTUTILSCONMONWRAPPERINFO_S60_P_H + +// System includes + +#include + +// User includes + +#include "wlanqtutils.h" + +// Forward declarations + +class WlanQtUtilsConnection; +class WlanQtUtilsConMonWrapper; + +// External data types + +// Constants + +// Class declaration + +class WlanQtUtilsConMonWrapperInfo : public MConnectionMonitorObserver +{ +public: + + // Data types + + WlanQtUtilsConMonWrapperInfo(WlanQtUtilsConMonWrapper *wrapper); + + ~WlanQtUtilsConMonWrapperInfo(); + + WlanQtUtilsConnection *ActiveConnection(); + + WlanQtUtilsConnection *ConnectionInfo(uint connectionId); + +protected: + +private: + + TBool ConnectionInfoDetails(WlanQtUtilsConnection *connection); + + void EventL(const CConnMonEventBase& connMonEvent); + + WlanQtUtils::ConnStatus ConnMonConnStatusMap(TInt connStatus); + + TBool IsWlanConnection(TUint connectionId); + +private: // data + + // Owned data + + RConnectionMonitor iMonitor; //!< Handle to Connection Monitor Server + + TRequestStatus iStatus; //!< Request status + + //! ID of the connection we are currently monitoring + TUint iMonitoringConnection; + + // Not owned data + + //! Public implementation to report progress to + WlanQtUtilsConMonWrapper *q_ptr; + + // Friend classes + + // TestWlanQtUtils is defined as a friend class in order to be able to + // call event handlers of wrappers. + friend class TestWlanQtUtils; +}; + +#endif // WLANQTUTILSCONMONWRAPPERINFO_S60_P_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsconmonwrapperscan_s60_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsconmonwrapperscan_s60_p.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Private implementation of wrapper for Symbian Connection Monitor +* library's scan interface. +*/ + +#ifndef WLANQTUTILSCONMONWRAPPERSCAN_S60_P_H +#define WLANQTUTILSCONMONWRAPPERSCAN_S60_P_H + +// System includes + +#include +#include + +// User includes + +// Forward declarations + +class WlanQtUtilsAp; +class WlanQtUtilsConMonWrapper; + +// External data types + +// Constants + +// Class declaration + +class WlanQtUtilsConMonWrapperScan : public CActive +{ +public: + + // Data types + + WlanQtUtilsConMonWrapperScan(WlanQtUtilsConMonWrapper *wrapper); + + ~WlanQtUtilsConMonWrapperScan(); + + void ScanAvailableWlanAPs(); + + void StopScan(); + +protected: + +private: + + void DoCancel(); + + void RunL(); + + void StoreConMonSecMode( + QSharedPointer ap, + TUint conMonSecMode); + + void StoreConMonConnMode( + QSharedPointer ap, + TInt conMonConnMode); + +private: // data + + // Owned data + + RConnectionMonitor iMonitor; //!< Handle to Connection Monitor Server + + //! Scan package used with Connection Monitor Server scan request + CConnMonWlanNetworksPtrArrayPckg* iWlanBuf; + + //! wlan pointer used with Connection Monitor Server scan request + TPtr iWlanPtr; + + /*! + Has scanning been cancelled by client, are we allowed to report + results? + */ + TBool iScanCancelled; + + // Not owned data + + //! Public implementation to report progress to + WlanQtUtilsConMonWrapper *q_ptr; + + // Friend classes +}; + +#endif // WLANQTUTILSCONMONWRAPPERSCAN_S60_P_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsconntestwrapper.h --- a/wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsconntestwrapper.h Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsconntestwrapper.h Mon May 24 21:11:39 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -19,10 +19,7 @@ #define WLANQTUTILSCONNTESTWRAPPER_H_ #include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE +#include class ConnTestWrapperPrivate; @@ -83,11 +80,7 @@ * d_ptr pointer to ConnTestWrapperPrivate * Owned by ConnTestWrapper object, instantiated in constructor. */ - ConnTestWrapperPrivate *d_ptr_; + QScopedPointer d_ptr_; }; -QT_END_HEADER - -QT_END_NAMESPACE - #endif /* WLANQTUTILSCONNTESTWRAPPER_H_ */ diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsconntestwrapper_s60_p.h --- a/wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsconntestwrapper_s60_p.h Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsconntestwrapper_s60_p.h Mon May 24 21:11:39 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsesockwrapper.h --- a/wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsesockwrapper.h Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsesockwrapper.h Mon May 24 21:11:39 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -12,74 +12,72 @@ * Contributors: * * Description: -* This is a header file for EsockWrapper class. +* Wrapper for Symbian Esock library. */ -#ifndef ESOCKWRAPPER_H_ -#define ESOCKWRAPPER_H_ +#ifndef WLANQTUTILSESOCKWRAPPER_H +#define WLANQTUTILSESOCKWRAPPER_H + +// System includes #include +#include -QT_BEGIN_HEADER +// User includes -QT_BEGIN_NAMESPACE +// Forward declarations + +class WlanQtUtilsEsockWrapperPrivate; -class EsockWrapperPrivate; +// External data types + +// Constants -/** - * Wrapper for connection handling. - */ -class EsockWrapper: public QObject +// Class declaration + +class WlanQtUtilsEsockWrapper: public QObject { Q_OBJECT public: - /** - * Default constructor - */ - EsockWrapper(QObject *parent = 0); + // Data types + + WlanQtUtilsEsockWrapper(QObject *parent = 0); + + ~WlanQtUtilsEsockWrapper(); - /** - * Destructor. - */ - ~EsockWrapper(); - -public: + void updateConnection(bool isOpened, int platformStatusCode); + + int lastStatusCode(); - /** - * - */ - void updateConnection(bool isOpened); +signals: + + void connectionStatusFromWrapper(bool isOpened); public slots: - - /** - * Starts connection creation to given IAP. - * - * @param[in] iapId IAP ID. - */ + void connectIap(int iapId); + + void disconnectIap(); + +protected: + +protected slots: + +private: + +private slots: + +private: // data - /** - * Disconnects connection. - */ - void disconnectIap(); + //! Private implementation + QScopedPointer d_ptr; -signals: + //! Platform status code of latest connection creation attempt + int mLastStatusCode; - void connectionStatusFromWrapper(bool isOpened); - -private: // Data - - /** Private esock wrapper. */ - EsockWrapperPrivate *d_ptr; + // Friend classes }; -QT_END_HEADER - -QT_END_NAMESPACE - -#endif /*ESOCKWRAPPER_H_*/ - -// End of file +#endif // WLANQTUTILSESOCKWRAPPER_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsesockwrapper_s60_p.h --- a/wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsesockwrapper_s60_p.h Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanqtutilities/wrapper/inc/wlanqtutilsesockwrapper_s60_p.h Mon May 24 21:11:39 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -12,80 +12,63 @@ * Contributors: * * Description: -* +* Private implementation of wrapper for Symbian Esock library. */ -#ifndef ESOCKWRAPPER_S60_P_H_ -#define ESOCKWRAPPER_S60_P_H_ +#ifndef WLANQTUTILSESOCKWRAPPER_S60_P_H +#define WLANQTUTILSESOCKWRAPPER_S60_P_H -// INCLUDES +// System includes + #include -QT_BEGIN_NAMESPACE +// User includes -// CLASS DECLARATION +// Forward declarations + +// External data types -/** -* EsockWrapperPrivate class. -*/ -class EsockWrapperPrivate: public CActive +// Constants + +// Class declaration + +class WlanQtUtilsEsockWrapperPrivate: public CActive { -public: // Constructor and destructor - - /** - * Default constructor - */ - EsockWrapperPrivate(EsockWrapper *aWrapper); +public: - /** - * Destructor - */ - ~EsockWrapperPrivate(); + // Data types -public: // New functions + WlanQtUtilsEsockWrapperPrivate(WlanQtUtilsEsockWrapper *wrapper); - /** - * connectIap - * Starts connection creation. - */ - void connectIap(int aIapId); + ~WlanQtUtilsEsockWrapperPrivate(); + + void ConnectIap(int iapId); - /** - * dsiconnectIap - * Stops connection. - */ - void disconnectIap(); + void DisconnectIap(); -private: // Functions from base class +protected: - /** - * RunL - * Called when the scheduled function ends. - */ +private: + void RunL(); - /** - * DoCancel - * Cancels operations. - */ void DoCancel(); -private: // Data +private: // data + + // Owned data - /** - * q_ptr pointer to ConnectionWrapper - * Owned by ConnectionWrapperPrivate object, instantiated in - * constructor. - */ - EsockWrapper *q_ptr; + RSocketServ iSocketServer; //!< Socket server handle + RConnection iConnection; //!< Connection handle + TBool iConnectionActive; //!< Do we have an active connection handle? + + // Not owned data - RSocketServ iSocketServer; - RConnection iConnection; + //! Public implementation to report progress to + WlanQtUtilsEsockWrapper *q_ptr; + + // Friend classes }; -QT_END_NAMESPACE - -#endif /*ESOCKWRAPPER_S60_P_H_*/ - -// End of file +#endif // WLANQTUTILSESOCKWRAPPER_S60_P_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilscmmwrapper.cpp --- a/wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilscmmwrapper.cpp Fri May 14 10:30:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* 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". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* This is a source file for CmmWrapper class. -*/ - -// INCLUDE FILES -#include "wlanqtutilscmmwrapper.h" -#include "wlanqtutilscmmwrapper_s60_p.h" -#include "wlanqtutilsiap.h" -#include "wlanqtutilswlaniap.h" -#include "wlanqtutilswlanap.h" - -// ================= MEMBER FUNCTIONS ======================= -// - -CmmWrapper::CmmWrapper( QObject *parent ) : - QObject( parent ) -{ - d_ptr = new CmmWrapperPrivate( this ); -} - -CmmWrapper::~CmmWrapper() -{ - delete d_ptr; -} - -int CmmWrapper::fetchIaps( QList& iapList ) -{ - int error = d_ptr->fetchIaps( iapList ); - return error; -} - -WlanQtUtilsWlanIap *CmmWrapper::createWlanIap( const WlanQtUtilsWlanAp *wlanAp ) -{ - return d_ptr->createWlanIap( wlanAp ); -} - -void CmmWrapper::moveIapToInternetSnap( int iapId ) -{ - return d_ptr->moveIapToInternetSnap( iapId ); -} - -//end of file diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilscmmwrapper_s60.cpp --- a/wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilscmmwrapper_s60.cpp Fri May 14 10:30:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,388 +0,0 @@ -/* - * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * This component and the accompanying materials are made available - * 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". - * - * Initial Contributors: - * Nokia Corporation - initial contribution. - * - * Contributors: - * - * Description: - * This is a source file for CmmWrapperPrivate class. - */ - -// INCLUDE FILES -#include -#include -#include -#include -#include -#include "wlanqtutilscommon.h" -#include "wlanqtutilsiap.h" -#include "wlanqtutilswlanap.h" -#include "wlanqtutilswlaniap.h" -#include "wlanqtutilscmmwrapper.h" -#include "wlanqtutilscmmwrapper_s60_p.h" - -#ifdef WLANQTUTILS_NO_OST_TRACES_FLAG -#include -#else -#include "OstTraceDefinitions.h" -#endif -#ifdef OST_TRACE_COMPILER_IN_USE -#include "wlanqtutilscmmwrapper_s60Traces.h" -#endif - - -// =========== PRIVATE CLASS MEMBER FUNCTIONS =============== -// -// --------------------------------------------------------- -// CmmWrapperPrivate::CmmWrapperPrivate() -// Constructor -// --------------------------------------------------------- -// -CmmWrapperPrivate::CmmWrapperPrivate(CmmWrapper *wrapper) : - q_ptr(wrapper) - { - OstTraceFunctionEntry1( CMMWRAPPERPRIVATE_CMMWRAPPERPRIVATE_ENTRY, this ); - - TRAPD(err, iCmManagerExt.OpenL()); - if (err != KErrNone) { - // todo - } - - OstTraceFunctionExit1( CMMWRAPPERPRIVATE_CMMWRAPPERPRIVATE_EXIT, this ); - } - -// --------------------------------------------------------- -// CmmWrapperPrivate::CmmWrapperPrivate() -// Destructor -// --------------------------------------------------------- -// -CmmWrapperPrivate::~CmmWrapperPrivate() - { - OstTraceFunctionEntry1( CMMWRAPPERPRIVATE_CMMWRAPPERPRIVATEDESTR_ENTRY, this ); - - iCmManagerExt.Close(); - - OstTraceFunctionExit1( CMMWRAPPERPRIVATE_CMMWRAPPERPRIVATEDESTR_EXIT, this ); - } - -// --------------------------------------------------------- -// CmmWrapperPrivate::fetchIaps() -// --------------------------------------------------------- -// -int CmmWrapperPrivate::fetchIaps(QList& iapList) - { - TRAPD(err, fetchIapsL(iapList)); - return err; - } - -// --------------------------------------------------------- -// CmmWrapperPrivate::fetchIapsL() -// --------------------------------------------------------- -// -void CmmWrapperPrivate::fetchIapsL(QList& iapList) - { - OstTraceFunctionEntry1( CMMWRAPPERPRIVATE_FETCHIAPSL_ENTRY, this ); - - // reset the list, just in case - iapList.clear(); - - //Array granularity 10 - RArray destinationIdArray = RArray (10); - - destinationIdArray.Reset(); - iCmManagerExt.AllDestinationsL(destinationIdArray); - - // looping all the SNAPs through - QList snapsIapList; - for (TInt i = 0; i < destinationIdArray.Count(); i++) - { - snapsIapList.clear(); - RCmDestinationExt dest; - dest = iCmManagerExt.DestinationL(destinationIdArray[i]); - TUint32 id = dest.Id(); - - if (getIapListFromSnap(id, snapsIapList) == KErrNone) - { - iapList.append(snapsIapList); - } - } - - OstTraceFunctionExit1( CMMWRAPPERPRIVATE_FETCHIAPSL_EXIT, this ); - } - -// --------------------------------------------------------- -// CmmWrapperPrivate::createWlanIap() -// Creates a new WLAN IAP -// --------------------------------------------------------- -// -WlanQtUtilsWlanIap *CmmWrapperPrivate::createWlanIap(const WlanQtUtilsWlanAp *aWlanAp) - { - WlanQtUtilsWlanIap *iap = NULL; - - TRAPD(err, iap = createWlanIapL(aWlanAp)); - - if (err != KErrNone) - { - // Todo: trace - } - return iap; - } - -// --------------------------------------------------------- -// CmmWrapperPrivate::createWlanIapL() -// Creates a new WLAN IAP -// --------------------------------------------------------- -// -WlanQtUtilsWlanIap *CmmWrapperPrivate::createWlanIapL(const WlanQtUtilsWlanAp *aWlanAp) - { - OstTraceFunctionEntry1( CMMWRAPPERPRIVATE_CREATEWLANIAPL_ENTRY, this ); - - // Create the new IAP - RCmConnectionMethodExt plugin = iCmManagerExt.CreateConnectionMethodL( - KUidWlanBearerType); - CleanupClosePushL(plugin); - - // Convert QString to Symbian buffer - TBufC buffer(aWlanAp->ssid().utf16()); - - WlanQtUtilsWlanSecMode secMode = aWlanAp->securityMode(); - int cmManagersSecMode = wlanQtUtils2CmmSecModeMap(secMode); - - plugin.SetStringAttributeL(CMManager::ECmName, buffer); - plugin.SetStringAttributeL(CMManager::EWlanSSID, buffer); - plugin.SetIntAttributeL(CMManager::EWlanSecurityMode, cmManagersSecMode); - // Todo: other parameters such as security keys -#if 0 - // TODO the security settings API plugin needs to be initialized here - // with the iap id. - // Check if the key value has been given - QString key = aWlanAp->securityKey(); - if ( key.length() > 0 ) - { - // Set the security key values here - if ( secMode == CMManager::EWlanSecModeWpa || - secMode == CMManager::EWlanSecModeWpa2 ) - { - // Store the WPA key to the database using the security settings API - TBufC bufKey(key.utf16()); - plugin.SetStringAttributeL( CMManager::EWlanWpaPreSharedKey, bufKey ); - - } - else if ( secMode == CMManager::EWlanSecModeWep ) - { - // Store the WPA key to the database using the security settings API - TBufC bufKey(key.utf16()); - plugin.SetStringAttributeL( CMManager::EWlanWepKey1, bufKey ); - } - } -#endif - - plugin.UpdateL(); - - TInt iapId = plugin.GetIntAttributeL(CMManager::ECmIapId); - - CleanupStack::PopAndDestroy(&plugin); // Close() called on "plugin" - - // Read details of the new IAP and create the WLAN IAP class - RCmConnectionMethodExt connectionMethod = iCmManagerExt.ConnectionMethodL( iapId ); - WlanQtUtilsIap *newIap = getIapInfoL(connectionMethod); - - OstTraceFunctionExit1( CMMWRAPPERPRIVATE_CREATEWLANIAPL_EXIT, this ); - return qobject_cast(newIap); - } - -// --------------------------------------------------------- -// CmmWrapperPrivate::moveIapToInternetSnap() -// --------------------------------------------------------- -// -void CmmWrapperPrivate::moveIapToInternetSnap( TInt32 aIapId ) - { - TRAPD( err, moveIapToInternetSnapL( aIapId ) ); - if (err != KErrNone) - { - // todo: add trace - } - } - -// --------------------------------------------------------- -// CmmWrapperPrivate::moveIapToInternetSnapL() -// --------------------------------------------------------- -// -void CmmWrapperPrivate::moveIapToInternetSnapL( TInt32 aIapId ) - { - OstTraceFunctionEntry1( CMMWRAPPERPRIVATE_MOVEIAPTOINTERNETSNAPL_ENTRY, this ); - - // Read all destination(SNAP) settings into an array - RArray destinations; - CleanupClosePushL(destinations); - iCmManagerExt.AllDestinationsL(destinations); - RCmDestinationExt destination; - // Loop through each destination - for(TInt i = 0; i < destinations.Count(); i++) - { - destination = iCmManagerExt.DestinationL(destinations[i]); - CleanupClosePushL(destination); - // Internet destination will always exist in the system. - // Internet destination will have ESnapPurposeInternet set in its metadata. - if (destination.MetadataL(CMManager::ESnapMetadataPurpose) == CMManager::ESnapPurposeInternet) - { - RCmConnectionMethodExt iap = iCmManagerExt.ConnectionMethodL( aIapId ); - CleanupClosePushL( iap ); - destination.AddConnectionMethodL( iap ); - destination.UpdateL(); - CleanupStack::PopAndDestroy(); // iap - } - CleanupStack::PopAndDestroy(); // destination - } - CleanupStack::PopAndDestroy(); // destinations - - OstTraceFunctionExit1( CMMWRAPPERPRIVATE_MOVEIAPTOINTERNETSNAPL_EXIT, this ); - } - -// --------------------------------------------------------- -// CmmWrapperPrivate::getIapListFromSnap() -// --------------------------------------------------------- -// -int CmmWrapperPrivate::getIapListFromSnap(TUint32 aDestId, - QList& iapList) - { - OstTraceFunctionEntry1( CMMWRAPPERPRIVATE_GETIAPLISTFROMSNAP_ENTRY, this ); - - RCmDestinationExt dest; - TRAPD(err, dest = iCmManagerExt.DestinationL(aDestId)); - if (err != KErrNone) - { - OstTraceFunctionExit1( CMMWRAPPERPRIVATE_GETIAPLISTFROMSNAP_EXIT, this ); - return err; - } - - // Copy IAPs from the SNAP into iapList. - int destIapCount = dest.ConnectionMethodCount(); - for (TInt i = 0; i < destIapCount; i++) - { - WlanQtUtilsIap* iap = NULL; - TRAP(err, iap = getIapInfoL(dest.ConnectionMethodL(i))); - - if (err == KErrNone) - { - iapList.append(iap); - } - } - - OstTraceFunctionExit1( DUP1_CMMWRAPPERPRIVATE_GETIAPLISTFROMSNAP_EXIT, this ); - return err; - } - -// --------------------------------------------------------- -// CmmWrapperPrivate::getIapInfoL() -// --------------------------------------------------------- -// -WlanQtUtilsIap *CmmWrapperPrivate::getIapInfoL( - RCmConnectionMethodExt aConnectionMethod) - { - OstTraceFunctionEntry1( CMMWRAPPERPRIVATE_GETIAPINFOL_ENTRY, this ); - - TUint iapId = aConnectionMethod.GetIntAttributeL(CMManager::ECmIapId); - - TUint netId = aConnectionMethod.GetIntAttributeL(CMManager::ECmNetworkId); - - HBufC* iapName = aConnectionMethod.GetStringAttributeL(CMManager::ECmName); - - TUint iapBearerType = aConnectionMethod.GetIntAttributeL(CMManager::ECmBearerType); - - QString name = QString::fromUtf16(iapName->Ptr(), iapName->Length()); - WlanQtUtilsBearerType bearer; - - WlanQtUtilsIap* newIap = NULL; - if (iapBearerType == KUidPacketDataBearerType) - { - bearer = WlanQtUtilsBearerTypeCellular; - newIap = new WlanQtUtilsIap(iapId, netId, name, bearer); - } - else - { - TInt secModeFromCmManager = - aConnectionMethod.GetIntAttributeL(CMManager::EWlanSecurityMode); - WlanQtUtilsWlanSecMode secMode = cmm2WlanQtUtilsSecModeMap(secModeFromCmManager); - bearer = WlanQtUtilsBearerTypeWlan; - //Note ssid is set same as iap name - WlanQtUtilsWlanIap* wlanIap = - new WlanQtUtilsWlanIap(iapId, netId, name, bearer, name, secMode); - newIap = wlanIap; - } - - OstTraceFunctionExit1( CMMWRAPPERPRIVATE_GETIAPINFOL_EXIT, this ); - return newIap; - } - -// --------------------------------------------------------- -// CmmWrapperPrivate::cmm2WlanQtUtilsSecModeMap() -// Maps CMManager's WLAN security mode into WlanQtUtilsWlanSecMode. -// CMManager uses sec mode type TConnMonSecurityMode defined -// in rconnmon.h. -// --------------------------------------------------------- -// -WlanQtUtilsWlanSecMode CmmWrapperPrivate::cmm2WlanQtUtilsSecModeMap(int aSecModeFromCmManager) - { - WlanQtUtilsWlanSecMode ret; - switch (aSecModeFromCmManager) - { - case CMManager::EWlanSecModeWep: - ret = WlanQtUtilsWlanSecModeWep; - break; - case CMManager::EWlanSecMode802_1x: - ret = WlanQtUtilsWlanSecMode802_1x; - break; - case CMManager::EWlanSecModeWpa: - ret = WlanQtUtilsWlanSecModeWpa; - break; - case CMManager::EWlanSecModeWpa2: - ret = WlanQtUtilsWlanSecModeWpa2; - break; - default: - ret = WlanQtUtilsWlanSecModeOpen; - break; - } - - return ret; - } - -// --------------------------------------------------------- -// Maps WlanQtUtilsWlanSecMode into CMManager's WLAN security mode -// (TWlanSecMode, defined in cmpluginwlandef.h). -// --------------------------------------------------------- -// -int CmmWrapperPrivate::wlanQtUtils2CmmSecModeMap(WlanQtUtilsWlanSecMode aWlanQtUtilsSecMode) - { - int ret; - switch (aWlanQtUtilsSecMode) - { - case WlanQtUtilsWlanSecModeWep: - ret = CMManager::EWlanSecModeWep; - break; - case WlanQtUtilsWlanSecMode802_1x: - ret = CMManager::EWlanSecMode802_1x; - break; - case WlanQtUtilsWlanSecModeWpa: - ret = CMManager::EWlanSecModeWpa; - break; - case WlanQtUtilsWlanSecModeWpa2: - ret = CMManager::EWlanSecModeWpa2; - break; - default: - ret = CMManager::EWlanSecModeOpen; - break; - } - - return ret; - } - -//end of file - diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsconmonwrapper.cpp --- a/wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsconmonwrapper.cpp Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsconmonwrapper.cpp Mon May 24 21:11:39 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -12,68 +12,109 @@ * Contributors: * * Description: -* +* Wrapper for Symbian Connection Monitor library. +*/ + +// System includes + +#include +#include + +// User includes + +#include "wlanqtutilsconmonwrapperdisconnect_s60_p.h" +#include "wlanqtutilsconmonwrapperinfo_s60_p.h" +#include "wlanqtutilsconmonwrapperscan_s60_p.h" +#include "wlanqtutilsconmonwrapper.h" + +/*! + \class WlanQtUtilsConMonWrapper + \brief Wrapper for Symbian Connection Monitor library. + + Provides functionality to scan WLAN networks, to retrieve connection + information, and to disconnect connections. */ -// INCLUDE FILES -#include -#include -#include "wlanqtutilsconmonwrapper.h" -#include "wlanqtutilsconmonwrapper_s60_p.h" +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== -// ================= MEMBER FUNCTIONS ======================= +/*! + Constructor. + + @param [in] parent Parent object. +*/ -ConMonWrapper::ConMonWrapper(QObject *parent) - : QObject(parent) +WlanQtUtilsConMonWrapper::WlanQtUtilsConMonWrapper(QObject *parent) : + QObject(parent), + d_ptrScan(new WlanQtUtilsConMonWrapperScan(this)), + d_ptrInfo(new WlanQtUtilsConMonWrapperInfo(this)), + d_ptrDisconnect(new WlanQtUtilsConMonWrapperDisconnect(this)) { - d_ptrScanWlans = new ConnMonScanWlanAps(this); - d_ptrConnInfo = new ConnMonConnInfo(this); - d_ptrConnDisconnect = new ConnMonConnDisconnect(this); } -ConMonWrapper::~ConMonWrapper() +/*! + Destructor. +*/ + +WlanQtUtilsConMonWrapper::~WlanQtUtilsConMonWrapper() { - delete d_ptrScanWlans; - delete d_ptrConnInfo; - delete d_ptrConnDisconnect; -} - -int ConMonWrapper::scanAvailableWlanAPs() -{ - return d_ptrScanWlans->scanAvailableWlanAPs(); } -void ConMonWrapper::emitAvailableWlans(QList &availableWlanAPs) +/*! + Start a WLAN scan. +*/ + +void WlanQtUtilsConMonWrapper::scanAvailableWlanAPs() { - emit availableWlanApsFromWrapper(availableWlanAPs); + d_ptrScan->ScanAvailableWlanAPs(); } -void ConMonWrapper::emitConnCreatedEvent(uint connectionId) +/*! + Stop a (possibly) ongoing WLAN scan. +*/ + +void WlanQtUtilsConMonWrapper::stopScan() { - emit connCreatedEventFromWrapper(connectionId); -} - -void ConMonWrapper::emitConnDeletedEvent(uint connectionId) -{ - emit connDeletedEventFromWrapper(connectionId); + d_ptrScan->StopScan(); } -void ConMonWrapper::emitConnStatusEvent(uint connectionId, WlanQtUtilsConnectionStatus connectionStatus) +/*! + Return active connection information. + + @return Information of active connection, 0 if not found. +*/ + +WlanQtUtilsConnection *WlanQtUtilsConMonWrapper::activeConnection() const { - emit connStatusEventFromWrapper(connectionId, connectionStatus); -} - -WlanQtUtilsActiveConn *ConMonWrapper::activeConnection() -{ - return d_ptrConnInfo->activeConnection(); + return d_ptrInfo->ActiveConnection(); } -WlanQtUtilsActiveConn* ConMonWrapper::connectionInfo(uint connectionId) +/*! + Returns information of a connection with the given connection ID. + + @param [in] connectionId Connection ID. + + @return Information of the given connection, 0 if not found. +*/ + +WlanQtUtilsConnection* WlanQtUtilsConMonWrapper::connectionInfo( + uint connectionId) const { - return d_ptrConnInfo->connectionInfo(connectionId); + return d_ptrInfo->ConnectionInfo(connectionId); } -void ConMonWrapper::disconnectIap(int iapId) +/*! + Stops given connection regardless of how many applications are using it. + + @param [in] iapId IAP ID to disconnect. +*/ + +void WlanQtUtilsConMonWrapper::disconnectIap(int iapId) { - d_ptrConnDisconnect->disconnectConnection(iapId); + d_ptrDisconnect->DisconnectConnection(iapId); } diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsconmonwrapper_s60.cpp --- a/wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsconmonwrapper_s60.cpp Fri May 14 10:30:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,666 +0,0 @@ -/* - * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * This component and the accompanying materials are made available - * 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". - * - * Initial Contributors: - * Nokia Corporation - initial contribution. - * - * Contributors: - * - * Description: - * This is a source file for following classes: - * ConnMonScanWlanAps, - * ConnMonConnInfo, - * ConnMonConnDisconnect - */ - -// INCLUDE FILES -#include -#include -#include - -#include "wlanqtutilscommon.h" -#include "wlanqtutilswlanap.h" -#include "wlanqtutilsactiveconn.h" -#include "wlanqtutilsconmonwrapper.h" -#include "wlanqtutilsconmonwrapper_s60_p.h" - -#ifdef WLANQTUTILS_NO_OST_TRACES_FLAG -#include -#else -#include "OstTraceDefinitions.h" -#endif -#ifdef OST_TRACE_COMPILER_IN_USE -#include "wlanqtutilsconmonwrapper_s60Traces.h" -#endif - - -// =========== PRIVATE CLASS MEMBER FUNCTIONS =============== -// -// --------------------------------------------------------- -// ConnMonScanWlanAps::ConnMonScanWlanAps() -// Constructor -// --------------------------------------------------------- -// -ConnMonScanWlanAps::ConnMonScanWlanAps(ConMonWrapper *wrapper) : - CActive(EPriorityStandard), q_ptr(wrapper), wlanPtr(0, 0) - { - OstTraceFunctionEntry1( CONNMONSCANWLANAPS_CONNMONSCANWLANAPS_ENTRY, this ); - - CActiveScheduler::Add(this); - // TBD: What if this leaves? - // Beware! iConnMon.ConnectL() can - // both leave AND return an error code.. - // User::LeaveIfError( iMonitor.ConnectL() ); - iMonitor.ConnectL(); - - OstTraceFunctionExit1( CONNMONSCANWLANAPS_CONNMONSCANWLANAPS_EXIT, this ); - } - -// --------------------------------------------------------- -// ConnMonScanWlanAps::ConnMonScanWlanAps() -// Destructor -// --------------------------------------------------------- -// -ConnMonScanWlanAps::~ConnMonScanWlanAps() - { - OstTraceFunctionEntry1( CONNMONSCANWLANAPS_CONNMONSCANWLANAPSDESTR_ENTRY, this ); - - Cancel(); - // Cancel notifications and close connection monitor session - iMonitor.Close(); - if (wlanBuf) - { - delete wlanBuf; - } - - OstTraceFunctionExit1( CONNMONSCANWLANAPS_CONNMONSCANWLANAPSDESTR_EXIT, this ); - } - -// --------------------------------------------------------- -// ConnMonScanWlanAps::DoCancel() -// -// --------------------------------------------------------- -// -void ConnMonScanWlanAps::DoCancel() - { - OstTraceFunctionEntry1( CONNMONSCANWLANAPS_DOCANCEL_ENTRY, this ); - // TODO: error handling - OstTraceFunctionExit1( CONNMONSCANWLANAPS_DOCANCEL_EXIT, this ); - } - -// --------------------------------------------------------- -// ConnMonScanWlanAps::RunL() -// Called when scan is ready. Emits scan results in a signal. -// --------------------------------------------------------- -// -void ConnMonScanWlanAps::RunL() - { - OstTraceFunctionEntry1( CONNMONSCANWLANAPS_RUNL_ENTRY, this ); - - if (iStatus == KErrNone) - { - RConnMonWlanNetworksPtrArray wlanPtrArray; - wlanBuf->UnpackToL(wlanPtrArray); - QList wlanScanResult; - - for (TInt i = 0; i < wlanPtrArray.Count(); i++) - { - WlanQtUtilsWlanAp *ap = new WlanQtUtilsWlanAp(); - - // Security mode values defined in enum TConnMonSecurityMode, rconnmon.h. - TUint connMonWlanSecMode; - WlanQtUtilsWlanSecMode wlanQtUtilsWlanSecMode; - - TBuf wlanName = - wlanPtrArray[i]->Name(); - - QString wlanNameInQt = QString::fromUtf16(wlanName.Ptr(), - wlanName.Length()); - - if (wlanNameInQt.length() == 1 && wlanNameInQt.at(0).unicode() - == 0) - { - // QString handles empty strings (single \0 char) strangely, - // so let's initialize them in a different way: - wlanNameInQt = ""; - } - - ap->setSsid(wlanNameInQt); - - // TODO: Won't compile to ARMV5 for some reason. Commented for awhile. - //TBuf8 wlanBssid = wlanPtrArray[i]->WlanBssid(); - //ap->setBssid(QString::fromUtf8(wlanBssid.Ptr(), wlanBssid.Length())); - ap->setBssid("addMAC"); - - TUint wlanConnectionMode = wlanPtrArray[i]->ConnectionMode(); - ap->setConnectionMode(wlanConnectionMode); - - TUint wlanSignalStrength = wlanPtrArray[i]->SignalStrength(); - ap->setSignalStrength(wlanSignalStrength); - - connMonWlanSecMode = wlanPtrArray[i]->SecurityMode(); - wlanQtUtilsWlanSecMode = conMon2WlanQtUtilsSecModeMap(connMonWlanSecMode); - ap->setSecurityMode(wlanQtUtilsWlanSecMode); - - wlanScanResult.append(ap); - delete wlanPtrArray[i]; - } - q_ptr->emitAvailableWlans(wlanScanResult); - wlanPtrArray.Close(); - delete wlanBuf; - wlanBuf = NULL; - // TODO: Is this enough for clearing QList containing ConnUtilsWlanAps? - wlanScanResult.clear(); - } - else - { - // TODO: add error handling - } - - OstTraceFunctionExit1( CONNMONSCANWLANAPS_RUNL_EXIT, this ); - } - -// --------------------------------------------------------- -// ConnMonScanWlanAps::scanAvailableWlanAPs() -// Gets APs from Connection Monitor -// --------------------------------------------------------- -// -int ConnMonScanWlanAps::scanAvailableWlanAPs() - { - OstTraceFunctionEntry1( CONNMONSCANWLANAPS_SCANAVAILABLEWLANAPS_ENTRY, this ); - - if (!IsActive()) - { - // TODO: What size for wlanBuf? How to know exact size? - // 2560 ~ 35 wlan APs - wlanBuf = new (ELeave) CConnMonWlanNetworksPtrArrayPckg(2560); - wlanPtr.Set(wlanBuf->Buf()->Des()); - - iMonitor.GetPckgAttribute(EBearerIdWLAN, 0, KWlanNetworks, wlanPtr, - iStatus); - SetActive(); - } - - OstTraceFunctionExit1( CONNMONSCANWLANAPS_SCANAVAILABLEWLANAPS_EXIT, this ); - return KErrNone; - } - -// --------------------------------------------------------- -// ConMonScanWlanAps::connMon2WlanQtUtilsSecModeMap() -// Map security mode from Connection Monitor into WlanQtUtilsWlanSecMode. -// --------------------------------------------------------- -// -WlanQtUtilsWlanSecMode ConnMonScanWlanAps::conMon2WlanQtUtilsSecModeMap(TUint connMonSecMode) - { - WlanQtUtilsWlanSecMode ret = WlanQtUtilsWlanSecModeNone; - switch (connMonSecMode) - { - case EConnMonSecurityWep: - ret = WlanQtUtilsWlanSecModeWep; - break; - case EConnMonSecurity802d1x: - ret = WlanQtUtilsWlanSecMode802_1x; - break; - case EConnMonSecurityWpa: - ret = WlanQtUtilsWlanSecModeWpa; - break; - case EConnMonSecurityWpaPsk: - ret = WlanQtUtilsWlanSecModeWpa2; - break; - default: - // TODO: should default be None/unknown or should there be assert against EConnMonSecurityOpen. - ret = WlanQtUtilsWlanSecModeOpen; - break; - } - - return ret; - } - - -// --------------------------------------------------------- -// ConnMonConnInfo::ConnMonConnInfo() -// Constructor -// --------------------------------------------------------- -// -ConnMonConnInfo::ConnMonConnInfo(ConMonWrapper *wrapper) : - q_ptr(wrapper) - { - OstTraceFunctionEntry1( CONNMONCONNINFO_CONNMONCONNINFO_ENTRY, this ); - - iMonitor.ConnectL(); - StartMonitoringL(); - - OstTraceFunctionExit1( CONNMONCONNINFO_CONNMONCONNINFO_EXIT, this ); - } - -// --------------------------------------------------------- -// ConnMonConnInfo::~ConnMonConnInfo() -// Destructor -// --------------------------------------------------------- -// -ConnMonConnInfo::~ConnMonConnInfo() - { - OstTraceFunctionEntry1( CONNMONCONNINFO_CONNMONCONNINFODESTR_ENTRY, this ); - - StopMonitoring(); - iMonitor.Close(); - - OstTraceFunctionExit1( CONNMONCONNINFO_CONNMONCONNINFODESTR_EXIT, this ); - } - -// --------------------------------------------------------- -// ConnMonConnInfo::StartMonitoringL() -// Starts monitoring of Connection Monitor Server events -// --------------------------------------------------------- -// -void ConnMonConnInfo::StartMonitoringL() - { - OstTraceFunctionEntry1( CONNMONCONNINFO_STARTMONITORINGL_ENTRY, this ); - - iMonitoring = ETrue; - iMonitor.NotifyEventL(*this); - - OstTraceFunctionExit1( CONNMONCONNINFO_STARTMONITORINGL_EXIT, this ); - } - -// --------------------------------------------------------- -// ConnMonConnInfo::StopMonitoring() -// Stops monitoring of Connection Monitor Server events -// --------------------------------------------------------- -// -void ConnMonConnInfo::StopMonitoring() - { - OstTraceFunctionEntry1( CONNMONCONNINFO_STOPMONITORING_ENTRY, this ); - - iMonitoring = EFalse; - iMonitor.CancelNotifications(); - - OstTraceFunctionExit1( CONNMONCONNINFO_STOPMONITORING_EXIT, this ); - } - -// --------------------------------------------------------- -// ConnMonConnInfo::EventL() -// Handler of Connection Monitor Server events -// --------------------------------------------------------- -// -void ConnMonConnInfo::EventL(const CConnMonEventBase& aConnMonEvent) - { - OstTraceFunctionEntry1( CONNMONCONNINFO_EVENTL_ENTRY, this ); - - TUint connectionId = aConnMonEvent.ConnectionId(); - OstTraceExt2( - TRACE_NORMAL, - CONNMONCONNINFO_EVENTL_EVENTTYPE, - "ConnMonConnInfo::EventL;connectionId=%u;aConnMonEvent.EventType()=%d", connectionId, aConnMonEvent.EventType() ); - - // Filter out other than WLAN connections - if (!isWlan(connectionId)) { - return; - } - - // Note: Conversions from CConnMonEventBase to sub classes cannot be made to use dynamic_cast - // because constructors of CConnMonEventBase and its sub classes are not public in - // connmon library's interface. - - switch (aConnMonEvent.EventType()) - { - case EConnMonCreateConnection: - q_ptr->emitConnCreatedEvent( connectionId ); - break; - case EConnMonDeleteConnection: - - // TODO: take the following into use. - // const CConnMonDeleteConnection* eventDelete; - // eventDelete = static_cast< const CConnMonDeleteConnection*>( &aConnMonEvent ); - //TUint totalDlVolume = eventDelete->DownlinkData(); - //TUint totalUlVolume = eventDelete->UplinkData(); - //TBool authDelete = eventDelete->AuthoritativeDelete(); - - q_ptr->emitConnDeletedEvent( connectionId ); - break; - case EConnMonConnectionStatusChange: - const CConnMonConnectionStatusChange* eventConnectionStatusChange; - eventConnectionStatusChange = - static_cast< const CConnMonConnectionStatusChange* >( &aConnMonEvent ); - WlanQtUtilsConnectionStatus connectionStatus; - connectionStatus = connMon2WlanQtUtilsConnectionStatusMap( - eventConnectionStatusChange->ConnectionStatus() ); - - OstTraceExt2( - TRACE_NORMAL, - CONNMONCONNINFO_EVENTL_CONNSTATUS, - "ConnMonConnInfo::EventL;connectionId=%u;eventConnectionStatusChange->ConnectionStatus()=%d", - connectionId, - eventConnectionStatusChange->ConnectionStatus() ); - - if (connectionStatus != WlanQtUtilsConnectionStatusNone) { - q_ptr->emitConnStatusEvent( connectionId, connectionStatus ); - } - break; - default: - break; - } - - OstTraceFunctionExit1( CONNMONCONNINFO_EVENTL_EXIT, this ); - } - -// --------------------------------------------------------- -// ConnMonConnInfo::activeConnection() -// --------------------------------------------------------- -// -WlanQtUtilsActiveConn *ConnMonConnInfo::activeConnection() - { - OstTraceFunctionEntry1( CONNMONCONNINFO_ACTIVECONNECTION_ENTRY, this ); - - // Get number of active connections - TRequestStatus status; - - TUint numConnections = 0; - iMonitor.GetConnectionCount( numConnections, status ); - User::WaitForRequest( status ); - if ( status.Int() == KErrNone ) - { - // Get connection info of this connection - for ( TUint i = 1; i <= numConnections; i++ ) - { - TUint numSubConnections = 0; - TUint connectionId = 0; - TInt ret = iMonitor.GetConnectionInfo( i, connectionId, numSubConnections ); - Q_ASSERT( ret == KErrNone ); // TODO: error handling - - WlanQtUtilsActiveConn* activeConn = connectionInfo( connectionId ); - if ( activeConn != NULL ) - { - // connectionInfo() only returns WLAN connections, and there may be only - // one active WLAN connection, so this is the one we want to return - OstTraceFunctionExit1( CONNMONCONNINFO_ACTIVECONNECTION_EXIT, this ); - return activeConn; - } - } - } - - OstTraceFunctionExit1( DUP1_CONNMONCONNINFO_ACTIVECONNECTION_EXIT, this ); - return NULL; - } - -// --------------------------------------------------------- -// ConnMonConnInfo::connectionInfo() -// --------------------------------------------------------- -// -WlanQtUtilsActiveConn *ConnMonConnInfo::connectionInfo( uint connectionId ) - { - OstTraceFunctionEntry1( CONNMONCONNINFO_CONNECTIONINFO_ENTRY, this ); - - TRequestStatus status; - WlanQtUtilsActiveConn *activeConn = NULL; - - // Get the connection bearer. - TInt bearer = 0; - iMonitor.GetIntAttribute( - connectionId, - 0, - KBearer, - bearer, - status ); - User::WaitForRequest( status ); - if ( status.Int() == KErrNone ) - { - // We are only interested in WLAN connections. - WlanQtUtilsBearerType bearerType = connMon2WlanQtUtilsBearerTypeMap( bearer ); - if ( bearerType == WlanQtUtilsBearerTypeWlan ) - { - activeConn = new WlanQtUtilsActiveConn(); - activeConn->setConnectionId( connectionId ); - activeConn->setBearerType( bearerType ); - activeConnInfoUpdate( activeConn ); - } - } - - OstTraceFunctionExit1( CONNMONCONNINFO_CONNECTIONINFO_EXIT, this ); - return activeConn; - } - -// --------------------------------------------------------- -// ConnMonConnInfo::activeConnInfoUpdate() -// Requests active connection info from Connection Monitor Server -// --------------------------------------------------------- -// -// TODO: divide this function into smaller pieces depending on the need. -// TODO: optimize so that all the information is not always requested from connmon. -// Only information that is missing is requested. -void ConnMonConnInfo::activeConnInfoUpdate( WlanQtUtilsActiveConn *activeConn ) - { - OstTraceFunctionEntry1( CONNMONCONNINFO_ACTIVECONNINFOUPDATE_ENTRY, this ); - - Q_ASSERT( activeConn != NULL ); - Q_ASSERT( activeConn->bearerType() != WlanQtUtilsBearerTypeNone ); - - TUint connectionId = activeConn->connectionId(); - TRequestStatus status; - - // Get connection IAP ID. - TUint iapId = 0; - iMonitor.GetUintAttribute( - connectionId, - 0, - KIAPId, - iapId, - status ); - User::WaitForRequest( status ); - if ( status.Int() == KErrNone ) - { - activeConn->setIapId( iapId ); - } - - // Get connection status. - TInt connectionStatus = 0; - iMonitor.GetIntAttribute( - connectionId, - 0, - KConnectionStatus, - connectionStatus, - status ); - User::WaitForRequest( status ); - if ( status.Int() == KErrNone ) { - activeConn->setConnectionStatus( connMon2WlanQtUtilsConnectionStatusMap( connectionStatus ) ); - } - - OstTraceFunctionExit1( CONNMONCONNINFO_ACTIVECONNINFOUPDATE_EXIT, this ); - } - -// --------------------------------------------------------- -// ConnMonConnInfo::connMon2WlanQtUtilsConnectionStatusMap() -// Maps connection status of Connection Monitor Server to connection -// status of Wlan Qt Utilities. -// --------------------------------------------------------- -// -WlanQtUtilsConnectionStatus ConnMonConnInfo::connMon2WlanQtUtilsConnectionStatusMap( TInt aConnectionStatus ) - { - // TODO: This mapping is not specific to current status which is unknown to wrapper. - // TODO: This is only current implementation and will need serious modifications and - // verification from connmon guys. - WlanQtUtilsConnectionStatus connUtilsConnectionStatus = WlanQtUtilsConnectionStatusNone; - switch (aConnectionStatus) - { - // KConnectionOpen is not final status for WLAN, because DHCP is run after that - case KConnectionOpen: - case KStartingConnection: - connUtilsConnectionStatus = WlanQtUtilsConnectionStatusConnecting; - break; - case KLinkLayerOpen: - connUtilsConnectionStatus = WlanQtUtilsConnectionStatusConnected; - break; - case KConnectionClosed: - case KLinkLayerClosed: - connUtilsConnectionStatus = WlanQtUtilsConnectionStatusDisconnected; - break; - default: - // Ignore all other values - connUtilsConnectionStatus = WlanQtUtilsConnectionStatusNone; - break; - } - - return connUtilsConnectionStatus; - } - -// --------------------------------------------------------- -// ConnMonConnInfo::connMon2WlanQtUtilsBearerTypeMap() -// Maps bearer type of Connection Monitor Server to bearer -// type of Wlan Qt Utilities. -// --------------------------------------------------------- -// -WlanQtUtilsBearerType ConnMonConnInfo::connMon2WlanQtUtilsBearerTypeMap( TInt aBearerType ) - { - WlanQtUtilsBearerType connUtilsBearerType = WlanQtUtilsBearerTypeNone; - switch ( aBearerType ) { - case EBearerWCDMA: - case EBearerGPRS: - case EBearerEdgeGPRS: - connUtilsBearerType = WlanQtUtilsBearerTypeCellular; - break; - case EBearerWLAN: - connUtilsBearerType = WlanQtUtilsBearerTypeWlan; - break; - default: - break; - } - - return connUtilsBearerType; - } - -/*! - Checks the bearer of given connection. - Meant for filtering handling only for WLAN IAP's. - - @param [in] connectionId Connection ID. - - @return Returns true if connection a WLAN connection, otherwise false. -*/ - -bool ConnMonConnInfo::isWlan(uint connectionId) -{ - bool result = false; - TRequestStatus status; - - TInt bearer = 0; - iMonitor.GetIntAttribute( - connectionId, - 0, - KBearer, - bearer, - status); - User::WaitForRequest(status); - - if (status.Int() == KErrNone && bearer == EBearerWLAN) { - result = true; - } - - return result; -} - -// --------------------------------------------------------- -// ConnMonConnDisconnect::ConnMonConnDisconnect() -// Constructor -// --------------------------------------------------------- -// -ConnMonConnDisconnect::ConnMonConnDisconnect(ConMonWrapper *wrapper) : - CActive(EPriorityStandard), q_ptr(wrapper) - { - OstTraceFunctionEntry1( CONNMONCONNDISCONNECT_CONNMONCONNDISCONNECT_ENTRY, this ); - - CActiveScheduler::Add(this); - iMonitor.ConnectL(); - - OstTraceFunctionExit1( CONNMONCONNDISCONNECT_CONNMONCONNDISCONNECT_EXIT, this ); - } - -// --------------------------------------------------------- -// ConnMonConnDisconnect::ConnMonConnDisconnect() -// Destructor -// --------------------------------------------------------- -// -ConnMonConnDisconnect::~ConnMonConnDisconnect() - { - OstTraceFunctionEntry1( CONNMONCONNDISCONNECT_CONNMONCONNDISCONNECTDESTR_ENTRY, this ); - - // Cancel notifications and close connection monitor session - //iMonitor.CancelNotifications(); - iMonitor.Close(); - - OstTraceFunctionExit1( CONNMONCONNDISCONNECT_CONNMONCONNDISCONNECTDESTR_EXIT, this ); - } - -// --------------------------------------------------------- -// ConnMonConnDisconnect::DoCancel() -// -// --------------------------------------------------------- -// -void ConnMonConnDisconnect::DoCancel() - { - OstTraceFunctionEntry1( CONNMONCONNDISCONNECT_DOCANCEL_ENTRY, this ); - // TODO: error handling - OstTraceFunctionExit1( CONNMONCONNDISCONNECT_DOCANCEL_EXIT, this ); - } - -// --------------------------------------------------------- -// ConnMonConnDisconnect::RunL() -// -// --------------------------------------------------------- -// -void ConnMonConnDisconnect::RunL() - { - OstTraceFunctionEntry1( CONNMONCONNDISCONNECT_RUNL_ENTRY, this ); - // TODO: Is anything needed? - OstTraceFunctionExit1( CONNMONCONNDISCONNECT_RUNL_EXIT, this ); - } - -// --------------------------------------------------------- -// ConnMonConnDisconnect::disconnectConnection(int iapId) -// Stop active connection. -// --------------------------------------------------------- -// -void ConnMonConnDisconnect::disconnectConnection(int iapId) - { - OstTraceFunctionEntry1( CONNMONCONNDISCONNECT_DISCONNECTCONNECTION_ENTRY, this ); - OstTrace1( - TRACE_NORMAL, - CONNMONCONNDISCONNECT_DISCONNECTCONNECTION, - "ConnMonConnDisconnect::disconnectConnection;iapId=%d", iapId ); - - // TODO: Error handling - TUint count; - TRequestStatus status; - iMonitor.GetConnectionCount(count, status); - User::WaitForRequest(status); - - for (TInt i = 1; i <= count; i++) - { - TUint numSubConnections; - TUint iap = 0; - TUint connectionId = 0; - TInt ret = iMonitor.GetConnectionInfo(i, connectionId, - numSubConnections); - if (ret != KErrNone) - { - // error - } - iMonitor.GetUintAttribute(connectionId, 0, KIAPId, iap, status); - User::WaitForRequest(status); - if (status.Int() != KErrNone) - { - // error - } - if (iap == iapId) - { - TInt KErr = iMonitor.SetBoolAttribute(connectionId, 0, - KConnectionStop, ETrue); - } - } - - OstTraceFunctionExit1( CONNMONCONNDISCONNECT_DISCONNECTCONNECTION_EXIT, this ); - } diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsconmonwrapperdisconnect_s60.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsconmonwrapperdisconnect_s60.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * 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". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * Private implementation of wrapper for Symbian Connection Monitor + * library's connection disconnect interface. + */ + +// System includes + +// User includes + +#include "wlanqtutilsconmonwrapper.h" +#include "wlanqtutilsconmonwrapperdisconnect_s60_p.h" +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wlanqtutilsconmonwrapperdisconnect_s60Traces.h" +#endif + +/*! + \class WlanQtUtilsConMonWrapperDisconnect + \brief Private wrapper for Symbian Connection Monitor library. + + Provides functionality to disconnect connections regardless of how + many applications are using the connection. +*/ + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +/*! + Constructor. + + @param [in] wrapper Wrapper to report progress to. + */ + +WlanQtUtilsConMonWrapperDisconnect::WlanQtUtilsConMonWrapperDisconnect( + WlanQtUtilsConMonWrapper *wrapper) : + q_ptr(wrapper) +{ + OstTraceFunctionEntry1(WLANQTUTILSCONMONWRAPPERDISCONNECT_WLANQTUTILSCONMONWRAPPERDISCONNECT_ENTRY, this); + + // Errors in Connection Monitor Server connection are fatal so just + // throw them as exceptions + QT_TRAP_THROWING(iMonitor.ConnectL()); + + OstTraceFunctionExit1(WLANQTUTILSCONMONWRAPPERDISCONNECT_WLANQTUTILSCONMONWRAPPERDISCONNECT_EXIT, this); +} + +/*! + Destructor. + */ + +WlanQtUtilsConMonWrapperDisconnect::~WlanQtUtilsConMonWrapperDisconnect() +{ + OstTraceFunctionEntry1(DUP1_WLANQTUTILSCONMONWRAPPERDISCONNECT_WLANQTUTILSCONMONWRAPPERDISCONNECT_ENTRY, this); + + iMonitor.Close(); + + OstTraceFunctionExit1(DUP1_WLANQTUTILSCONMONWRAPPERDISCONNECT_WLANQTUTILSCONMONWRAPPERDISCONNECT_EXIT, this); +} + +/*! + Disconnects the connection with the given IAP ID. + + @param [in] wrapper Wrapper to report progress to. + */ + +void WlanQtUtilsConMonWrapperDisconnect::DisconnectConnection(int iapId) +{ + OstTraceFunctionEntry1(WLANQTUTILSCONMONWRAPPERDISCONNECT_DISCONNECTCONNECTION_ENTRY, this); + + OstTrace1( + TRACE_NORMAL, + WLANQTUTILSCONMONWRAPPERDISCONNECT_DISCONNECTCONNECTION, + "WlanQtUtilsConMonWrapperDisconnect::DisconnectConnection;iapId=%d", iapId); + + // Loop through connections to find the one with the IAP ID we want + TUint count; + TRequestStatus status; + iMonitor.GetConnectionCount(count, status); + User::WaitForRequest(status); + if (status.Int() == KErrNone) { + for (TInt i = 1; i <= count; i++) { + TUint numSubConnections; + TUint iap = 0; + TUint connectionId = 0; + TInt ret = iMonitor.GetConnectionInfo( + i, + connectionId, + numSubConnections); + if (ret == KErrNone) { + iMonitor.GetUintAttribute(connectionId, 0, KIAPId, iap, status); + User::WaitForRequest(status); + if (status.Int() == KErrNone) { + if (iap == iapId) { + OstTrace1( + TRACE_NORMAL, + WLANQTUTILSCONMONWRAPPERDISCONNECT_DISCONNECTCONNECTION_STOP, + "WlanQtUtilsConMonWrapperDisconnect::DisconnectConnection Stopping connection;connectionId=%u", + connectionId); + + // Match found, stop connection + TInt KErr = iMonitor.SetBoolAttribute( + connectionId, + 0, + KConnectionStop, + ETrue); + + OstTrace1( + TRACE_NORMAL, + WLANQTUTILSCONMONWRAPPERDISCONNECT_DISCONNECTCONNECTION_RESULT, + "WlanQtUtilsConMonWrapperDisconnect::DisconnectConnection Result;KErr=%d", KErr); + } + } + } + } + } + + OstTraceFunctionExit1( WLANQTUTILSCONMONWRAPPERDISCONNECT_DISCONNECTCONNECTION_EXIT, this); +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsconmonwrapperinfo_s60.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsconmonwrapperinfo_s60.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,354 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Private implementation of wrapper for Symbian Connection Monitor +* library's scan interface. +*/ + +// System includes + +#include +#include + +// User includes + +#include "wlanqtutils.h" +#include "wlanqtutilsconnection.h" +#include "wlanqtutilsconmonwrapper.h" +#include "wlanqtutilsconmonwrapperinfo_s60_p.h" + +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wlanqtutilsconmonwrapperinfo_s60Traces.h" +#endif + +/*! + \class WlanQtUtilsConMonWrapperInfo + \brief Private wrapper for Symbian Connection Monitor library. + + Provides functionality to request information about connections. +*/ + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +/*! + Constructor. + + @param [in] wrapper Wrapper to report progress to. +*/ + +WlanQtUtilsConMonWrapperInfo::WlanQtUtilsConMonWrapperInfo( + WlanQtUtilsConMonWrapper *wrapper) : + iMonitoringConnection(0), + q_ptr(wrapper) +{ + OstTraceFunctionEntry1(WLANQTUTILSCONMONWRAPPERINFO_WLANQTUTILSCONMONWRAPPERINFO_ENTRY, this); + + // Errors in Connection Monitor Server connection are fatal so just + // throw them as exceptions + QT_TRAP_THROWING( + iMonitor.ConnectL(); + iMonitor.NotifyEventL(*this); + ); + + OstTraceFunctionExit1(WLANQTUTILSCONMONWRAPPERINFO_WLANQTUTILSCONMONWRAPPERINFO_EXIT, this); +} + +/*! + Destructor. +*/ + +WlanQtUtilsConMonWrapperInfo::~WlanQtUtilsConMonWrapperInfo() +{ + OstTraceFunctionEntry1(DUP1_WLANQTUTILSCONMONWRAPPERINFO_WLANQTUTILSCONMONWRAPPERINFO_ENTRY, this); + + iMonitor.CancelNotifications(); + iMonitor.Close(); + + OstTraceFunctionExit1(DUP1_WLANQTUTILSCONMONWRAPPERINFO_WLANQTUTILSCONMONWRAPPERINFO_EXIT, this); +} + +/*! + Getter for active connection information. + + @return Information of active connection, if one exists. +*/ + +WlanQtUtilsConnection *WlanQtUtilsConMonWrapperInfo::ActiveConnection() +{ + OstTraceFunctionEntry1(WLANQTUTILSCONMONWRAPPERINFO_ACTIVECONNECTION_ENTRY, this); + + // Get number of active connections + TRequestStatus status; + + WlanQtUtilsConnection *activeConn = NULL; + TUint numConnections = 0; + iMonitor.GetConnectionCount(numConnections, status); + User::WaitForRequest(status); + if (status.Int() == KErrNone) { + // Get connection info of this connection + for (TUint i = 1; i <= numConnections; i++) { + TUint numSubConnections = 0; + TUint connectionId = 0; + TInt ret = iMonitor.GetConnectionInfo( + i, + connectionId, + numSubConnections); + if (ret == KErrNone) { + activeConn = ConnectionInfo(connectionId); + if (activeConn != NULL) { + // ConnectionInfo() only returns WLAN connections, + // and there may be only one active WLAN connection, + // so this is the one we want to return and also + // remember later. + Q_ASSERT(iMonitoringConnection == 0 + || iMonitoringConnection == connectionId); + iMonitoringConnection = connectionId; + break; + } + } + } + } + + OstTraceFunctionExit1(WLANQTUTILSCONMONWRAPPERINFO_ACTIVECONNECTION_EXIT, this); + return activeConn; +} + +/*! + Returns information of a connection with the given connection ID. + + @param[in] connectionId Connection ID. + @return Information of the given connection, if one exists. +*/ + +WlanQtUtilsConnection *WlanQtUtilsConMonWrapperInfo::ConnectionInfo( + uint connectionId) +{ + OstTraceFunctionEntry1(WLANQTUTILSCONMONWRAPPERINFO_CONNECTIONINFO_ENTRY, this); + + WlanQtUtilsConnection *activeConn = NULL; + + if (IsWlanConnection(connectionId)) { + activeConn = new WlanQtUtilsConnection(); + activeConn->setConnectionId(connectionId); + if (!ConnectionInfoDetails(activeConn)) { + delete activeConn; + activeConn = NULL; + } + } + + OstTraceFunctionExit1(WLANQTUTILSCONMONWRAPPERINFO_CONNECTIONINFO_EXIT, this); + return activeConn; +} + +/*! + Gets detailed information of a given connection. + + @param[out] connection Where to store info. Connection ID must already + be valid. + + @return Returns ETrue if detail fetching succeeded. +*/ + +TBool WlanQtUtilsConMonWrapperInfo::ConnectionInfoDetails( + WlanQtUtilsConnection *connection) +{ + OstTraceFunctionEntry1(WLANQTUTILSCONMONWRAPPERINFO_CONNECTIONINFODETAILS_ENTRY, this); + Q_ASSERT(connection != NULL); + + TBool success = EFalse; + TUint connectionId = connection->connectionId(); + TRequestStatus status; + + // Get connection IAP ID. + TUint iapId = 0; + iMonitor.GetUintAttribute( + connectionId, + 0, + KIAPId, + iapId, + status); + User::WaitForRequest(status); + if (status.Int() == KErrNone) { + connection->setIapId(iapId); + + // Get connection status. + TInt connectionStatus = 0; + iMonitor.GetIntAttribute( + connectionId, + 0, + KConnectionStatus, + connectionStatus, + status); + User::WaitForRequest(status); + if (status.Int() == KErrNone) { + connection->setConnectionStatus( + ConnMonConnStatusMap(connectionStatus)); + success = ETrue; + } + } + + OstTraceFunctionExit1(WLANQTUTILSCONMONWRAPPERINFO_CONNECTIONINFODETAILS_EXIT, this); + return success; +} + +/*! + Handler of Connection Monitor Server events. + + @param [in] connMonEvent Connection monitor event. +*/ + +void WlanQtUtilsConMonWrapperInfo::EventL(const CConnMonEventBase& connMonEvent) +{ + OstTraceFunctionEntry1(WLANQTUTILSCONMONWRAPPERINFO_EVENTL_ENTRY, this); + + TUint connectionId = connMonEvent.ConnectionId(); + + OstTraceExt2( + TRACE_NORMAL, + WLANQTUTILSCONMONWRAPPERINFO_EVENTL_EVENTTYPE, + "WlanQtUtilsConMonWrapperInfo::EventL;connectionId=%u;aConnMonEvent.EventType()=%{ConnMonEvent}", + connectionId, + connMonEvent.EventType()); + + switch (connMonEvent.EventType()) { + case EConnMonCreateConnection: + // Filter out other than WLAN connections + if (IsWlanConnection(connectionId)) { + iMonitoringConnection = connectionId; + emit q_ptr->connCreatedEventFromWrapper(connectionId); + } + break; + + case EConnMonDeleteConnection: + if (iMonitoringConnection == connectionId) { + iMonitoringConnection = 0; + emit q_ptr->connDeletedEventFromWrapper(connectionId); + } + break; + + case EConnMonConnectionStatusChange: + if (iMonitoringConnection == connectionId) { + // Find out the new status for the connection + const CConnMonConnectionStatusChange *connMonStatusEvent; + connMonStatusEvent = + static_cast< const CConnMonConnectionStatusChange* >(&connMonEvent); + WlanQtUtils::ConnStatus connectionStatus; + connectionStatus = + ConnMonConnStatusMap(connMonStatusEvent->ConnectionStatus()); + + OstTraceExt2( + TRACE_NORMAL, + WLANQTUTILSCONMONWRAPPERINFO_EVENTL_CONNSTATUS, + "WlanQtUtilsConMonWrapperInfo::EventL;connectionId=%u;eventConnectionStatusChange->ConnectionStatus()=%{ConnMonConnStatus}", + connectionId, + connMonStatusEvent->ConnectionStatus()); + + if (connectionStatus != WlanQtUtils::ConnStatusNone) { + emit q_ptr->connStatusEventFromWrapper( + connectionId, + connectionStatus); + } + } + break; + + default: + // Not interesting + break; + } + + OstTraceFunctionExit1(WLANQTUTILSCONMONWRAPPERINFO_EVENTL_EXIT, this); +} + +/*! + Maps Connection Monitor's connection status value into + WlanQtUtilsConnectionStatus. + + Note: Mapping is only valid for WLAN connections. + + @param connStatus Connection status as used by Connection + Monitor server. Defined in nifvar.h. + @return Connection status in Wlan Qt Utilities style. +*/ + +WlanQtUtils::ConnStatus WlanQtUtilsConMonWrapperInfo::ConnMonConnStatusMap( + TInt connStatus) + { + OstTraceFunctionEntry1(WLANQTUTILSCONMONWRAPPERINFO_CONNMONCONNSTATUSMAP_ENTRY, this); + + WlanQtUtils::ConnStatus utilsConnStatus; + switch (connStatus) { + // KConnectionOpen is not final status for WLAN, because DHCP is + // run after that + case KConnectionOpen: + case KStartingConnection: + utilsConnStatus = WlanQtUtils::ConnStatusConnecting; + break; + + case KLinkLayerOpen: + utilsConnStatus = WlanQtUtils::ConnStatusConnected; + break; + + case KLinkLayerClosed: + utilsConnStatus = WlanQtUtils::ConnStatusDisconnected; + break; + + default: + // Ignore all other values + utilsConnStatus = WlanQtUtils::ConnStatusNone; + break; + } + + OstTraceFunctionExit1(WLANQTUTILSCONMONWRAPPERINFO_CONNMONCONNSTATUSMAP_EXIT, this); + return utilsConnStatus; +} + +/*! + Checks the bearer of given connection. + Meant for filtering handling only for WLAN IAP's. + + @param [in] connectionId Connection ID. + + @return Returns ETrue if connection a WLAN connection, otherwise false. +*/ + +TBool WlanQtUtilsConMonWrapperInfo::IsWlanConnection(TUint connectionId) +{ + OstTraceFunctionEntry1(WLANQTUTILSCONMONWRAPPERINFO_ISWLANCONNECTION_ENTRY, this); + + TBool result = EFalse; + TRequestStatus status; + + TInt bearer = 0; + iMonitor.GetIntAttribute( + connectionId, + 0, + KBearer, + bearer, + status); + User::WaitForRequest(status); + + if (status.Int() == KErrNone && bearer == EBearerWLAN) { + result = ETrue; + } + + OstTraceFunctionExit1(WLANQTUTILSCONMONWRAPPERINFO_ISWLANCONNECTION_EXIT, this); + return result; +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsconmonwrapperscan_s60.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsconmonwrapperscan_s60.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,330 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Private implementation of wrapper for Symbian Connection Monitor +* library's scan interface. +*/ + +// System includes + +#include +#include +#include +#include + +// User includes + +#include "wlanqtutilsap.h" +#include "wlanqtutilsconmonwrapper.h" +#include "wlanqtutilsconmonwrapperscan_s60_p.h" + +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wlanqtutilsconmonwrapperscan_s60Traces.h" +#endif + +/*! + \class WlanQtUtilsConMonWrapperScan + \brief Private wrapper for Symbian Connection Monitor library. + + Provides functionality to scan WLAN networks. +*/ + +// External function prototypes + +// Local constants + +//! Size of the scan result buffer. Good for about 100 networks. +#define SCAN_RESULT_BUFFER_SIZE 15000 + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +/*! + Constructor. + + @param [in] wrapper Wrapper to report progress to. + */ + +WlanQtUtilsConMonWrapperScan::WlanQtUtilsConMonWrapperScan( + WlanQtUtilsConMonWrapper *wrapper) : + CActive(EPriorityStandard), + iWlanBuf(NULL), + iWlanPtr(0, 0), + iScanCancelled(EFalse), + q_ptr(wrapper) +{ + OstTraceFunctionEntry1(WLANQTUTILSCONMONWRAPPERSCAN_WLANQTUTILSCONMONWRAPPERSCAN_ENTRY, this); + + CActiveScheduler::Add(this); + // Errors in Connection Monitor Server connection are fatal so just + // throw them as exceptions + QT_TRAP_THROWING(iMonitor.ConnectL()); + + OstTraceFunctionExit1(WLANQTUTILSCONMONWRAPPERSCAN_WLANQTUTILSCONMONWRAPPERSCAN_EXIT, this); +} + +/*! + Destructor. + */ + +WlanQtUtilsConMonWrapperScan::~WlanQtUtilsConMonWrapperScan() +{ + OstTraceFunctionEntry1(DUP1_WLANQTUTILSCONMONWRAPPERSCAN_WLANQTUTILSCONMONWRAPPERSCAN_ENTRY, this); + + // Cancel possibly ongoing scan + Cancel(); + // Cancel notifications and close connection monitor session + iMonitor.Close(); + delete iWlanBuf; + + OstTraceFunctionExit1(DUP1_WLANQTUTILSCONMONWRAPPERSCAN_WLANQTUTILSCONMONWRAPPERSCAN_EXIT, this); +} + +/*! + Request a scan for available WLAN networks. + */ + +void WlanQtUtilsConMonWrapperScan::ScanAvailableWlanAPs() +{ + OstTraceFunctionEntry1(WLANQTUTILSCONMONWRAPPERSCAN_SCANAVAILABLEWLANAPS_ENTRY, this); + + if (!IsActive()) { + // Reserve the scan result buffer, if this is the first scan + // request. Same buffer is used for the lifetime of this object. + if (iWlanBuf == NULL) { + iWlanBuf = new CConnMonWlanNetworksPtrArrayPckg( + SCAN_RESULT_BUFFER_SIZE); + iWlanPtr.Set(iWlanBuf->Buf()->Des()); + } + + iScanCancelled = EFalse; + iMonitor.GetPckgAttribute( + EBearerIdWLAN, + 0, + KWlanNetworks, + iWlanPtr, + iStatus); + SetActive(); + } + + OstTraceFunctionExit1(WLANQTUTILSCONMONWRAPPERSCAN_SCANAVAILABLEWLANAPS_EXIT, this); +} + +/*! + Stops a possibly ongoing WLAN scan. + */ + +void WlanQtUtilsConMonWrapperScan::StopScan() +{ + OstTraceFunctionEntry1(WLANQTUTILSCONMONWRAPPERSCAN_STOPSCAN_ENTRY, this); + + iScanCancelled = ETrue; + Cancel(); + + OstTraceFunctionExit1(WLANQTUTILSCONMONWRAPPERSCAN_STOPSCAN_EXIT, this); +} + +/*! + From CActive: called when active object is cancelled. + */ + +void WlanQtUtilsConMonWrapperScan::DoCancel() +{ + OstTraceFunctionEntry1(WLANQTUTILSCONMONWRAPPERSCAN_DOCANCEL_ENTRY, this); + + // Stop scan request, if one is active + iMonitor.CancelAsyncRequest(EConnMonGetPckgAttribute); + + OstTraceFunctionExit1(WLANQTUTILSCONMONWRAPPERSCAN_DOCANCEL_EXIT, this); +} + +/*! + From CActive: called when async scan request has been completed. + Reports results to owning wrapper. + */ + +void WlanQtUtilsConMonWrapperScan::RunL() +{ + OstTraceFunctionEntry1(WLANQTUTILSCONMONWRAPPERSCAN_RUNL_ENTRY, this); + + OstTrace1( + TRACE_NORMAL, + WLANQTUTILSCONMONWRAPPERSCAN_RUNL_STATUS, + "WlanQtUtilsConMonWrapperScan::RunL;iStatus=%d", iStatus.Int() ); + + if (iStatus == KErrNone) { + RConnMonWlanNetworksPtrArray wlanPtrArray; + iWlanBuf->UnpackToL(wlanPtrArray); + QList< QSharedPointer > wlanScanResult; + + OstTrace1( + TRACE_NORMAL, + WLANQTUTILSCONMONWRAPPERSCAN_RUNL_COUNT, + "WlanQtUtilsConMonWrapperScan::RunL;count=%d", + wlanPtrArray.Count()); + + for (TInt i = 0; i < wlanPtrArray.Count(); i++) { + // Convert name to QString + TBuf wlanName = + wlanPtrArray[i]->Name(); + QString wlanNameInQt = + QString::fromUtf16(wlanName.Ptr(), wlanName.Length()); + + OstTraceExt1( + TRACE_DUMP, + WLANQTUTILSCONMONWRAPPERSCAN_RUNL, + "WlanQtUtilsConMonWrapperScan::RunL;name=%S", + wlanPtrArray[i]->Name()); + + // Skip over hidden networks. There is no spec for what + // their names will contain, but at least names with only + // null characters and whitespace characters are seen + // in real life. + wlanNameInQt.remove(QChar()); + if (wlanNameInQt.trimmed().isEmpty()) { + delete wlanPtrArray[i]; + continue; + } + + // Go ahead and create the access point + QSharedPointer ap = + QSharedPointer(new WlanQtUtilsAp()); + + ap->setValue(WlanQtUtilsAp::ConfIdSsid, wlanNameInQt); + + StoreConMonConnMode(ap, wlanPtrArray[i]->ConnectionMode()); + ap->setValue( + WlanQtUtilsAp::ConfIdSignalStrength, + wlanPtrArray[i]->SignalStrength()); + + // Security mode values defined in enum TConnMonSecurityModeV2, + // rconnmon.h. + StoreConMonSecMode(ap, wlanPtrArray[i]->SecurityModeV2()); + + // TODO: "Adding WLAN network manually" subfreature: + // wps (Wifi Protected Setup) support, read this from connmon + ap->setValue(WlanQtUtilsAp::ConfIdWpsSupported, false); + // TODO: "Adding WLAN network manually" subfreature: + // different scan requests needed to identify hidden networks + ap->setValue(WlanQtUtilsAp::ConfIdHidden, false); + + wlanScanResult.append(ap); + delete wlanPtrArray[i]; + } + // Don't report results, if scan was cancelled + if (!iScanCancelled) { + emit q_ptr->availableWlanApsFromWrapper(wlanScanResult); + } + // else: scan was probably stopped before results were reveived + + wlanPtrArray.Close(); + + // QSharedPointer takes care of memory deallocation + wlanScanResult.clear(); + } + + OstTraceFunctionExit1(WLANQTUTILSCONMONWRAPPERSCAN_RUNL_EXIT, this); +} + +/*! + Stores Security mode parameters received from ConnMon to \a ap class. + + @param ap Access Point object to where the configuration is stored + @param conMonSecMode Security mode to store. + */ + +void WlanQtUtilsConMonWrapperScan::StoreConMonSecMode( + QSharedPointer ap, + TUint conMonSecMode) + { + // Entry-exit traces left out on purpose, because this is a simple + // function and called many times inside a loop. + + CMManagerShim::WlanSecMode secMode; + ap->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false); + + switch (conMonSecMode) { + case EConnMonSecurityV2WepOpen: + case EConnMonSecurityV2WepShared: + secMode = CMManagerShim::WlanSecModeWep; + break; + + case EConnMonSecurityV2802d1x: + secMode = CMManagerShim::WlanSecMode802_1x; + break; + + case EConnMonSecurityV2Wpa: + secMode = CMManagerShim::WlanSecModeWpa; + break; + + case EConnMonSecurityV2WpaPsk: + secMode = CMManagerShim::WlanSecModeWpa; + ap->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true); + break; + + case EConnMonSecurityV2Wpa2: + secMode = CMManagerShim::WlanSecModeWpa2; + break; + + case EConnMonSecurityV2Wpa2Psk: + secMode = CMManagerShim::WlanSecModeWpa2; + ap->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true); + break; + + case EConnMonSecurityV2Wapi: + case EConnMonSecurityV2WapiPsk: + secMode = CMManagerShim::WlanSecModeWapi; + break; + + default: + Q_ASSERT(conMonSecMode == EConnMonSecurityV2Open); + secMode = CMManagerShim::WlanSecModeOpen; + break; + } + + ap->setValue(WlanQtUtilsAp::ConfIdSecurityMode, secMode); +} + +/*! + Stores connection mode parameters received from ConnMon to \a ap class. + + @param ap Access Point object to where the configuration is stored + @param conMonConnMode Connection mode to store. + */ + +void WlanQtUtilsConMonWrapperScan::StoreConMonConnMode( + QSharedPointer ap, + TInt conMonConnMode) +{ + // Entry-exit traces left out on purpose, because this is a simple + // function and called many times inside a loop. + + CMManagerShim::WlanConnMode connMode; + + switch (conMonConnMode){ + case EConnMonInfraStructure: + case EConnMonSecureInfra: + connMode = CMManagerShim::Infra; + break; + + default: + Q_ASSERT(conMonConnMode == EConnMonAdHoc); + connMode = CMManagerShim::Adhoc; + break; + } + + ap->setValue(WlanQtUtilsAp::ConfIdConnectionMode, connMode); +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsconntestwrapper.cpp --- a/wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsconntestwrapper.cpp Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsconntestwrapper.cpp Mon May 24 21:11:39 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -19,14 +19,14 @@ #include "wlanqtutilsconntestwrapper.h" #include "wlanqtutilsconntestwrapper_s60_p.h" -ConnTestWrapper::ConnTestWrapper(QObject *parent) : QObject(parent) +ConnTestWrapper::ConnTestWrapper(QObject *parent) : + QObject(parent), + d_ptr_(new ConnTestWrapperPrivate(this)) { - d_ptr_ = new ConnTestWrapperPrivate(this); } ConnTestWrapper::~ConnTestWrapper() { - delete d_ptr_; } void ConnTestWrapper::connectivityTestDone(bool result) diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsconntestwrapper_s60.cpp --- a/wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsconntestwrapper_s60.cpp Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsconntestwrapper_s60.cpp Mon May 24 21:11:39 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -22,11 +22,7 @@ #include "wlanqtutilsconntestwrapper.h" #include "wlanqtutilsconntestwrapper_s60_p.h" -#ifdef WLANQTUTILS_NO_OST_TRACES_FLAG -#include -#else #include "OstTraceDefinitions.h" -#endif #ifdef OST_TRACE_COMPILER_IN_USE #include "wlanqtutilsconntestwrapper_s60Traces.h" #endif @@ -64,17 +60,13 @@ CONNTESTWRAPPERPRIVATE_CONNECTIVITYOBSERVER, "ConnTestWrapperPrivate::ConnectivityObserver;aResult=%u", aResult ); - switch ( aResult ) + if ( aResult == EConnectionOk ) { - case EConnectionOk : - q_ptr->connectivityTestDone( ETrue ); - break; - case EHttpAuthenticationNeeded : - case EConnectionNotOk : - case ETimeout : - default: - q_ptr->connectivityTestDone( EFalse ); - break; + q_ptr->connectivityTestDone( ETrue ); + } + else + { + q_ptr->connectivityTestDone( EFalse ); } delete iIct; diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsesockwrapper.cpp --- a/wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsesockwrapper.cpp Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsesockwrapper.cpp Mon May 24 21:11:39 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -12,34 +12,99 @@ * Contributors: * * Description: -* This is a source file for EsockWrapper class. +* Wrapper for Symbian Esock library. */ +// System includes + +#include + +// User includes + #include "wlanqtutilsesockwrapper.h" #include "wlanqtutilsesockwrapper_s60_p.h" -EsockWrapper::EsockWrapper(QObject *parent) - : QObject(parent) +/*! + \class WlanQtUtilsEsockWrapper + \brief Wrapper for Symbian Esock library. + + Provides functionality to connect and disconnect IAPs. +*/ + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +/*! + Constructor. + + @param [in] parent Parent object. + */ + +WlanQtUtilsEsockWrapper::WlanQtUtilsEsockWrapper(QObject *parent) : + QObject(parent), + d_ptr(new WlanQtUtilsEsockWrapperPrivate(this)), + mLastStatusCode(KErrNone) { - d_ptr = new EsockWrapperPrivate(this); } -EsockWrapper::~EsockWrapper() +/*! + Destructor. + */ + +WlanQtUtilsEsockWrapper::~WlanQtUtilsEsockWrapper() { - delete d_ptr; } -void EsockWrapper::updateConnection(bool isOpened) +/*! + Handles connection status update event. + + @param [in] isOpened Was the connection opened or not? + @param [in] platformStatusCode Platform specific status code. + */ + +void WlanQtUtilsEsockWrapper::updateConnection( + bool isOpened, + int platformStatusCode) { + mLastStatusCode = platformStatusCode; emit connectionStatusFromWrapper(isOpened); } -void EsockWrapper::connectIap(int iapId) +/*! + Returns last received connection creation status code. Clears status. + + @return Platform specific status code of the last connection attempt. + */ + +int WlanQtUtilsEsockWrapper::lastStatusCode() { - d_ptr->connectIap(iapId); + // Return current status and clear it + int status = mLastStatusCode; + mLastStatusCode = KErrNone; + return status; } -void EsockWrapper::disconnectIap() +/*! + Starts connection creation to given IAP. + + @param [in] iapId IAP ID to connect. + */ + +void WlanQtUtilsEsockWrapper::connectIap(int iapId) { - d_ptr->disconnectIap(); + d_ptr->ConnectIap(iapId); } + +/*! + Disconnects connection, if one is active. + */ + +void WlanQtUtilsEsockWrapper::disconnectIap() +{ + d_ptr->DisconnectIap(); +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsesockwrapper_s60.cpp --- a/wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsesockwrapper_s60.cpp Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsesockwrapper_s60.cpp Mon May 24 21:11:39 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -12,138 +12,185 @@ * Contributors: * * Description: -* +* Private implementation of wrapper for Symbian Esock library. */ -// INCLUDE FILES +// System includes + #include #include #include -#include +#include + +// User includes + #include "wlanqtutilsesockwrapper.h" #include "wlanqtutilsesockwrapper_s60_p.h" -#ifdef WLANQTUTILS_NO_OST_TRACES_FLAG -#include -#else #include "OstTraceDefinitions.h" -#endif #ifdef OST_TRACE_COMPILER_IN_USE #include "wlanqtutilsesockwrapper_s60Traces.h" #endif +/*! + \class WlanQtUtilsWlanQtUtilsEsockWrapperPrivate + \brief Private implementation of wrapper for Symbian Esock library. -// =========== PRIVATE CLASS MEMBER FUNCTIONS =============== -// -// --------------------------------------------------------- -// EsockWrapperPrivate::EsockWrapperPrivate() -// Constructor -// --------------------------------------------------------- -// -EsockWrapperPrivate::EsockWrapperPrivate(EsockWrapper *aWrapper) -: CActive(EPriorityStandard), q_ptr(aWrapper) - { - OstTraceFunctionEntryExt( ESOCKWRAPPERPRIVATE_ESOCKWRAPPERPRIVATE_ENTRY, this ); + Provides functionality to connect and disconnect IAPs. +*/ + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +/*! + Constructor. + @param [in] wrapper Wrapper to report progress to. + */ + +WlanQtUtilsEsockWrapperPrivate::WlanQtUtilsEsockWrapperPrivate( + WlanQtUtilsEsockWrapper *wrapper) : + CActive(EPriorityStandard), + iConnectionActive(EFalse), + q_ptr(wrapper) +{ + OstTraceFunctionEntry1(WLANQTUTILSESOCKWRAPPERPRIVATE_WLANQTUTILSESOCKWRAPPERPRIVATE_ENTRY, this); + CActiveScheduler::Add(this); - iSocketServer.Connect(); - - OstTraceFunctionExit1( ESOCKWRAPPERPRIVATE_ESOCKWRAPPERPRIVATE_EXIT, this ); - } + // Establish a session to Socket Server. Errors in Socket Server + // connection are fatal so just throw them as exceptions + qt_symbian_throwIfError(iSocketServer.Connect()); + + OstTraceFunctionExit1(WLANQTUTILSESOCKWRAPPERPRIVATE_WLANQTUTILSESOCKWRAPPERPRIVATE_EXIT, this); +} -// --------------------------------------------------------- -// EsockWrapperPrivate::EsockWrapperPrivate() -// Destructor -// --------------------------------------------------------- -// -EsockWrapperPrivate::~EsockWrapperPrivate() - { - OstTraceFunctionEntry1( ESOCKWRAPPERPRIVATE_ESOCKWRAPPERPRIVATEDESTR_ENTRY, this ); - +/*! + Destructor. + */ + +WlanQtUtilsEsockWrapperPrivate::~WlanQtUtilsEsockWrapperPrivate() +{ + OstTraceFunctionEntry1(DUP1_WLANQTUTILSESOCKWRAPPERPRIVATE_WLANQTUTILSESOCKWRAPPERPRIVATE_ENTRY, this); + + // Close any possibly ongoing connection Cancel(); - // Closing active RConnection is not mandatory, but is recommended. - // ==> add checking here when implementing cancel/error cases. + // Close Socket Server session iSocketServer.Close(); - OstTraceFunctionExit1( ESOCKWRAPPERPRIVATE_ESOCKWRAPPERPRIVATEDESTR_EXIT, this ); - } + OstTraceFunctionExit1(DUP1_WLANQTUTILSESOCKWRAPPERPRIVATE_WLANQTUTILSESOCKWRAPPERPRIVATE_EXIT, this); +} + +/*! + Starts connection creation to given IAP. -// --------------------------------------------------------- -// EsockWrapperPrivate::connectIap() -// Start connection creation to given IAP. -// --------------------------------------------------------- -// -void EsockWrapperPrivate::connectIap(int aIapId) - { - OstTraceFunctionEntryExt( ESOCKWRAPPERPRIVATE_CONNECTIAP_ENTRY, this ); + @param [in] iapId IAP ID to connect. + */ + +void WlanQtUtilsEsockWrapperPrivate::ConnectIap(int iapId) +{ + OstTraceFunctionEntry1(WLANQTUTILSESOCKWRAPPERPRIVATE_CONNECTIAP_ENTRY, this); + + // Cancel a (possibly) ongoing previous request + Cancel(); - // Open an RConnection object. - iConnection.Open(iSocketServer); + OstTrace1( + TRACE_NORMAL, + WLANQTUTILSESOCKWRAPPERPRIVATE_CONNECTIAP, + "WlanQtUtilsEsockWrapperPrivate::connectIap;iapId=%d", + iapId ); + + // Open an RConnection object. Errors in RConnection opening are + // fatal so just throw them as exceptions + qt_symbian_throwIfError(iConnection.Open(iSocketServer)); - // Create overrides to force opening of the given IAP without any user prompts. - TCommDbConnPref prefs; - prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); - prefs.SetDirection(ECommDbConnectionDirectionOutgoing); - prefs.SetIapId(aIapId); + // Create overrides for connection preferences to force opening of the + // given IAP without any user prompts. + TConnPrefList prefList; + TExtendedConnPref prefs; + prefs.SetIapId(iapId); + prefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent); + QT_TRAP_THROWING(prefList.AppendL(&prefs)); + + // Start a connection with connection preferences + iConnection.Start(prefList, iStatus); + + iConnectionActive = ETrue; - // Start the Connection with overrides - iConnection.Start(prefs, iStatus); - - // TODO: Currently SetActive Panics when connecting "furiously" in Visual view... - // Panicking line in SetActive was this: - // __ASSERT_ALWAYS(!(iStatus.iFlags&TRequestStatus::EActive),Panic(EReqAlreadyActive)); SetActive(); - OstTraceFunctionExit1( ESOCKWRAPPERPRIVATE_CONNECTIAP_EXIT, this ); - } + OstTraceFunctionExit1(WLANQTUTILSESOCKWRAPPERPRIVATE_CONNECTIAP_EXIT, this); +} + +/*! + Disconnects connection, if one is active. + */ -// --------------------------------------------------------- -// EsockWrapperPrivate::disconnectIap() -// Stop connection. -// --------------------------------------------------------- -// -void EsockWrapperPrivate::disconnectIap() - { - OstTraceFunctionEntry1( ESOCKWRAPPERPRIVATE_DISCONNECTIAP_ENTRY, this ); +void WlanQtUtilsEsockWrapperPrivate::DisconnectIap() +{ + OstTraceFunctionEntry1(WLANQTUTILSESOCKWRAPPERPRIVATE_DISCONNECTIAP_ENTRY, this); - // TODO: Error checking - iConnection.Close(); + if (iConnectionActive) { + OstTrace0( + TRACE_NORMAL, + WLANQTUTILSESOCKWRAPPERPRIVATE_DISCONNECTIAP_DISCONNECT, + "WlanQtUtilsEsockWrapperPrivate::disconnectIap Disconnecting connection"); + + iConnectionActive = EFalse; + iConnection.Close(); + } else { + OstTrace0( + TRACE_NORMAL, + WLANQTUTILSESOCKWRAPPERPRIVATE_DISCONNECTIAP_IGNORED, + "WlanQtUtilsEsockWrapperPrivate::disconnectIap Ignored since no active connection"); + } - OstTraceFunctionExit1( ESOCKWRAPPERPRIVATE_DISCONNECTIAP_EXIT, this ); - } + OstTraceFunctionExit1(WLANQTUTILSESOCKWRAPPERPRIVATE_DISCONNECTIAP_EXIT, this); +} + +/*! + From CActive: called when async request (RConnection::Start()) + has been completed. + */ -// --------------------------------------------------------- -// EsockWrapperPrivate::RunL() -// Called when connection creation has finished. -// --------------------------------------------------------- -// -void EsockWrapperPrivate::RunL() - { - OstTraceFunctionEntry1( ESOCKWRAPPERPRIVATE_RUNL_ENTRY, this ); - OstTrace1( TRACE_NORMAL, ESOCKWRAPPERPRIVATE_RUNL, "EsockWrapperPrivate::RunL;iStatus.Int()=%d", iStatus.Int() ); +void WlanQtUtilsEsockWrapperPrivate::RunL() +{ + OstTraceFunctionEntry1(WLANQTUTILSESOCKWRAPPERPRIVATE_RUNL_ENTRY, this); + + OstTrace1( + TRACE_NORMAL, + WLANQTUTILSESOCKWRAPPERPRIVATE_RUNL, + "WlanQtUtilsEsockWrapperPrivate::RunL;iStatus=%d", iStatus.Int()); - bool success = false; - - if (iStatus == KErrNone) - { + bool success; + if (iStatus == KErrNone) { success = true; - } + } else { + success = false; + iConnectionActive = EFalse; + } - q_ptr->updateConnection(success); + // Report to public wrapper + q_ptr->updateConnection(success, iStatus.Int()); - OstTraceFunctionExit1( ESOCKWRAPPERPRIVATE_RUNL_EXIT, this ); - } + OstTraceFunctionExit1(WLANQTUTILSESOCKWRAPPERPRIVATE_RUNL_EXIT, this); +} + +/*! + From CActive: called when active object is cancelled. + */ -// --------------------------------------------------------- -// EsockWrapperPrivate::DoCancel() -// -// --------------------------------------------------------- -// -void EsockWrapperPrivate::DoCancel() - { - OstTraceFunctionEntry1( ESOCKWRAPPERPRIVATE_DOCANCEL_ENTRY, this ); - OstTraceFunctionExit1( ESOCKWRAPPERPRIVATE_DOCANCEL_EXIT, this ); - } - -//end of file +void WlanQtUtilsEsockWrapperPrivate::DoCancel() +{ + OstTraceFunctionEntry1(WLANQTUTILSESOCKWRAPPERPRIVATE_DOCANCEL_ENTRY, this); + + // Disconnect, if needed. + DisconnectIap(); + + OstTraceFunctionExit1(WLANQTUTILSESOCKWRAPPERPRIVATE_DOCANCEL_EXIT, this); +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansniffer.pro --- a/wlanutilities/wlansniffer/wlansniffer.pro Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlansniffer/wlansniffer.pro Mon May 24 21:11:39 2010 +0300 @@ -1,5 +1,5 @@ # -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). # All rights reserved. # This component and the accompanying materials are made available # under the terms of "Eclipse Public License v1.0" @@ -12,52 +12,16 @@ # Contributors: # # Description: +# WLAN Sniffer project file. # -TEMPLATE = app -TARGET = wlansniffer -TARGET.CAPABILITY = ALL -TCB -DEPENDPATH += . -# Own headers -INCLUDEPATH += inc \ - traces -# wlanutilities Private API -INCLUDEPATH += ../inc -CONFIG += hb no_icon service - -#Store generated .moc files to their own directory -MOC_DIR = moc - -TRANSLATIONS = wlansniffer.ts - -# Input -SOURCES += src/main.cpp \ - src/wlansniffer.cpp \ - src/wlansnifferlistview.cpp \ - src/wlansniffermainwindow.cpp \ - src/wlansnifferservice.cpp +TEMPLATE = subdirs -HEADERS += inc/wlansniffer.h \ - inc/wlansnifferlistview.h \ - inc/wlansniffermainwindow.h \ - inc/wlansnifferservice.h \ - traces/OstTraceDefinitions.h - -RESOURCES = res/wlansniffer.qrc - -SERVICE.FILE = res/service_conf.xml -SERVICE.OPTIONS = embeddable +SUBDIRS += \ + wlansnifferapplication + +CONFIG += ordered -symbian*::LIBS += -lwlanqtutilities -lxqservice -lxqserviceutil -lqtsysteminfo - -symbian*: { - TARGET.UID3 = 0x10281CAA - SYMBIAN_PLATFORMS = WINSCW ARMV5 - BLD_INF_RULES.prj_exports += "rom/wlansniffer.iby CORE_MW_LAYER_IBY_EXPORT_PATH(wlansniffer.iby)" - BLD_INF_RULES.prj_exports += "rom/wlansniffer_resources.iby LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(wlansniffer_resources.iby)" - addFiles.sources = /epoc32/release/$(PLATFORM)/$(CFG)/wlanqtutilities.dll xqservice.dll xqserviceutil.dll - addFiles.path = /sys/bin - DEPLOYMENT += addFiles - # Enable for QtHighway tracing - # DEFINES += WLANSNIFFER_SERVICETRACES -} +# This enables compiling also the Symbian component from this level +BLD_INF_RULES.prj_exports += \ + "$${LITERAL_HASH}include \"./wlansnifferkeepalive/group/bld.inf\"" diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/inc/wlansniffer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/inc/wlansniffer.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Sniffer application main class. +*/ + +#ifndef WLANSNIFFER_H +#define WLANSNIFFER_H + +// System includes + +#include +#include + +// User includes + +// Forward declarations + +class WlanSnifferEngine; +class HbTranslator; +class WlanSnifferMainWindow; + +// External data types + +// Constants + +// Class declaration + +class WlanSniffer : public HbApplication +{ + Q_OBJECT + +public: + + // Data types + + WlanSniffer(int argc, char* argv[]); + + ~WlanSniffer(); + +signals: + +public slots: + +protected: + +protected slots: + +private: + + Q_DISABLE_COPY(WlanSniffer) + + bool findKeepaliveProcess(); + +private slots: + + void exitApplication(); + +private: // data + + // Not owned data + + // Owned data + WlanSnifferEngine *mEngine; //!< Sniffer engine + QSharedPointer mTranslator; //!< Translator for localisation + QSharedPointer mMainWindow; //!< Main window instance + + // Friend classes +}; + +#endif // WLANSNIFFER_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/inc/wlansnifferengine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/inc/wlansnifferengine.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,149 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Sniffer application engine. +*/ + +#ifndef WLANSNIFFERENGINE_H +#define WLANSNIFFERENGINE_H + +// System includes + +#include +#include +#include +#include + +// User includes + +#include "wlanqtutils.h" + +// Forward declarations + +class WlanSnifferService; +class XQSettingsManager; + +// External data types + +// Constants + +// Class declaration + +class WlanSnifferEngine : public QObject +{ + Q_OBJECT + +public: + + // Data types + + explicit WlanSnifferEngine(QObject *parent = 0); + + ~WlanSnifferEngine(); + + WlanQtUtils *wlanQtUtils() const; + + bool isEmbedded() const; + + void startWlanScanning(); + + void stopWlanScanning(); + + bool masterWlan() const; + + void setMasterWlan(bool enabled); + + bool forceDisableWlan() const; + + bool offlineMode() const; + +signals: + + /*! + Signal indicating that WLAN scan results are available. + */ + void wlanScanReady(); + + /*! + Signal to inform that List View is requested. + + @param [in] title Window title. + */ + void toListView(const QString &title); + + /*! + Signal to inform that application exit was requested. + */ + void exitTriggered(); + + /*! + Signal indicating that the WLAN master status has changed. + + @param [in] enabled Master WLAN status: true if enabled. + */ + void masterWlanStatus(bool enabled); + + /*! + Signal indicating that the force disable WLAN status has changed. + + @param [in] disabled Force disable WLAN status: true if disabled. + */ + void forceDisableWlanStatus(bool disabled); + +public slots: + + void completeService(); + +protected: + + void timerEvent(QTimerEvent *event); + +protected slots: + +private: + + Q_DISABLE_COPY(WlanSnifferEngine) + +private slots: + + void updateSetting(const XQSettingsKey &key, const QVariant &value); + +private: // data + + // Not owned data + + //! WLAN Sniffer service + WlanSnifferService *mService; + + //! Settings manager for platform settings reading, writing & status changes. + XQSettingsManager *mSettingsManager; + + // Owned data + + //! Scan interval is 10 seconds + static const int scanTimerInterval = 10000; + + //! WLAN scan timer ID + int mScanTimerId; + + //! TRUE if embedded + bool mEmbedded; + + //! WLAN Qt Utils instance + QSharedPointer mWlanQtUtils; + + // Friend classes +}; + +#endif // WLANSNIFFERENGINE_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/inc/wlansnifferlistitem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/inc/wlansnifferlistitem.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Sniffer list view list widget item. +*/ + +#ifndef WLANSNIFFERLISTITEM_H +#define WLANSNIFFERLISTITEM_H + +// System includes + +#include +#include + +// User includes + +// Forward declarations + +// External data types + +// Constants + +// Class declaration + +class WlanSnifferListItem : public HbListWidgetItem +{ + +public: + + // Data types + + WlanSnifferListItem(); + + ~WlanSnifferListItem(); + + void setNetworkName(const QString &text); + + void setLeftIcon(const QString &icon); + + void setSignalIcon(const QString &icon); + + void setSecureIcon(const QString &icon); + +signals: + +public slots: + +protected: + +protected slots: + +private: + + Q_DISABLE_COPY(WlanSnifferListItem) + +private slots: + +private: // data + + // Friend classes +}; + +#endif // WLANSNIFFERLISTITEM_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/inc/wlansnifferlistview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/inc/wlansnifferlistview.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,155 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Sniffer List View. +*/ + +#ifndef WLANSNIFFERLISTVIEW_H +#define WLANSNIFFERLISTVIEW_H + +// System includes + +#include +#include +#include +#include +#include + +// User includes + +// Forward declarations + +class HbDocumentLoader; +class HbListWidget; +class HbListWidgetItem; +class HbLabel; +class HbPushButton; +class WlanSnifferMainWindow; +class WlanSnifferListWidget; +class WlanSnifferEngine; +class WlanQtUtilsAp; + +// External data types + +// Constants + +// Class declaration + +class WlanSnifferListView : public HbView +{ + Q_OBJECT + +public: + + // Data types + + WlanSnifferListView( + WlanSnifferEngine *engine, + WlanSnifferMainWindow *mainWindow); + + ~WlanSnifferListView(); + +signals: + + /*! + Signal for triggering WLAN Wizard start. + + @param [in] ap WLAN access point. + */ + + void wizardTriggered(const WlanQtUtilsAp *ap); + +public slots: + +protected: + +protected slots: + +private: + + Q_DISABLE_COPY(WlanSnifferListView) + + void loadDocml(bool isEmbedded); + + void updateWlanStatusLabel(bool enabled); + + void handleConnect(QVariant data); + +private slots: + + void updateListContent(); + + void updateWlanEnabled(); + + void updateConnectionOpened(int iapId); + + void updateConnectionClosed(int iapId); + + void handleContextMenuClosed(); + + void handleListItemActivated(HbListWidgetItem *item); + + void handleListItemLongPressed( + HbListWidgetItem *item, + const QPointF &coords); + + void handleListItemConnect(); + + void handleListItemDisconnect(); + + void handleWlanToggled(); + + void handleWlanEnableDialogClosed(HbAction *action); + +private: // data + + // Owned data + + //! Document loader for list view + QScopedPointer mDocLoader; + //! WLAN Sniffer list view custom widget + QSharedPointer mWlanListWidget; + //! Context menu reference, if one is open + QSharedPointer mContextMenu; + /*! + Data identifying the network for which the context menu has been + opened: WlanQtUtilsAp class, or int IAP ID. + */ + QVariant mContextMenuData; + //! WLAN enabling in airplane mode dialog + QSharedPointer mWlanEnableDialog; + //! Flag for handling WLAN scan result update ignoring + bool mIgnoreWlanScanResults; + //! ID of the IAP we are currently connecting + int mConnectingIapId; + + // Not owned data + + //! WLAN Sniffer engine + WlanSnifferEngine *mEngine; + //! WLAN ON/OFF switch action + HbAction *mSwitchWlanAction; + //! Add WLAN manually action + HbAction *mAddWlanAction; + //! WLAN Sniffer list view widget + HbListWidget *mWlanList; + //! WLAN Status label + HbLabel *mStatusLabel; + //! WLAN ON/OFF button + HbPushButton *mWlanButton; + + // Friend classes +}; + +#endif // WLANSNIFFERLISTVIEW_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/inc/wlansnifferlistwidget.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/inc/wlansnifferlistwidget.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,135 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Sniffer list widget class. +*/ + +#ifndef WLANSNIFFERLISTWIDGET_H +#define WLANSNIFFERLISTWIDGET_H + +// System includes + +#include +#include +#include + +// User includes + +// Forward declarations + +class HbListWidget; +class HbListWidgetItem; +class WlanSnifferListItem; +class WlanQtUtilsIap; +class WlanQtUtilsAp; + +// External data types + +// Constants + +// Class declaration + +class WlanSnifferListWidget +{ + +public: + + // Data types + + /*! + Signal strength category boundaries in dB (absolute value). + Smaller value means better signal. + */ + enum + { + SignalStrengthHigh = 65, //!< High signal strength + SignalStrengthMedium = 79 //!< Medium signal strength + }; + + explicit WlanSnifferListWidget(HbListWidget *listWidget); + + virtual ~WlanSnifferListWidget(); + + void updateContent( + QList< QSharedPointer > &iaps, + QList< QSharedPointer > &aps, + int connectedIapId); + + void scrollTo(int row); + +signals: + +public slots: + +protected: + +protected slots: + +private: + + Q_DISABLE_COPY(WlanSnifferListWidget) + + void sortIaps( + QList< QSharedPointer > &iaps, + int connectedIapId); + + void sortAps( + QList< QSharedPointer > &aps); + + static bool iapLessThan( + const QSharedPointer iap1, + const QSharedPointer iap2); + + static bool apLessThan( + const QSharedPointer ap1, + const QSharedPointer ap2); + + WlanSnifferListItem *findFromOldList(QSharedPointer iap); + + WlanSnifferListItem *findFromOldList(QSharedPointer ap); + + HbListWidgetItem *listItemCreate( + QSharedPointer iap, + int connectedIapId); + + HbListWidgetItem *listItemCreate(QSharedPointer ap); + + QString signalStrengthIconChoose(int signalStrength); + + QString leftIconChoose(int iapId, int connectedIapId); + + void removeLostItems( + const QList< QSharedPointer > &iaps, + const QList< QSharedPointer > &aps); + + void addDiscoveredItemsAndUpdateRest( + const QList< QSharedPointer > &iaps, + const QList< QSharedPointer > &aps, + int connectedIapId); + + void traceListContent() const; + +private slots: + +private: // data + + // Not owned data + HbListWidget *mListWidget; //!< WLAN list view widget + + // Owned data + + // Friend classes +}; + +#endif // WLANSNIFFERLISTWIDGET_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/inc/wlansniffermainwindow.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/inc/wlansniffermainwindow.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Sniffer main window. +*/ + +#ifndef WLANSNIFFERMAINWINDOW_H +#define WLANSNIFFERMAINWINDOW_H + +// System includes + +#include +#include +#include + +// User includes + +#include "wlansniffer.h" + +// Forward declarations + +class WlanWizard; +class WlanSnifferListView; +class WlanQtUtilsAp; +class WlanSnifferEngine; + +// External data types + +// Constants + +// Class declaration + +class WlanSnifferMainWindow : public HbMainWindow +{ + Q_OBJECT + +public: + + // Data types + + explicit WlanSnifferMainWindow(WlanSnifferEngine *engine); + + ~WlanSnifferMainWindow(); + +signals: + +public slots: + + void toListView(const QString &title); + +protected: + +protected slots: + +private: + + Q_DISABLE_COPY(WlanSnifferMainWindow) + + void addListView(); + +private slots: + + void startWlanWizard(const WlanQtUtilsAp *ap); + + void handleWlanWizardComplete(int iapId, bool connected); + + void handleWlanWizardCancelled(); + +private: // data + + // Owned data + + WlanWizard *mWizard; //!< WLAN Wizard object + WlanSnifferListView *mListView; //!< List view object + + // Not owned data + + WlanSnifferEngine *mEngine; //!< WLAN Sniffer engine + + // Friend classes +}; + +#endif // WLANSNIFFERMAINWINDOW_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/inc/wlansnifferservice.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/inc/wlansnifferservice.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Sniffer QtHighway Service. +*/ + +#ifndef WLANSNIFFERSERVICE_H +#define WLANSNIFFERSERVICE_H + +// System includes + +#include +#include + +// User includes + +// Forward declarations + +// External data types + +// Constants + +// Class declaration +class WlanSnifferService: public XQServiceProvider +{ + Q_OBJECT + +public: + + // Data types + + explicit WlanSnifferService(QObject *parent = 0); + + ~WlanSnifferService(); + + void complete(); + +signals: + + /*! + Signal to inform WLAN Sniffer that List View is requested. + + @param [in] title Window title. + */ + void toListView(const QString &title); + + /*! + Signal to inform WLAN Sniffer that exit was requested. + */ + void exitTriggered(); + +public slots: + + void listView(); + +protected: + +protected slots: + +private: + + Q_DISABLE_COPY(WlanSnifferService) + + QString title() const; + +private slots: + +private: // data + + // Not owned data + + // Owned data + int mAsyncRequestIndex; //!< Service request ID + + // Friend classes +}; + +#endif // WLANSNIFFERSERVICE_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/res/hblistviewitem.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/res/hblistviewitem.css Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,26 @@ + +HbListViewItem[layoutName="wlanlistitem"]{ + layout:wlanlistitem; +} + +HbListViewItem::icon-1[layoutName="wlanlistitem"]{ + fixed-height: var(hb-param-graphic-size-primary-small); + fixed-width: var(hb-param-graphic-size-primary-small); +} + +HbListViewItem::text-1[layoutName="wlanlistitem"]{ + text-height: var(hb-param-text-height-primary); + font-variant: primary; + pref-width:-1; + text-align: left; +} + +HbListViewItem::icon-2[layoutName="wlanlistitem"]{ + fixed-height: var(hb-param-graphic-size-secondary); + fixed-width: var(hb-param-graphic-size-secondary); +} + +HbListViewItem::icon-3[layoutName="wlanlistitem"]{ + fixed-height: var(hb-param-graphic-size-secondary); + fixed-width: var(hb-param-graphic-size-secondary); +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/res/hblistviewitem.widgetml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/res/hblistviewitem.widgetml Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/res/service_conf.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/res/service_conf.xml Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,11 @@ + + + wlansniffer + No path + WLAN Sniffer + + com.nokia.symbian.IWlanSniffer + 1.0 + WLAN Sniffer List View + + diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/res/wlansniffer.qrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/res/wlansniffer.qrc Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,11 @@ + + + + wlansnifferlistview.docml + + + + hblistviewitem.css + hblistviewitem.widgetml + + diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/res/wlansnifferlistview.docml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/res/wlansnifferlistview.docml Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +
+
+ + + + + + + + + + + + + +
+ + + + + + diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/rom/wlansniffer.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/rom/wlansniffer.iby Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Sniffer Application iby. +*/ + +#ifndef WLANSNIFFER_IBY +#define WLANSNIFFER_IBY + +#include + +#ifdef __PROTOCOL_WLAN + +#define UPGRADABLE_APP_REG_RSC(NAME) data=DATAZ_\PRIVATE\10003A3F\IMPORT\APPS\ ## NAME ## _reg.rsc Private\10003a3f\import\apps\ ## NAME ## _reg.rsc + +S60_APP_EXE(wlansniffer) +S60_APP_RESOURCE(wlansniffer) +UPGRADABLE_APP_REG_RSC(wlansniffer) + +#endif // __PROTOCOL_WLAN + +#endif // WLANSNIFFER_IBY diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/rom/wlansniffer_resources.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/rom/wlansniffer_resources.iby Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Sniffer Application resource iby. +*/ + +#ifndef WLANSNIFFER_RESOURCES_IBY +#define WLANSNIFFER_RESOURCES_IBY + +#include +#include + +#ifdef __PROTOCOL_WLAN + +data=DATAZ_/QT_TRANSLATIONS_DIR/wlansniffer.qm QT_TRANSLATIONS_DIR/wlansniffer.qm + +#endif // __PROTOCOL_WLAN + +#endif // WLANSNIFFER_RESOURCES_IBY diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/src/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/src/main.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Sniffer application main function. +*/ + +// System includes + +#ifdef WLANSNIFFER_SERVICETRACES +#include +#endif +#include + +// User includes + +#include "wlansniffer.h" + +// External function prototypes + +// Local constants + +int main(int argc, char *argv[]) +{ + // Check WLAN dynamic configuration & exit if WLAN is not enabled + QtMobility::QSystemInfo sysinfo; + if (!sysinfo.hasFeatureSupported(QtMobility::QSystemInfo::WlanFeature)) { + return -1; + } + +#ifdef WLANSNIFFER_SERVICETRACES + qInstallMsgHandler(XQSERVICEMESSAGEHANDLER); +#endif + + WlanSniffer app(argc, argv); + + return app.exec(); +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/src/wlansniffer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/src/wlansniffer.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,142 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Sniffer application main class implementation. +*/ + +// System includes + +#include +#include +#include + +// User includes + +#include "wlansnifferengine.h" +#include "wlansniffermainwindow.h" +#include "wlansniffer.h" + +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wlansnifferTraces.h" +#endif + +/*! + \class WlanSniffer + \brief WLAN Sniffer main class implementation. +*/ + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +/*! + Constructor. + + @param [in] argc Parameter count. + @param [in] argv Parameters. + */ + +WlanSniffer::WlanSniffer(int argc, char* argv[]) : + HbApplication(argc, argv), + mEngine(new WlanSnifferEngine(this)), + mTranslator(new HbTranslator()), + mMainWindow(0) +{ + OstTraceFunctionEntry0(WLANSNIFFER_WLANSNIFFER_ENTRY); + + // Install also common localization + mTranslator->loadCommon(); + + mMainWindow = QSharedPointer( + new WlanSnifferMainWindow(mEngine)); + + // Connect exit handling + bool connectStatus = connect( + mEngine, + SIGNAL(exitTriggered()), + this, + SLOT(exitApplication())); + Q_ASSERT(connectStatus); + + // Start the Wlan Sniffer Keepalive process, if not started yet + // The purpose of the process is to manage Wlan links opened + // by this application, and the process should be running always + // after the first launch of this application. + if (findKeepaliveProcess() == false) { + QProcess::startDetached("wlansnifferkeepalive"); + } + + OstTraceFunctionExit0(WLANSNIFFER_WLANSNIFFER_EXIT); +} + +/*! + Destructor. + */ + +WlanSniffer::~WlanSniffer() +{ + OstTraceFunctionEntry0(WLANSNIFFER_WLANSNIFFERDESTR_ENTRY); + OstTraceFunctionExit0(WLANSNIFFER_WLANSNIFFERDESTR_EXIT); +} + +/*! + Function for finding possible running keepalive process. + + @return TRUE if a keepalive process was found running. + */ + +bool WlanSniffer::findKeepaliveProcess() +{ + OstTraceFunctionEntry0(WLANSNIFFER_FINDKEEPALIVEPROCESS_ENTRY); + + // Try to search the keepalive process + bool found = false; + TFileName executableName; + executableName.Copy(_L("wlansnifferkeepalive*")); + TFindProcess processSearch; + TFullName processFullName; + while (processSearch.Next(processFullName) == KErrNone) { + if (processFullName.Match(executableName) != KErrNotFound) { + found = true; + break; + } + } + + OstTraceExt1( + TRACE_NORMAL, + WLANSNIFFER_FINDKEEPALIVEPROCESS_RESULT, + "WlanSniffer::findKeepaliveProcess;found=%hhu", + found); + + OstTraceFunctionExit0(WLANSNIFFER_FINDKEEPALIVEPROCESS_EXIT); + return found; +} + +/*! + Slot for handling application exit. + */ + +void WlanSniffer::exitApplication() +{ + OstTraceFunctionEntry0(WLANSNIFFER_EXITAPPLICATION_ENTRY); + + exit(); + + OstTraceFunctionExit0(WLANSNIFFER_EXITAPPLICATION_EXIT); +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/src/wlansnifferengine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/src/wlansnifferengine.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,419 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Sniffer application engine. +*/ + +// System includes + +#include + +#include +#include +#include +#include + +// User includes + +#include "wlanqtutils.h" +#include "wlansnifferservice.h" +#include "wlansnifferengine.h" + +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wlansnifferengineTraces.h" +#endif + +/*! + \class WlanSnifferEngine + \brief WLAN Sniffer application engine. + + This class implements the WLAN Sniffer application engine. + The purpose of the engine implementation is to gather all non-UI + implementation base functionality into one place that can be utilized + from multiple places (i.e. multiple views and windows). +*/ + + +// External function prototypes + +// Local constants + +//! Master WLAN ON/OFF setting key +static const XQSettingsKey masterWlanKey( + XQSettingsKey::TargetCentralRepository, + KCRUidWlanDeviceSettingsRegistryId.iUid, + KWlanOnOff); + +//! WLAN forced OFF setting key +static const XQSettingsKey wlanForceKey( + XQSettingsKey::TargetCentralRepository, + KCRUidWlanDeviceSettingsRegistryId.iUid, + KWlanForceDisable); + +//! Offline mode setting key +static const XQSettingsKey offlineKey( + XQSettingsKey::TargetPublishAndSubscribe, + KPSUidStartup.iUid, + KPSGlobalSystemState); + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +/*! + Constructor. + + @param [in] parent Parent object. + */ + +WlanSnifferEngine::WlanSnifferEngine(QObject *parent) : + QObject(parent), + mService(new WlanSnifferService(this)), + mSettingsManager(new XQSettingsManager(this)), + mScanTimerId(0), + mEmbedded(false), + mWlanQtUtils(new WlanQtUtils()) +{ + OstTraceFunctionEntry0(WLANSNIFFERENGINE_WLANSNIFFERENGINE_ENTRY); + + // Subscribe for WLAN status change indications + bool connectStatus = connect( + mSettingsManager, + SIGNAL(valueChanged(XQSettingsKey, QVariant)), + this, + SLOT(updateSetting(XQSettingsKey, QVariant))); + Q_ASSERT(connectStatus); + mSettingsManager->startMonitoring(masterWlanKey); + mSettingsManager->startMonitoring(wlanForceKey); + + // Connect WLAN Sniffer service signals + connectStatus = connect( + mService, + SIGNAL(toListView(QString)), + this, + SIGNAL(toListView(QString))); + Q_ASSERT(connectStatus == true); + connectStatus = connect( + mService, + SIGNAL(returnValueDelivered()), + this, + SIGNAL(exitTriggered())); + Q_ASSERT(connectStatus == true); + + // Store WLAN Sniffer service embedded status + mEmbedded = XQServiceUtil::isEmbedded(); + + OstTraceFunctionExit0(WLANSNIFFERENGINE_WLANSNIFFERENGINE_EXIT); +} + +/*! + Destructor. + */ + +WlanSnifferEngine::~WlanSnifferEngine() +{ + OstTraceFunctionEntry0(DUP1_WLANSNIFFERENGINE_WLANSNIFFERENGINE_ENTRY); + OstTraceFunctionExit0(DUP1_WLANSNIFFERENGINE_WLANSNIFFERENGINE_EXIT); +} + +/*! + Getter function for WLAN Qt Utilities instance owned by + this class. The whole WLAN Sniffer application uses the same + instance, and thus the reference is needed also in other classes. + + @return WLAN Qt Utilities object. + */ + +WlanQtUtils *WlanSnifferEngine::wlanQtUtils() const +{ + OstTraceFunctionEntry0(WLANSNIFFERENGINE_WLANQTUTILS_ENTRY); + + // The reference must never be null. + Q_ASSERT(mWlanQtUtils.data()); + + OstTraceFunctionExit0(WLANSNIFFERENGINE_WLANQTUTILS_EXIT); + return mWlanQtUtils.data(); +} + +/*! + Getter for WLAN Sniffer service embedded property. + + @return TRUE if WLAN Sniffer is used as an embedded service. + */ + +bool WlanSnifferEngine::isEmbedded() const +{ + OstTraceFunctionEntry0(WLANSNIFFERENGINE_ISEMBEDDED_ENTRY); + OstTraceFunctionExit0(WLANSNIFFERENGINE_ISEMBEDDED_EXIT); + return mEmbedded; +} + +/*! + Starts periodic WLAN Scanning. + It is allowed to call this function also when the scanning is already ON. + If so, the timer is not restarted but the scan period stays untouched. + */ + +void WlanSnifferEngine::startWlanScanning() +{ + OstTraceFunctionEntry0(WLANSNIFFERENGINE_STARTWLANSCANNING_ENTRY); + + // A valid timer ID means scan is ON + if (mScanTimerId == 0) { + OstTrace0( + TRACE_NORMAL, + WLANSNIFFERENGINE_STARTWLANSCANNING, + "WlanSnifferEngine::startWlanScanning Periodic WLAN scanning starting"); + + // Connect signal forwarding + bool connectStatus = connect( + mWlanQtUtils.data(), + SIGNAL(wlanScanReady()), + this, + SIGNAL(wlanScanReady())); + Q_ASSERT(connectStatus); + + // Start the first scan + mWlanQtUtils->scanWlans(); + + // Start timer for the next scan + mScanTimerId = startTimer(scanTimerInterval); + + // The timer start must succeed + Q_ASSERT(mScanTimerId != 0); + } + + OstTraceFunctionExit0(WLANSNIFFERENGINE_STARTWLANSCANNING_EXIT); +} + +/*! + Stops periodic WLAN Scanning. + It is allowed to call this function also when periodic scanning is OFF. + */ + +void WlanSnifferEngine::stopWlanScanning() +{ + OstTraceFunctionEntry0(WLANSNIFFERENGINE_STOPWLANSCANNING_ENTRY); + + // A valid timer ID means scan is ON + if (mScanTimerId != 0) { + OstTrace0( + TRACE_NORMAL, + WLANSNIFFERENGINE_STOPWLANSCANNING, + "WlanSnifferEngine::stopWlanScanning Periodic WLAN scanning stopped"); + + // Disconnect signal forwarding + disconnect( + mWlanQtUtils.data(), + SIGNAL(wlanScanReady()), + this, + SIGNAL(wlanScanReady())); + + killTimer(mScanTimerId); + mScanTimerId = 0; + } + + OstTraceFunctionExit0(WLANSNIFFERENGINE_STOPWLANSCANNING_EXIT); +} + +/*! + Function for getting the master WLAN status. + + @return Master WLAN status: true if enabled, otherwise false. +*/ + +bool WlanSnifferEngine::masterWlan() const +{ + OstTraceFunctionEntry1(WLANSNIFFERENGINE_MASTERWLAN_ENTRY, this); + + // Read WLAN ON/OFF setting from Cenrep + int wlanEnabled = mSettingsManager->readItemValue(masterWlanKey).toInt(); + + OstTrace1( + TRACE_NORMAL, + WLANSNIFFERENGINE_MASTERWLAN, + "WlanSnifferEngine::masterWlan;enabled=%d", + wlanEnabled); + + OstTraceFunctionExit1(WLANSNIFFERENGINE_MASTERWLAN_EXIT, this); + return wlanEnabled ? true : false; +} + +/*! + Function for switching the master WLAN status ON or OFF. + + @param [in] enabled If set to true, WLAN is switched ON, and vice versa. +*/ + +void WlanSnifferEngine::setMasterWlan(bool enabled) +{ + OstTraceFunctionEntry1(WLANSNIFFERENGINE_SETMASTERWLAN_ENTRY, this); + + OstTraceExt1( + TRACE_NORMAL, + WLANSNIFFERENGINE_SETMASTERWLAN, + "WlanSnifferEngine::setMasterWlan;enabled=%hhu", + enabled); + + // Store WLAN ON/OFF setting to Cenrep + int wlanEnabled = enabled ? 1 : 0; + bool writeStatus = mSettingsManager->writeItemValue(masterWlanKey, wlanEnabled); + Q_ASSERT(writeStatus); + + OstTraceFunctionExit1(WLANSNIFFERENGINE_SETMASTERWLAN_EXIT, this); +} + +/*! + Function for getting the force disable WLAN status. + + @return forced WLAN status: true if disabled, otherwise false. +*/ + +bool WlanSnifferEngine::forceDisableWlan() const +{ + OstTraceFunctionEntry1(WLANSNIFFERENGINE_FORCEDISABLEWLAN_ENTRY, this); + + // Read force disable WLAN ON/OFF setting from Cenrep + int wlanDisabled = mSettingsManager->readItemValue(wlanForceKey).toInt(); + + OstTrace1( + TRACE_NORMAL, + WLANSNIFFERENGINE_FORCEDISABLEWLAN, + "WlanSnifferEngine::forceDisableWlan;wlanDisabled=%d", + wlanDisabled); + + OstTraceFunctionEntry1(WLANSNIFFERENGINE_FORCEDISABLEWLAN_EXIT, this); + return wlanDisabled ? true : false; +} + +/*! + Function for getting the offline mode status. + + @return Offline mode status: true if offline, otherwise false. +*/ + +bool WlanSnifferEngine::offlineMode() const +{ + OstTraceFunctionEntry1(WLANSNIFFERENGINE_OFFLINEMODE_ENTRY, this); + + // Read offline mode setting from Cenrep + int systemState = mSettingsManager->readItemValue(offlineKey).toInt(); + + bool offline = false; + if (ESwStateNormalRfOff == systemState) { + offline = true; + } + + OstTraceExt1( + TRACE_NORMAL, + WLANSNIFFERENGINE_OFFLINEMODE, + "WlanSnifferEngine::offlineMode;offline=%hhu", + offline); + + OstTraceFunctionExit1(WLANSNIFFERENGINE_OFFLINEMODE_EXIT, this); + return offline; +} + +/*! + Function for completing the running WLAN Sniffer service. + This function must only be ran if a WLAN Sniffer service is running. + */ + +void WlanSnifferEngine::completeService() +{ + OstTraceFunctionEntry0(WLANSNIFFERENGINE_COMPLETESERVICE_ENTRY); + + mService->complete(); + + OstTraceFunctionExit0(WLANSNIFFERENGINE_COMPLETESERVICE_EXIT); +} + +/*! + This function (from QObject) handles timers. Initiates a new WLAN scan. + + @param [in] event Timer event. + */ + +void WlanSnifferEngine::timerEvent(QTimerEvent *event) +{ + OstTraceFunctionEntry0(WLANSNIFFERENGINE_TIMEREVENT_ENTRY); + + int timerId = event->timerId(); + + OstTrace1( + TRACE_NORMAL, + WLANSNIFFERENGINE_TIMEREVENT, + "WlanSnifferEngine::timerEvent;timerId=%d", + timerId); + + // WLAN scan timer is the only used timer + Q_ASSERT(timerId == mScanTimerId); + + // Request a new scan. Timer events come periodically. + mWlanQtUtils->scanWlans(); + + OstTraceFunctionExit0(WLANSNIFFERENGINE_TIMEREVENT_EXIT); +} + +/*! + Slot for updating settings. + + @param [in] key The changed key setting. + @param [in] value The new value of the setting. +*/ + +void WlanSnifferEngine::updateSetting( + const XQSettingsKey &key, + const QVariant &value) +{ + OstTraceFunctionEntry1(WLANSNIFFERENGINE_UPDATESETTING_ENTRY, this); + + // Check that the key is WLAN ON/OFF, or wlanForceDisable since + // they are the only supported keys + Q_ASSERT( + key.target() == masterWlanKey.target() || + key.target() == wlanForceKey.target()); + Q_ASSERT( + key.uid() == masterWlanKey.uid() || + key.uid() == wlanForceKey.uid()); + Q_ASSERT( + key.key() == masterWlanKey.key() || + key.key() == wlanForceKey.key()); + + bool ok; + bool boolean = value.toInt(&ok) ? true : false; + Q_ASSERT(ok); + + // The updated key can be either the KWlanOnOff or the KWlanForceDisable + if (key.key() == wlanForceKey.key()) { + // Inform about WlanForceDisable status change + OstTraceExt1( + TRACE_NORMAL, + WLANSNIFFERENGINE_UPDATESETTING_WLANFORCEDISABLE, + "WlanSnifferEngine::emit forceWlanStatus;forcedWlanDisabled=%hhu", + boolean); + emit forceDisableWlanStatus(boolean); + } else { + // Inform about WLAN ON/OFF status change + OstTraceExt1( + TRACE_NORMAL, + WLANSNIFFERENGINE_UPDATESETTING_WLANONOFF, + "WlanSnifferEngine::emit masterWlanStatus;wlanEnabled=%hhu", + boolean); + emit masterWlanStatus(boolean); + } + + OstTraceFunctionExit1(WLANSNIFFERENGINE_UPDATESETTING_EXIT, this); +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/src/wlansnifferlistitem.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/src/wlansnifferlistitem.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,116 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Sniffer list view list widget item. +*/ + +// System includes + +#include + +// User includes + +#include "wlansnifferlistitem.h" + +/*! + \class WlanSnifferListItem + \brief This class implements the custom list widget item used in + WLAN Sniffer list view. +*/ + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +/*! + Constructor. +*/ + +WlanSnifferListItem::WlanSnifferListItem() : HbListWidgetItem() +{ + // Fill data model with empty icons to work as a skeleton + QVariantList decoratorList; + decoratorList << HbIcon() << HbIcon() << HbIcon(); + setData(decoratorList, Qt::DecorationRole); + + // Fill data model with empty text to work as a skeleton + QVariantList displayList; + displayList << QString(); + setData(displayList, Qt::DisplayRole); +} + +/*! + Destructor. +*/ + +WlanSnifferListItem::~WlanSnifferListItem() +{ +} + +/*! + List item network name setting function. + + @param [in] name Network name to set. + */ + +void WlanSnifferListItem::setNetworkName(const QString &name) +{ + setText(name); +} + +/*! + List item left icon setting function. + + @param [in] icon Icon logical name. + */ + +void WlanSnifferListItem::setLeftIcon(const QString &icon) +{ + setIcon(HbIcon(icon)); +} + +/*! + List item signal strength icon setting function. + + @param [in] icon Icon logical name. + */ + +void WlanSnifferListItem::setSignalIcon(const QString &icon) +{ + setSecondaryIcon(HbIcon(icon)); +} + +/*! + List item secure icon setting function. + + @param [in] icon Icon logical name. + */ + +void WlanSnifferListItem::setSecureIcon(const QString &icon) +{ + // Fetch the current decorators (icons) + QVariant decorators = data(Qt::DecorationRole); + Q_ASSERT(decorators.canConvert()); + QVariantList decoratorList = decorators.toList(); + // There must always be three icons + Q_ASSERT(decoratorList.count() == 3); + + // Replace old icon + decoratorList[2] = HbIcon(icon); + setData(decoratorList, Qt::DecorationRole); +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/src/wlansnifferlistview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/src/wlansnifferlistview.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,655 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Sniffer List View. +*/ + +// System includes + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +// User includes + +#include "wlanqtutils.h" +#include "wlanqtutilsap.h" +#include "wlanqtutilsiap.h" + +#include "wlansnifferengine.h" +#include "wlansniffermainwindow.h" +#include "wlansnifferlistview.h" +#include "wlansnifferlistitem.h" +#include "wlansnifferlistwidget.h" + +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wlansnifferlistviewTraces.h" +#endif + +/*! + \class WlanSnifferListView + \brief WLAN Sniffer application's list view implementation. +*/ + +// External function prototypes + +// Local constants + +//! WLAN Sniffer list view docml file location +static const QString WlanSnifferListViewDocml(":/docml/wlansnifferlistview.docml"); + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +/*! + Constructor. + + @param [in] engine WLAN Sniffer application engine. + @param [in] mainWindow WLAN Sniffer main window. +*/ + +WlanSnifferListView::WlanSnifferListView( + WlanSnifferEngine *engine, + WlanSnifferMainWindow *mainWindow) : + mDocLoader(new HbDocumentLoader(mainWindow)), + mWlanListWidget(), + mContextMenu(), + mContextMenuData(), + mWlanEnableDialog(), + mIgnoreWlanScanResults(false), + mConnectingIapId(WlanQtUtils::IapIdNone), + mEngine(engine), + mSwitchWlanAction(0), + mAddWlanAction(0), + mWlanList(0), + mStatusLabel(0), + mWlanButton(0) +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_WLANSNIFFERLISTVIEW_ENTRY); + + // Start scanning immediately to get the first scan results as soon as + // possible, since the scanning takes time. + if (mEngine->masterWlan() && !mEngine->forceDisableWlan()) { + mEngine->startWlanScanning(); + } + + // Initialize UI from the docml based on standalone/embedded status + loadDocml(mEngine->isEmbedded()); + + if (mEngine->isEmbedded()) { + // We need to create a custom navigation action and handle exiting + // from the application differently in case the application was + // launched as embedded via QtHighway + HbAction *completeAction = new HbAction(Hb::BackNaviAction, this); + setNavigationAction(completeAction); + bool connectStatus = connect( + completeAction, + SIGNAL(triggered(bool)), + mEngine, + SLOT(completeService())); + Q_ASSERT(connectStatus); + } + + // Connect WLAN network open & close signals + bool connectStatus = connect( + mEngine->wlanQtUtils(), + SIGNAL(wlanNetworkOpened(int)), + this, + SLOT(updateConnectionOpened(int))); + Q_ASSERT(connectStatus); + connectStatus = connect( + mEngine->wlanQtUtils(), + SIGNAL(wlanNetworkClosed(int, int)), + this, + SLOT(updateConnectionClosed(int))); // "reason" parameter ignored + Q_ASSERT(connectStatus); + + // Connect WLAN ON/OFF setting change signal + connectStatus = connect( + mEngine, + SIGNAL(masterWlanStatus(bool)), + this, + SLOT(updateWlanEnabled())); + Q_ASSERT(connectStatus); + + // Connect Force Disable WLAN setting change signal + connectStatus = connect( + mEngine, + SIGNAL(forceDisableWlanStatus(bool)), + this, + SLOT(updateWlanEnabled())); + Q_ASSERT(connectStatus); + + // Connect signals to catch user interaction with the WLAN network list + connectStatus = connect( + mWlanList, + SIGNAL(activated(HbListWidgetItem *)), + this, + SLOT(handleListItemActivated(HbListWidgetItem *))); + Q_ASSERT(connectStatus); + connectStatus = connect( + mWlanList, + SIGNAL(longPressed(HbListWidgetItem *, QPointF)), + this, + SLOT(handleListItemLongPressed(HbListWidgetItem *, QPointF))); + Q_ASSERT(connectStatus); + + // Connect signals to catch user interaction with WLAN ON/OFF switching + connectStatus = connect( + mWlanButton, + SIGNAL(clicked(bool)), + this, + SLOT(handleWlanToggled())); + Q_ASSERT(connectStatus); + connectStatus = connect( + mSwitchWlanAction, + SIGNAL(triggered(bool)), + this, + SLOT(handleWlanToggled())); + Q_ASSERT(connectStatus); + + // Connect WLAN scan results signal + connectStatus = connect( + mEngine, + SIGNAL(wlanScanReady()), + this, + SLOT(updateListContent())); + Q_ASSERT(connectStatus); + + // Set the initial value of WLAN state + updateWlanEnabled(); + + OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_WLANSNIFFERLISTVIEW_EXIT); +} + +/*! + Destructor. +*/ + +WlanSnifferListView::~WlanSnifferListView() +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_WLANSNIFFERLISTVIEWDESTR_ENTRY); + OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_WLANSNIFFERLISTVIEWDESTR_EXIT); +} + +/*! + Loading of WLAN Sniffer List View docml. + + @param [in] isEmbedded TRUE if WLAN Sniffer is launched as embedded. +*/ + +void WlanSnifferListView::loadDocml(bool isEmbedded) +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_LOADDOCML_ENTRY); + + bool ok = false; + // First load the common section + mDocLoader->load(WlanSnifferListViewDocml, &ok); + Q_ASSERT(ok); + + // Then load the mode specific section + if (isEmbedded) { + mDocLoader->load(WlanSnifferListViewDocml, "embedded", &ok); + } else { + mDocLoader->load(WlanSnifferListViewDocml, "standalone", &ok); + } + Q_ASSERT(ok); + + // Load the view by name from the xml file + QGraphicsWidget *widget = mDocLoader->findWidget("occ_list"); + Q_ASSERT(widget); + // Set the WlanListView view to be the widget that was loaded from the xml + setWidget(widget); + + // Set view menu + HbMenu *viewMenu = qobject_cast(mDocLoader->findWidget("viewMenu")); + Q_ASSERT(viewMenu); + setMenu(viewMenu); + + // WLAN Sniffer list widget takes responsibility of the list widget behaviour + mWlanList = qobject_cast(mDocLoader->findWidget("listWidget")); + Q_ASSERT(mWlanList); + mWlanListWidget = QSharedPointer(new WlanSnifferListWidget(mWlanList)); + + // Retrieve pointers to widgets we need to access from the code + mSwitchWlanAction = qobject_cast(mDocLoader->findObject("switchWlanAction")); + Q_ASSERT(mSwitchWlanAction); + + mAddWlanAction = qobject_cast(mDocLoader->findObject("addWlanAction")); + Q_ASSERT(mAddWlanAction); + + mWlanButton = qobject_cast(mDocLoader->findWidget("wlanButton")); + Q_ASSERT(mWlanButton); + + mStatusLabel = qobject_cast(mDocLoader->findWidget("statusLabel")); + Q_ASSERT(mStatusLabel); + + OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_LOADDOCML_EXIT); +} + +/*! + Updates WLAN status label based on current WLAN status. + + @param [in] enabled True if WLAN is enabled. +*/ + +void WlanSnifferListView::updateWlanStatusLabel(bool enabled) +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_UPDATEWLANSTATUSLABEL_ENTRY); + + QString status; + if (!enabled) { + // WLAN is OFF + status = hbTrId("txt_occ_grid_wlan_is_switched_off"); + } else { + int iapId = mEngine->wlanQtUtils()->activeIap(); + + switch (mEngine->wlanQtUtils()->connectionStatus()) { + case WlanQtUtils::ConnStatusConnecting: + // WLAN is connecting + Q_ASSERT(iapId != WlanQtUtils::IapIdNone); + status = hbTrId("txt_occ_grid_connecting_to_1").arg( + mEngine->wlanQtUtils()->iapName(iapId)); + break; + + case WlanQtUtils::ConnStatusConnected: + // WLAN is connected + Q_ASSERT(iapId != WlanQtUtils::IapIdNone); + status = hbTrId("txt_occ_grid_connected_to_1").arg( + mEngine->wlanQtUtils()->iapName(iapId)); + break; + + default: + // WLAN is disconnected + status = hbTrId("txt_occ_grid_not_connected"); + break; + } + } + mStatusLabel->setPlainText(status); + + OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_UPDATEWLANSTATUSLABEL_EXIT); +} + +/*! + Handles a "Connect" action for the selected IAP or AP item. + + @param data IAP ID (int), or AP class (WlanQtUtilsAp) to connect. +*/ + +void WlanSnifferListView::handleConnect(QVariant data) +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_HANDLECONNECT_ENTRY); + + // Check whether we need to disconnect a previous connection first + int activeWlanId = mEngine->wlanQtUtils()->activeIap(); + + // Get IAP ID if IAP is available + int iapId = WlanQtUtils::IapIdNone; + if (data.canConvert()) { + iapId = data.toInt(); + } + OstTraceExt2( + TRACE_NORMAL, + WLANSNIFFERLISTVIEW_HANDLECONNECT, + "WlanSnifferListView::handleConnect;activeWlanId=%d;iapId=%d", + activeWlanId, + iapId); + + // Skip connecting if the IAP is already connected + if (activeWlanId != WlanQtUtils::IapIdNone && iapId == activeWlanId) { + return; + } + + if (activeWlanId != WlanQtUtils::IapIdNone) { + mEngine->wlanQtUtils()->disconnectIap(activeWlanId); + + // Update list widget so that the IAP is no longer connected + updateListContent(); + } + + if (iapId != WlanQtUtils::IapIdNone) { + // Item was an IAP, connect it. + mConnectingIapId = iapId; + mStatusLabel->setPlainText( + hbTrId("txt_occ_grid_connecting_to_1").arg( + mEngine->wlanQtUtils()->iapName(iapId))); + mEngine->wlanQtUtils()->connectIap(iapId); + } else { + // Item is a WLAN AP. Summon the Wlan Wizard to handle creation + // of the IAP and connecting it. + Q_ASSERT(data.canConvert()); + WlanQtUtilsAp ap = data.value(); + emit wizardTriggered(&ap); + } + + OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_HANDLECONNECT_EXIT); +} + +/*! + Updates WLAN list widget with new WLAN scan results. +*/ + +void WlanSnifferListView::updateListContent() +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_UPDATELISTCONTENT_ENTRY); + + if (!mIgnoreWlanScanResults) { + // Get the latest scan results + QList< QSharedPointer > iaps; + QList< QSharedPointer > aps; + mEngine->wlanQtUtils()->availableWlans(iaps, aps); + + // Check for connected IAP + int iapId = WlanQtUtils::IapIdNone; + if (mEngine->wlanQtUtils()->connectionStatus() == + WlanQtUtils::ConnStatusConnected) { + iapId = mEngine->wlanQtUtils()->activeIap(); + } + + // Let the list widget class update the list content + mWlanListWidget->updateContent(iaps, aps, iapId); + } + + OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_UPDATELISTCONTENT_EXIT); +} + +/*! + WLAN state settings change handler. This slot handles both the + WLAN ON/OFF setting and WLAN forced OFF setting. + Updates all WLAN ON/OFF related (UI) elements. +*/ + +void WlanSnifferListView::updateWlanEnabled() +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_UPDATEWLANENABLED_ENTRY); + + // Check the updated setting status + bool forcedOff = mEngine->forceDisableWlan(); + bool enabled = mEngine->masterWlan() && !forcedOff; + + // Update the WLAN status label + updateWlanStatusLabel(enabled); + + // Set the WLAN ON/OFF button state + mWlanButton->setChecked(enabled); + + // Select the right WLAN button icon and menu action text + if (enabled) { + mWlanButton->setIcon(HbIcon("qtg_mono_wlan")); + mSwitchWlanAction->setText(hbTrId("txt_occ_opt_switch_wlan_off")); + } else { + mWlanButton->setIcon(HbIcon("qtg_mono_wlan_offline")); + mSwitchWlanAction->setText(hbTrId("txt_occ_opt_switch_wlan_on")); + } + + // Set triggable WLAN UI elements disabled if WLAN is forced OFF + mWlanButton->setEnabled(!forcedOff); + mSwitchWlanAction->setEnabled(!forcedOff); + + // Disable manual WLAN IAP creation when WLAN is switched OFF + mAddWlanAction->setEnabled(enabled); + + // Switch WLAN scanning ON/OFF + if (enabled) { + mEngine->startWlanScanning(); + } else { + mEngine->stopWlanScanning(); + // Clear the network list when going to offline + mWlanList->clear(); + } + + OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_UPDATEWLANENABLED_EXIT); +} + +/*! + Connection opened slot. Updates connection status. + + @param [in] iapId IAP ID of the connected WLAN IAP. +*/ + +void WlanSnifferListView::updateConnectionOpened(int iapId) +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_UPDATECONNECTIONOPENED_ENTRY); + + mConnectingIapId = WlanQtUtils::IapIdNone; + mStatusLabel->setPlainText( + hbTrId("txt_occ_grid_connected_to_1").arg( + mEngine->wlanQtUtils()->iapName(iapId))); + + // Update the list widget content + updateListContent(); + + // Scroll to the top of the list + mWlanListWidget->scrollTo(0); + + OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_UPDATECONNECTIONOPENED_EXIT); +} + +/*! + Connection closing handler. Updates connection status. + + @param [in] iapId Disconnected IAP ID. +*/ + +void WlanSnifferListView::updateConnectionClosed(int iapId) +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_UPDATECONNECTIONCLOSED_ENTRY); + + if (mEngine->masterWlan() && !mEngine->forceDisableWlan()) { + // Check whether we can update the status text to "Not connected" + if (mConnectingIapId == WlanQtUtils::IapIdNone || + mConnectingIapId == iapId) { + mStatusLabel->setPlainText(hbTrId("txt_occ_grid_not_connected")); + } + // else: we are already connecting to another network so don't touch + // the status label + + // Update the list widget content + updateListContent(); + } + + if (mConnectingIapId == iapId) { + // Not connecting to this network anymore + mConnectingIapId = WlanQtUtils::IapIdNone; + } + + OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_UPDATECONNECTIONCLOSED_EXIT); +} + +/*! + Context menu closing handler. +*/ + +void WlanSnifferListView::handleContextMenuClosed() +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_HANDLECONTEXTMENUCLOSED_ENTRY); + + // Let list updating start again + mIgnoreWlanScanResults = false; + + OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_HANDLECONTEXTMENUCLOSED_EXIT); +} + +/*! + List item activation handler. Connects the WLAN network, and if there + is no IAP yet for it, starts WLAN Wizard. + + @param [in] item Selected WLAN network list item. +*/ + +void WlanSnifferListView::handleListItemActivated(HbListWidgetItem *item) +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_HANDLELISTITEMACTIVATED_ENTRY); + + handleConnect(item->data()); + + OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_HANDLELISTITEMACTIVATED_EXIT); +} + +/*! + WLAN List item long press handler. + The long press of a list item (i.e. WLAN IAP) opens a context menu that + is populated depending on the state of the WLAN network in case. + + @param [in] item Selected list item. + @param [in] coords Coordinates of the long press. +*/ + +void WlanSnifferListView::handleListItemLongPressed( + HbListWidgetItem *item, + const QPointF &coords) +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_HANDLELISTITEMLONGPRESSED_ENTRY); + + mContextMenu = QSharedPointer(new HbMenu()); + + int activeIap = mEngine->wlanQtUtils()->activeIap(); + + // Remember the item that was long pressed + mContextMenuData = item->data(); + if (mContextMenuData.canConvert() + && mContextMenuData.toInt() == activeIap) { + // Connected IAP, add "Disconnect" action + mContextMenu->addAction( + hbTrId("txt_common_menu_disconnect"), + this, + SLOT(handleListItemDisconnect())); + } else { + // Not connected IAP or AP, add "Connect" action + mContextMenu->addAction( + hbTrId("txt_common_menu_connect"), + this, + SLOT(handleListItemConnect())); + } + + // Show the menu and connect closure signal (to re-enable list refreshing) + bool connectStatus = connect( + mContextMenu.data(), + SIGNAL(aboutToClose()), + this, + SLOT(handleContextMenuClosed())); + Q_ASSERT(connectStatus); + mContextMenu->setTimeout(HbPopup::ContextMenuTimeout); + mContextMenu->setPreferredPos(coords); + mContextMenu->show(); + + // Skip WLAN scan result updates during context menu handling + mIgnoreWlanScanResults = true; + + OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_HANDLELISTITEMLONGPRESSED_EXIT); +} + +/*! + Handles the "Connect" action selected from the context menu for a list item. +*/ + +void WlanSnifferListView::handleListItemConnect() +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_HANDLELISTITEMCONNECT_ENTRY); + + handleConnect(mContextMenuData); + + OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_HANDLELISTITEMCONNECT_EXIT); +} + +/*! + Handles the "Disconnect" action selected from the context menu for a list item. +*/ + +void WlanSnifferListView::handleListItemDisconnect() +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_HANDLELISTITEMDISCONNECT_ENTRY); + + // "Disconnect" was only added, if the item was an IAP and data was + // the IAP ID. + Q_ASSERT(mContextMenuData.canConvert()); + mEngine->wlanQtUtils()->disconnectIap(mContextMenuData.toInt()); + + OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_HANDLELISTITEMDISCONNECT_EXIT); +} + +/*! + Function for handling WLAN ON/OFF switch initiation. +*/ + +void WlanSnifferListView::handleWlanToggled() +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_HANDLEWLANTOGGLED_ENTRY); + + // Toggle the new WLAN ON/OFF value + bool wlanOn = mEngine->masterWlan(); + OstTraceExt1( + TRACE_NORMAL, + WLANSNIFFERLISTVIEW_HANDLEWLANTOGGLED, + "WlanSnifferListView::handleWlanToggled;wlan=%hhu", + wlanOn); + + // We have to check whether the offline mode is ON. If it is, then the + // user needs to be queried whether WLAN will be used in offline mode. + if (!wlanOn && mEngine->offlineMode()) { + // Show the dialog and wait for user input. + mWlanEnableDialog = QSharedPointer( + new HbMessageBox(HbMessageBox::MessageTypeQuestion)); + mWlanEnableDialog->setTimeout(HbPopup::StandardTimeout); + mWlanEnableDialog->setText(hbTrId("txt_occ_info_activate_wlan_in_airplane_mode")); + // Open the dialog and connect the result to the handleWlanEnableDialogClosed slot + mWlanEnableDialog->open(this, SLOT(handleWlanEnableDialogClosed(HbAction*))); + } else { + // Stop WLAN scanning immediately when switching WLAN OFF. + // WLAN might have sent scan results just before disabling WLAN. + if (wlanOn) { + mEngine->stopWlanScanning(); + } + mEngine->setMasterWlan(!wlanOn); + } + + OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_HANDLEWLANTOGGLED_EXIT); +} + +/*! + Function to handle the input received when the wlan enabling + query is closed. + + @param [in] action The user action received from the dialog. +*/ + +void WlanSnifferListView::handleWlanEnableDialogClosed(HbAction *action) +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_HANDLEWLANENABLEDIALOGCLOSED_ENTRY); + + // The dialog must exist + Q_ASSERT(mWlanEnableDialog); + + // If the user selected yes, then the wlan value is toggled, + // otherwise nothing needs to be done. + // TODO: Update actions().at(0) when a better solution is provided by orbit + if (action == mWlanEnableDialog->actions().at(0)) { + mEngine->setMasterWlan(true); + } + + OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_HANDLEWLANENABLEDIALOGCLOSED_EXIT); +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/src/wlansnifferlistwidget.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/src/wlansnifferlistwidget.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,645 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Sniffer list widget class. +*/ + +// System includes + +#include +#include +#include +#include +#include +#include +#include + +// User includes + +#include "wlanqtutils.h" +#include "wlanqtutilsap.h" +#include "wlanqtutilsiap.h" + +#include "wlansniffer.h" +#include "wlansnifferlistitem.h" +#include "wlansnifferlistwidget.h" + +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wlansnifferlistwidgetTraces.h" +#endif + +/*! + \class WlanSnifferListWidget + \brief WLAN Sniffer Custom List Widget implementation. +*/ + +// External function prototypes + +// Local constants + +//! Location of WLAN Sniffer List Layout definitions +static const QString WlanSnifferLayoutPath(":/wlansnifferlistlayout/"); + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +/*! + Constructor. + + @param [in] listWidget List Widget created to customize. +*/ + +WlanSnifferListWidget::WlanSnifferListWidget(HbListWidget *listWidget) : + mListWidget(listWidget) +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTWIDGET_WLANSNIFFERLISTWIDGET_ENTRY); + + // Register custom layout location + HbStyleLoader::registerFilePath(WlanSnifferLayoutPath); + + // Set custom WLAN list item layout + mListWidget->setLayoutName("wlanlistitem"); + + OstTraceFunctionExit0(WLANSNIFFERLISTWIDGET_WLANSNIFFERLISTWIDGET_EXIT); +} + +/*! + Destructor. +*/ + +WlanSnifferListWidget::~WlanSnifferListWidget() +{ + OstTraceFunctionEntry0(DUP1_WLANSNIFFERLISTWIDGET_WLANSNIFFERLISTWIDGET_ENTRY); + + HbStyleLoader::unregisterFilePath(WlanSnifferLayoutPath); + + OstTraceFunctionExit0(DUP1_WLANSNIFFERLISTWIDGET_WLANSNIFFERLISTWIDGET_EXIT); +} + +/*! + Updates the list widget content with the given IAPs and APs. + + @param [in] iaps New WLAN IAP list. + @param [in] aps New WLAN AP list. + @param [in] connectedIapId IAP ID of the connected WLAN or + IapIdNone if not connected. + */ + +void WlanSnifferListWidget::updateContent( + QList< QSharedPointer > &iaps, + QList< QSharedPointer > &aps, + int connectedIapId) +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTWIDGET_UPDATESCANSTATUS_ENTRY); + + traceListContent(); + + // Sort the scan result lists + sortIaps(iaps, connectedIapId); + sortAps(aps); + + // Remove items, which are not present in new IAP or AP lists + removeLostItems(iaps, aps); + + // Add items, which are only found in the new IAP and AP lists. + // Also update the icons of existing items (connection mode and + // signal strength may have changed) + addDiscoveredItemsAndUpdateRest(iaps, aps, connectedIapId); + + traceListContent(); + + OstTraceFunctionExit0(WLANSNIFFERLISTWIDGET_UPDATESCANSTATUS_EXIT); +} + +/*! + Scroll the list widget to given row. + + @param [in] row Row to scroll to. Indexing starts from zero. + */ + +void WlanSnifferListWidget::scrollTo(int row) +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTWIDGET_SCROLLTO_ENTRY); + + OstTrace1( + TRACE_NORMAL, + WLANSNIFFERLISTWIDGET_SCROLLTO, + "WlanSnifferListWidget::scrollTo;row=%d", + row); + + // Check that the row exists + if (row < mListWidget->count()) { + // Do the scrolling + QModelIndex index = mListWidget->model()->index(row, 0); + mListWidget->scrollTo(index); + } + + OstTraceFunctionExit0(WLANSNIFFERLISTWIDGET_SCROLLTO_EXIT); +} + +/*! + IAP list sorting. Sorts IAPs into alphabetical order taking localization + into account. + + @param [in,out] iaps WLAN IAP list. + @param [in] connectedIapId IAP ID of the connected WLAN or + IapIdNone if not connected. +*/ + +void WlanSnifferListWidget::sortIaps( + QList< QSharedPointer > &iaps, + int connectedIapId) +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTWIDGET_SORTIAPS_ENTRY); + + // Order the list by IAP name + qSort( + iaps.begin(), + iaps.end(), + WlanSnifferListWidget::iapLessThan); + + // Find the possible connected IAP + int connectedIndex = 0; + for (int i = 0; i < iaps.size(); i++) { + if (iaps[i]->value(WlanQtUtilsIap::ConfIdIapId).toInt() == connectedIapId) { + connectedIndex = i; + break; + } + } + + // Move the possible connected IAP to the beginning + if (connectedIndex) { + OstTraceExt2( + TRACE_NORMAL, + WLANSNIFFERLISTWIDGET_SORTIAPS_MOVE_CONNECTED, + "WlanSnifferListWidget::sortIaps Moving connected IAP to top;connectedIapId=%d;connectedIndex=%d", + connectedIapId, + connectedIndex); + + iaps.move(connectedIndex, 0); + } + + OstTraceFunctionExit0(WLANSNIFFERLISTWIDGET_SORTIAPS_EXIT); +} + +/*! + AP list sorting. Sorts APs into alphabetical order taking localization + into account. + + @param [in,out] aps WLAN AP list. +*/ + +void WlanSnifferListWidget::sortAps( + QList< QSharedPointer > &aps) +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTWIDGET_SORTAPS_ENTRY); + + // Order the list by AP SSID + qSort( + aps.begin(), + aps.end(), + WlanSnifferListWidget::apLessThan); + + OstTraceFunctionExit0(WLANSNIFFERLISTWIDGET_SORTAPS_EXIT); +} + +/*! + Compares two WLAN IAPs. Comparison is done with the IAP name. + + @param[in] iap1 IAP to compare with. + @param[in] iap2 IAP to compare. + + @return Returns true if the first iap is "less than" the second one. + */ + +bool WlanSnifferListWidget::iapLessThan( + const QSharedPointer iap1, + const QSharedPointer iap2) +{ + // Primary comparison is based on the name + int result = HbStringUtil::compareC( + iap1->value(WlanQtUtilsIap::ConfIdName).toString(), + iap2->value(WlanQtUtilsIap::ConfIdName).toString()); + + // If name is equal, compare based on security mode + if (result == 0) { + result = + iap1->value(WlanQtUtilsIap::ConfIdSecurityMode).toInt() - + iap2->value(WlanQtUtilsIap::ConfIdSecurityMode).toInt(); + } + + return (result < 0) ? true : false; +} + +/*! + Compares two WLAN APs. Comparison is done with the AP SSID. + + @param[in] ap1 AP to compare with. + @param[in] ap2 AP to compare. + + @return Returns true if the first ap is "less than" the second one. + */ + +bool WlanSnifferListWidget::apLessThan( + const QSharedPointer ap1, + const QSharedPointer ap2) +{ + // Primary comparison is based on the SSID + int result = HbStringUtil::compareC( + ap1->value(WlanQtUtilsAp::ConfIdSsid).toString(), + ap2->value(WlanQtUtilsAp::ConfIdSsid).toString()); + + // If SSID is equal, compare based on security mode + if (result == 0) { + result = + ap1->value(WlanQtUtilsIap::ConfIdSecurityMode).toInt() - + ap2->value(WlanQtUtilsIap::ConfIdSecurityMode).toInt(); + } + + return (result < 0) ? true : false; +} + +/*! + Function for finding the given IAP from the old Wlan list. + + @param [in] iap IAP to find. + + @return Found WLAN List Widget item, 0 if not found. +*/ + +WlanSnifferListItem *WlanSnifferListWidget::findFromOldList( + QSharedPointer iap) +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTWIDGET_FINDFROMOLDLIST_IAP_ENTRY); + + WlanSnifferListItem *result = NULL; + QVariant iapData = iap->value(WlanQtUtilsIap::ConfIdIapId); + for (int row = 0; row < mListWidget->count(); row++) { + HbListWidgetItem *item = mListWidget->item(row); + if (item->data() == iapData) { + result = static_cast(item); + break; + } + } + + OstTraceExt2( + TRACE_DUMP, + WLANSNIFFERLISTWIDGET_FINDFROMOLDLIST_IAP, + "WlanSnifferListWidget::findFromOldList;iapId=%d;found=%hhu", + iapData.toInt(), + (result != NULL) ? true : false); + + OstTraceFunctionExit0(WLANSNIFFERLISTWIDGET_FINDFROMOLDLIST_IAP_EXIT); + return result; +} + +/*! + Function for finding the given AP from the old Wlan list. + + @param [in] ap AP to find. + + @return Found WLAN List Widget item, 0 if not found. +*/ + +WlanSnifferListItem *WlanSnifferListWidget::findFromOldList( + QSharedPointer ap) +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTWIDGET_FINDFROMOLDLIST_AP_ENTRY); + + WlanSnifferListItem *result = NULL; + for (int row = 0; row < mListWidget->count(); row++) { + HbListWidgetItem *item = mListWidget->item(row); + if (item->data().canConvert()) { + WlanQtUtilsAp oldAp = item->data().value(); + if (WlanQtUtilsAp::compare(ap.data(), &oldAp) == true) { + result = static_cast(item); + break; + } + } + } + +#ifdef OST_TRACE_COMPILER_IN_USE + QString tmp(ap.data()->value(WlanQtUtilsAp::ConfIdSsid).toString()); + TPtrC16 ssid(tmp.utf16(), tmp.length()); + OstTraceExt2( + TRACE_NORMAL, + WLANSNIFFERLISTWIDGET_FINDFROMOLDLIST_AP, + "WlanSnifferListWidget::findFromOldList;found=%hhu;ssid=%S", + (result != NULL) ? true : false, + ssid); +#endif + + OstTraceFunctionExit0(WLANSNIFFERLISTWIDGET_FINDFROMOLDLIST_AP_EXIT); + return result; +} + +/*! + Function for creating a new list item from the given IAP. + + @param [in] iap WLAN IAP to create. + @param [in] connectedIapId IAP ID of the connected WLAN or + IapIdNone if not connected. + + @return New WLAN List Widget item. +*/ + +HbListWidgetItem *WlanSnifferListWidget::listItemCreate( + QSharedPointer iap, + int connectedIapId) +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTWIDGET_LISTITEMCREATE_IAP_ENTRY); + + WlanSnifferListItem *item = new WlanSnifferListItem(); + item->setNetworkName(iap->value(WlanQtUtilsIap::ConfIdName).toString()); + if (iap->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt() != + CMManagerShim::WlanSecModeOpen) { + item->setSecureIcon("qtg_small_secure"); + // TODO: Handle WPS case - it uses a different icon! + // Will be implemented with "Adding WLAN IAP manually" subfeature. + } + + item->setLeftIcon( + leftIconChoose( + iap->value(WlanQtUtilsIap::ConfIdIapId).toInt(), + connectedIapId)); + item->setSignalIcon( + signalStrengthIconChoose( + iap->value(WlanQtUtilsAp::ConfIdSignalStrength).toInt())); + + item->setData(iap->value(WlanQtUtilsIap::ConfIdIapId)); + + OstTraceFunctionExit0(WLANSNIFFERLISTWIDGET_LISTITEMCREATE_IAP_EXIT); + return item; +} + +/*! + Function for creating a new list item from the given AP. + + @param [in] ap WLAN AP to create. + + @return New WLAN List Widget item. +*/ + +HbListWidgetItem *WlanSnifferListWidget::listItemCreate( + QSharedPointer ap) +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTWIDGET_LISTITEMCREATE_AP_ENTRY); + + WlanSnifferListItem *item = new WlanSnifferListItem(); + item->setNetworkName(ap->value(WlanQtUtilsAp::ConfIdSsid).toString()); + if (ap->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt() + != CMManagerShim::WlanSecModeOpen) { + item->setSecureIcon("qtg_small_secure"); + // TODO: Handle WPS case - it uses a different icon! + // Will be implemented with "Adding WLAN IAP manually" subfeature. + } + item->setSignalIcon( + signalStrengthIconChoose( + ap->value(WlanQtUtilsAp::ConfIdSignalStrength).toInt())); + + QVariant data; + data.setValue(*ap); + item->setData(data); + + OstTraceFunctionExit0(WLANSNIFFERLISTWIDGET_LISTITEMCREATE_AP_EXIT); + return item; +} + +/*! + Function for selecting the correct signal strength icon. + + @param [in] signalStrength Signal strength. + + @return Signal strength icon logical name. +*/ + +QString WlanSnifferListWidget::signalStrengthIconChoose(int signalStrength) +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTWIDGET_SIGNALSTRENGTHICONCHOOSE_ENTRY); + + QString iconName; + if (signalStrength <= SignalStrengthHigh) { + iconName = "qtg_small_signal_good"; + } else if (signalStrength <= SignalStrengthMedium) { + iconName = "qtg_small_signal_medium"; + } else { + iconName = "qtg_small_signal_low"; + } + + OstTraceFunctionExit0(WLANSNIFFERLISTWIDGET_SIGNALSTRENGTHICONCHOOSE_EXIT); + return iconName; +} + +/*! + Function for selecting the correct "left" icon, which is different for + connected and not connected IAPs. + + @param [in] iapId IAP ID of the WLAN IAP. + @param [in] connectedIapId IAP ID of the connected WLAN or + IapIdNone if not connected. + + @return Icon logical name of the "left" icon. +*/ + +QString WlanSnifferListWidget::leftIconChoose( + int iapId, + int connectedIapId) +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTWIDGET_LEFTICONCHOOSE_ENTRY); + + QString iconName; + if (iapId == connectedIapId) { + iconName = "qtg_small_connection"; + } else { + iconName = "qtg_small_wlan"; + } + + OstTraceFunctionExit0(WLANSNIFFERLISTWIDGET_LEFTICONCHOOSE_EXIT); + return iconName; +} + +/*! + Function for removing from the old Wlan list those items, which are + not present in the given new lists. + + @param [in] iaps New WLAN IAP list. + @param [in] aps New WLAN AP list. +*/ + +void WlanSnifferListWidget::removeLostItems( + const QList< QSharedPointer > &iaps, + const QList< QSharedPointer > &aps) +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTWIDGET_REMOVELOSTITEMS_ENTRY); + + int row = 0; + // Loop through all rows in the current list and try to find the items from + // the new lists + while (row < mListWidget->count()) { + bool found = false; + const HbListWidgetItem *item = mListWidget->item(row); + if (item->data().canConvert()) { + // Item was an IAP, try to find it from the new IAP list + foreach (QSharedPointer iap, iaps) { + if (iap->value(WlanQtUtilsIap::ConfIdIapId) == + item->data()) { + found = true; + break; + } + } + } else { + // Item has to be an AP, try to find it from the new AP list + Q_ASSERT(item->data().canConvert()); + WlanQtUtilsAp oldAp = item->data().value(); + foreach (QSharedPointer newAp, aps) { + if (WlanQtUtilsAp::compare(newAp.data(), &oldAp) == true) { + found = true; + break; + } + } + } + if (found == false) { + // Item was lost. Remove this row and delete it. Don't increment + // row index, because the next item now has the same row index + // as this one had + delete mListWidget->takeItem(row); + + OstTrace1( + TRACE_NORMAL, + WLANSNIFFERLISTWIDGET_REMOVELOSTITEMS, + "WlanSnifferListWidget::removeLostItems Removed;row=%d", + row); + } else { + // Item still exists, move on to next row + row++; + } + } + + OstTraceFunctionExit0(WLANSNIFFERLISTWIDGET_REMOVELOSTITEMS_EXIT); +} + +/*! + Function for adding to the Wlan list those items, which are new + in the given new lists. Also, icons and order of the existing list + items are updated. + + @param [in] iaps New WLAN IAP list. + @param [in] aps New WLAN AP list. + @param [in] connectedIapId IAP ID of the connected WLAN or + IapIdNone if not connected. +*/ + +void WlanSnifferListWidget::addDiscoveredItemsAndUpdateRest( + const QList< QSharedPointer > &iaps, + const QList< QSharedPointer > &aps, + int connectedIapId) +{ + OstTraceFunctionEntry0(WLANSNIFFERLISTWIDGET_ADDDISCOVEREDITEMSANDUPDATEREST_ENTRY); + + int row = 0; + // Loop through new IAPs and try to find them from the old list + foreach (QSharedPointer newIap, iaps) { + WlanSnifferListItem *oldItem = findFromOldList(newIap); + if (oldItem != NULL) { + // Match found, update icons + oldItem->setLeftIcon( + leftIconChoose( + newIap->value(WlanQtUtilsIap::ConfIdIapId).toInt(), + connectedIapId)); + oldItem->setSignalIcon( + signalStrengthIconChoose( + newIap->value(WlanQtUtilsAp::ConfIdSignalStrength).toInt())); + // Also move the IAP to new row, if necessary (IAP order changes + // when IAPs are connected/disconnected) + int oldRow = mListWidget->row(oldItem); + if (row != oldRow) { + OstTraceExt2( + TRACE_NORMAL, + WLANSNIFFERLISTWIDGET_ADDDISCOVEREDITEMSANDUPDATEREST_MOVE, + "WlanSnifferListWidget::addDiscoveredItemsAndUpdateRest Moved;oldRow=%d;row=%d", + oldRow, + row); + mListWidget->takeItem(oldRow); + mListWidget->insertItem(row, oldItem); + } + } else { + // New item discovered, add it to the list. Row is the same as the + // index of the item in the new scan list + OstTrace1( + TRACE_NORMAL, + WLANSNIFFERLISTWIDGET_ADDDISCOVEREDITEMSANDUPDATEREST_ADD_IAP, + "WlanSnifferListWidget::addDiscoveredItemsAndUpdateRest Added IAP;row=%d", + row); + mListWidget->insertItem(row, listItemCreate(newIap, connectedIapId)); + } + // Move to next row + row++; + } + // Repeat the same for new APs. Notice that row index continues from + // previous loop + foreach (QSharedPointer newAp, aps) { + WlanSnifferListItem *oldItem = findFromOldList(newAp); + if (oldItem != NULL) { + oldItem->setSignalIcon( + signalStrengthIconChoose( + newAp->value(WlanQtUtilsAp::ConfIdSignalStrength).toInt())); + // Notice that AP order may not change, they are always in + // alphabetical order + } else { + OstTrace1( + TRACE_NORMAL, + WLANSNIFFERLISTWIDGET_ADDDISCOVEREDITEMSANDUPDATEREST_ADD_AP, + "WlanSnifferListWidget::addDiscoveredItemsAndUpdateRest Added AP;row=%d", + row); + mListWidget->insertItem(row, listItemCreate(newAp)); + } + row++; + } + + OstTraceFunctionExit0(WLANSNIFFERLISTWIDGET_ADDDISCOVEREDITEMSANDUPDATEREST_EXIT); +} + +/*! + This function traces the contents of the list. +*/ + +void WlanSnifferListWidget::traceListContent() const +{ +#ifdef OST_TRACE_COMPILER_IN_USE + for (int row = 0; row < mListWidget->count(); row++) { + HbListWidgetItem *item = mListWidget->item(row); + if (item->data().canConvert()) { + OstTraceExt2( + TRACE_DUMP, + WLANSNIFFERLISTWIDGET_TRACELISTCONTENT_IAP, + "WlanSnifferListWidget::traceListContent IAP;row=%d;id=%d", + row, + item->data().toInt()); + } else { + Q_ASSERT(item->data().canConvert()); + WlanQtUtilsAp ap = item->data().value(); + QString tmp(ap.value(WlanQtUtilsAp::ConfIdSsid).toString()); + TPtrC16 ssid(tmp.utf16(), tmp.length()); + OstTraceExt2( + TRACE_DUMP, + WLANSNIFFERLISTWIDGET_TRACELISTCONTENT_AP, + "WlanSnifferListWidget::traceListContent AP;row=%d;ssid=%S", + row, + ssid); + } + } +#endif +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/src/wlansniffermainwindow.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/src/wlansniffermainwindow.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,235 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Sniffer main window. +*/ + +// System includes + +// User includes + +#include "wlanqtutils.h" +#include "wlanqtutilsap.h" + +#include "wlanwizard.h" + +#include "wlansnifferengine.h" +#include "wlansnifferlistview.h" +#include "wlansniffermainwindow.h" + +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wlansniffermainwindowTraces.h" +#endif + +/*! + \class WlanSnifferMainWindow + \brief WLAN Sniffer main window. +*/ + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +/*! + Constructor. + + @param [in] engine WLAN Sniffer application engine. + */ + +WlanSnifferMainWindow::WlanSnifferMainWindow(WlanSnifferEngine *engine) : + mWizard(0), + mListView(0), + mEngine(engine) +{ + OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_WLANSNIFFERMAINWINDOW_ENTRY); + + // Add the list view to the main window + addListView(); + bool connectStatus = connect( + mEngine, + SIGNAL(toListView(QString)), + this, + SLOT(toListView(QString))); + Q_ASSERT(connectStatus == true); + + // When using WLAN Sniffer service, the view show is called after the service + // request arrives. + if (!mEngine->isEmbedded()) { + // Show the list view + toListView(hbTrId("txt_occ_title_wireless_lan")); + } + + OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_WLANSNIFFERMAINWINDOW_EXIT); +} + +/*! + Destructor. + */ + +WlanSnifferMainWindow::~WlanSnifferMainWindow() +{ + OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_WLANSNIFFERMAINWINDOWDESTR_ENTRY); + + delete mWizard; + + OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_WLANSNIFFERMAINWINDOWDESTR_EXIT); +} + +/*! + Shows the WLAN Sniffer list view. + + @param [in] title View title. + */ + +void WlanSnifferMainWindow::toListView(const QString &title) +{ + OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_TOLISTVIEW_ENTRY); + + // Show the list view + mListView->setTitle(title); + setCurrentView(mListView); + show(); + + OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_TOLISTVIEW_EXIT); +} + +/*! + Creates and adds the WLAN List View to main window. + */ + +void WlanSnifferMainWindow::addListView() +{ + OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_ADDLISTVIEW_ENTRY); + + mListView = new WlanSnifferListView(mEngine, this); + addView(mListView); + + bool connectStatus = connect( + mListView, + SIGNAL(wizardTriggered(const WlanQtUtilsAp *)), + this, + SLOT(startWlanWizard(const WlanQtUtilsAp *))); + + OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_ADDLISTVIEW_EXIT); +} + +/*! + Starts WLAN Wizard for new WLAN IAP creation. + + @param [in] ap WLAN Access Point to create. + */ + +void WlanSnifferMainWindow::startWlanWizard(const WlanQtUtilsAp *ap) +{ + OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_STARTWLANWIZARD_ENTRY); + + Q_ASSERT(mWizard == NULL); + + // Stop WLAN scanning for the duration of WLAN Wizard + mEngine->stopWlanScanning(); + + mWizard = new WlanWizard(this); + bool connectStatus = connect( + mWizard, + SIGNAL(finished(int,bool)), + this, + SLOT(handleWlanWizardComplete(int,bool))); + Q_ASSERT(connectStatus == true); + + connectStatus = connect( + mWizard, + SIGNAL(cancelled()), + this, + SLOT(handleWlanWizardCancelled())); + Q_ASSERT(connectStatus == true); + + mWizard->setParameters( + ap->value(WlanQtUtilsAp::ConfIdSsid).toString(), + ap->value(WlanQtUtilsAp::ConfIdConnectionMode).toInt(), + ap->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(), + ap->value(WlanQtUtilsAp::ConfIdWpaPskUse).toInt(), + ap->value(WlanQtUtilsAp::ConfIdHidden).toBool(), + ap->value(WlanQtUtilsAp::ConfIdWpsSupported).toBool()); + + mWizard->show(); + + OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_STARTWLANWIZARD_EXIT); +} + +/*! + WLAN Wizard successful completion handler. + + @param [in] iapId IAP ID of the new WLAN IAP. + @param [in] connected TRUE if connected. + */ + +void WlanSnifferMainWindow::handleWlanWizardComplete( + int iapId, + bool connected) +{ + OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_HANDLEWLANWIZARDCOMPLETE_ENTRY); + + // Enable scanning again + mEngine->startWlanScanning(); + + // TODO: Will be needed in "Adding WLAN network manually" subfeature + Q_UNUSED(connected); + + // The IAP ID must be valid + Q_ASSERT(iapId != WlanQtUtils::IapIdNone); + + // Connect (share) the new IAP in order to keep the connection open when + // deleting Wizard. + // Todo: this needs some checking when "Adding WLAN IAP manually" subfeature + // is implemented, because we don't want to connect the IAP, if Wizard didn't + // connect it. + mEngine->wlanQtUtils()->connectIap(iapId, false); + + // The wizard must exist + Q_ASSERT(mWizard); + + // Delete the Wizard instance, but only when returning to event loop, because + // execution returns back to Wizard after this slot. + mWizard->deleteLater(); + mWizard = NULL; + + OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_HANDLEWLANWIZARDCOMPLETE_EXIT); +} + +/*! + WLAN Wizard cancellation handler. + */ + +void WlanSnifferMainWindow::handleWlanWizardCancelled() +{ + OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_HANDLEWLANWIZARDCANCELLED_ENTRY); + + // Enable scanning again + mEngine->startWlanScanning(); + + // The wizard must exist + Q_ASSERT(mWizard); + + // Delete the Wizard instance, but only when returning to event loop, because + // execution returns back to Wizard after this slot. + mWizard->deleteLater(); + mWizard = NULL; + + OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_HANDLEWLANWIZARDCANCELLED_EXIT); +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/src/wlansnifferservice.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/src/wlansnifferservice.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,127 @@ +/* +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Sniffer QtHighway Service. +*/ + +// System includes + +// User includes + +#include "wlansnifferservice.h" + +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wlansnifferserviceTraces.h" +#endif + +/*! + \class WlanSnifferService + \brief WLAN Sniffer QtHighway service implementation. + + This class implements a QtHighway service that can be used to launch + a WLAN Sniffer application. +*/ + + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +/*! + Constructor. + + @param[in] parent Object parent. + */ + +WlanSnifferService::WlanSnifferService(QObject* parent) : + XQServiceProvider( + // TODO: Change to use the define in xqaiwdeclplat.h + QLatin1String("wlansniffer.com.nokia.symbian.IWlanSniffer"), + parent) +{ + OstTraceFunctionEntry0(WLANSNIFFERSERVICE_WLANSNIFFERSERVICE_ENTRY); + + publishAll(); + + OstTraceFunctionExit0(WLANSNIFFERSERVICE_WLANSNIFFERSERVICE_EXIT); +} + +/*! + Destructor. + */ + +WlanSnifferService::~WlanSnifferService() +{ + OstTraceFunctionEntry0(WLANSNIFFERSERVICE_WLANSNIFFERSERVICEDESTR_ENTRY); + OstTraceFunctionExit0(WLANSNIFFERSERVICE_WLANSNIFFERSERVICEDESTR_EXIT); +} + +/*! + Completes the current service. + */ + +void WlanSnifferService::complete() +{ + OstTraceFunctionEntry0(WLANSNIFFERSERVICE_COMPLETE_ENTRY); + + QVariant returnValue(true); + bool status = completeRequest(mAsyncRequestIndex, returnValue); + Q_ASSERT(status); + + OstTraceFunctionExit0(WLANSNIFFERSERVICE_COMPLETE_EXIT); +} + +/*! + List view service function. Launches the WLAN Sniffer List View. + */ + +void WlanSnifferService::listView() +{ + OstTraceFunctionEntry0(WLANSNIFFERSERVICE_LISTVIEW_ENTRY); + + mAsyncRequestIndex = setCurrentRequestAsync(); + emit toListView(title()); + + OstTraceFunctionExit0(WLANSNIFFERSERVICE_LISTVIEW_EXIT); +} + +/* + Extracts and returns the client application's title (if available). + + @return Client application's title string or empty if not available. + */ + +QString WlanSnifferService::title() const +{ + OstTraceFunctionEntry0(WLANSNIFFERSERVICE_TITLE_ENTRY); + + // Get service request info + XQRequestInfo info = requestInfo(); + + // There must be a valid request info object + Q_ASSERT(info.isValid()); + + // Extract the title + // TODO: Start using the official define when available + QVariant titleInfo = info.info("WindowTitle"); + QString title = titleInfo.toString(); + + OstTraceFunctionExit0(WLANSNIFFERSERVICE_TITLE_EXIT); + return title; +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/traces/OstTraceDefinitions.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/traces/OstTraceDefinitions.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,21 @@ +/* +* 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 "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* OST trace definition header. +*/ + +#ifndef __OSTTRACEDEFINITIONS_H__ +#define __OSTTRACEDEFINITIONS_H__ +#include +#endif diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/tsrc/ctcmakeandruncases.cmd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/tsrc/ctcmakeandruncases.cmd Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,24 @@ +:: 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 "Eclipse Public License v1.0" +:: which accompanies this distribution, and is available +:: at the URL "http://www.eclipse.org/legal/epl-v10.html". +:: +:: Initial Contributors: +:: Nokia Corporation - initial contribution. +:: +:: Contributors: +:: +:: Description: +:: Batch file to instrument and run test cases with CTC. + +@echo off +del MON.* +del profile.txt +rmdir /S /Q CTCHTML +call qmake "CONFIG -= debug" +call sbs clean +call sbs reallyclean +call ctcwrap -C EXCLUDE=* -C NO_EXCLUDE+..\src\wlansnifferlistwidget.cpp -i d -2comp sbs -c winscw_udeb +call \epoc32\release\winscw\udeb\t_wlansniffer.exe \ No newline at end of file diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/tsrc/ctcresults.cmd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/tsrc/ctcresults.cmd Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,17 @@ +:: 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 "Eclipse Public License v1.0" +:: which accompanies this distribution, and is available +:: at the URL "http://www.eclipse.org/legal/epl-v10.html". +:: +:: Initial Contributors: +:: Nokia Corporation - initial contribution. +:: +:: Contributors: +:: +:: Description: +:: Batch file to create coverage reports from CTC results. + +call ctcpost -p profile.txt +call ctc2html -i profile.txt \ No newline at end of file diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/tsrc/makeandruncases.cmd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/tsrc/makeandruncases.cmd Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,21 @@ +:: 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 "Eclipse Public License v1.0" +:: which accompanies this distribution, and is available +:: at the URL "http://www.eclipse.org/legal/epl-v10.html". +:: +:: Initial Contributors: +:: Nokia Corporation - initial contribution. +:: +:: Contributors: +:: +:: Description: +:: Batch file to compile and run test cases. + +@echo off +call qmake +call sbs clean +call sbs reallyclean +call sbs -c winscw_udeb +call \epoc32\release\winscw\udeb\t_wlansniffer.exe \ No newline at end of file diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/tsrc/t_wlansniffer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/tsrc/t_wlansniffer.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,557 @@ +/* +* 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 "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* This is the source file for testing Wlan Sniffer application. +*/ + +// System includes + +#include +#include +#include +#include +#include +#include + +// User includes + +#include "wlanqtutilsiap.h" +#include "wlanqtutilsap.h" + +#include "wlansnifferlistwidget.h" +#include "t_wlansniffer.h" + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +/*! + Test main function. Runs all test cases. + */ + +int main(int argc, char *argv[]) +{ + HbApplication app(argc, argv); + + char *pass[3]; + pass[0] = argv[0]; + pass[1] = "-o"; + pass[2] = "c:\\data\\TestWlanSniffer.txt"; + + TestWlanSniffer tc; + int res = QTest::qExec(&tc, 3, pass); + + return res; +} + +// ======== MEMBER FUNCTIONS ======== + +/*! + This function will be called before the first test function is executed. +*/ + +void TestWlanSniffer::initTestCase() +{ + mWidget = NULL; +} + +/*! + This function will be called after the last test function was executed. + */ + +void TestWlanSniffer::cleanupTestCase() +{ +} + +/*! + This function will be called before each test function is executed. + */ + +void TestWlanSniffer::init() +{ + mListWidget = new HbListWidget(); + mWidget = new WlanSnifferListWidget(mListWidget); + + mIaps.clear(); + mAps.clear(); +} + +/*! + This function will be called after each test function is executed. + */ + +void TestWlanSniffer::cleanup() +{ + delete mWidget; + mWidget = NULL; + + mListWidget->clear(); + delete mListWidget; + mListWidget = NULL; +} + +/*! + This function tests Wlan list widget content updating. + */ + +void TestWlanSniffer::testUpdateContentIapAdded() +{ + appendWlanAp("SSID 1", 20, 0, CMManagerShim::WlanSecModeOpen); + appendWlanAp("SSID 2", 90, 0, CMManagerShim::WlanSecModeWpa); + + mWidget->updateContent(mIaps, mAps, 0); + + QCOMPARE(mListWidget->count(), 2); + verifyAp(0, QString("SSID 1"), CMManagerShim::WlanSecModeOpen); + verifyAp(1, QString("SSID 2"), CMManagerShim::WlanSecModeWpa); + + appendWlanIap(1, 0, "SSID 3", "SSID 3", 20, CMManagerShim::WlanSecModeWpa); + + mWidget->updateContent(mIaps, mAps, 0); + + QCOMPARE(mListWidget->count(), 3); + verifyIap(0, 1); + verifyAp(1, QString("SSID 1"), CMManagerShim::WlanSecModeOpen); + verifyAp(2, QString("SSID 2"), CMManagerShim::WlanSecModeWpa); +} + +/*! + This function tests Wlan list widget content updating. + */ + +void TestWlanSniffer::testUpdateContentApAdded() +{ + appendWlanAp("SSID 1", 20, 0, CMManagerShim::WlanSecModeOpen); + + mWidget->updateContent(mIaps, mAps, 0); + + QCOMPARE(mListWidget->count(), 1); + verifyAp(0, QString("SSID 1"), CMManagerShim::WlanSecModeOpen); + + appendWlanAp("SSID 2", 90, 0, CMManagerShim::WlanSecModeWpa); + + mWidget->updateContent(mIaps, mAps, 0); + + QCOMPARE(mListWidget->count(), 2); + verifyAp(0, QString("SSID 1"), CMManagerShim::WlanSecModeOpen); + verifyAp(1, QString("SSID 2"), CMManagerShim::WlanSecModeWpa); +} + +/*! + This function tests Wlan list widget content updating. + */ + +void TestWlanSniffer::testUpdateContentIapRemoved() +{ + appendWlanIap(1, 0, "SSID 1", "SSID 1", 20, CMManagerShim::WlanSecModeWpa); + appendWlanIap(2, 0, "SSID 2", "SSID 2", 90, CMManagerShim::WlanSecModeWpa); + appendWlanAp("SSID 3", 90, 0, CMManagerShim::WlanSecModeWep); + + mWidget->updateContent(mIaps, mAps, 0); + + QCOMPARE(mListWidget->count(), 3); + verifyIap(0, 1); + verifyIap(1, 2); + verifyAp(2, QString("SSID 3"), CMManagerShim::WlanSecModeWep); + + mIaps.takeAt(0); + + mWidget->updateContent(mIaps, mAps, 0); + + QCOMPARE(mListWidget->count(), 2); + verifyIap(0, 2); + verifyAp(1, QString("SSID 3"), CMManagerShim::WlanSecModeWep); +} + +/*! + This function tests Wlan list widget content updating. + */ + +void TestWlanSniffer::testUpdateContentApRemoved() +{ + appendWlanAp("SSID 1", 20, 0, CMManagerShim::WlanSecModeOpen); + + mWidget->updateContent(mIaps, mAps, 0); + + QCOMPARE(mListWidget->count(), 1); + verifyAp(0, QString("SSID 1"), CMManagerShim::WlanSecModeOpen); + + mAps.takeAt(0); + + mWidget->updateContent(mIaps, mAps, 0); + + QCOMPARE(mListWidget->count(), 0); +} + +/*! + This function tests Wlan list widget content updating. + */ + +void TestWlanSniffer::testUpdateContentIapConnected() +{ + appendWlanIap(1, 0, "SSID 1", "SSID 1", 95, CMManagerShim::WlanSecModeWpa); + appendWlanIap(2, 0, "SSID 2", "SSID 2", 15, CMManagerShim::WlanSecModeWpa); + appendWlanAp("SSID 3", 20, 0, CMManagerShim::WlanSecModeOpen); + + mWidget->updateContent(mIaps, mAps, 0); + + QCOMPARE(mListWidget->count(), 3); + verifyIap(0, 1); + verifyIap(1, 2); + verifyAp(2, QString("SSID 3"), CMManagerShim::WlanSecModeOpen); + + // IAP order changed because one is connected + mIaps.clear(); + appendWlanIap(2, 0, "SSID 2", "SSID 2", 20, CMManagerShim::WlanSecModeWpa); + appendWlanIap(1, 0, "SSID 1", "SSID 1", 20, CMManagerShim::WlanSecModeWpa); + + mWidget->updateContent(mIaps, mAps, 2); + + QCOMPARE(mListWidget->count(), 3); + verifyIap(0, 2); + verifyIap(1, 1); + verifyAp(2, QString("SSID 3"), CMManagerShim::WlanSecModeOpen); +} + +/*! + This function tests Wlan list widget content updating. + */ + +void TestWlanSniffer::testUpdateContentIapDisconnected() +{ + appendWlanIap(2, 0, "SSID 2", "SSID 2", 20, CMManagerShim::WlanSecModeWpa); + appendWlanIap(1, 0, "SSID 1", "SSID 1", 20, CMManagerShim::WlanSecModeWpa); + appendWlanAp("SSID 3", 20, 0, CMManagerShim::WlanSecModeOpen); + + mWidget->updateContent(mIaps, mAps, 2); + + QCOMPARE(mListWidget->count(), 3); + verifyIap(0, 2); + verifyIap(1, 1); + verifyAp(2, QString("SSID 3"), CMManagerShim::WlanSecModeOpen); + + // IAP order changed because not connected anymore + mIaps.clear(); + appendWlanIap(1, 0, "SSID 1", "SSID 1", 20, CMManagerShim::WlanSecModeWpa); + appendWlanIap(2, 0, "SSID 2", "SSID 2", 60, CMManagerShim::WlanSecModeWpa); + + mWidget->updateContent(mIaps, mAps, 0); + + QCOMPARE(mListWidget->count(), 3); + verifyIap(0, 1); + verifyIap(1, 2); + verifyAp(2, QString("SSID 3"), CMManagerShim::WlanSecModeOpen); +} + +/*! + This function tests Wlan list widget content updating. + */ + +void TestWlanSniffer::testUpdateContentRobustness1() +{ + appendWlanIap(1, 0, "SSID 1", "SSID 1", 15, CMManagerShim::WlanSecModeWpa); + appendWlanIap(2, 0, "SSID 2", "SSID 2", 95, CMManagerShim::WlanSecModeWpa); + appendWlanAp("SSID 3", 20, 0, CMManagerShim::WlanSecModeOpen); + appendWlanAp("SSID 4", 30, 0, CMManagerShim::WlanSecModeWep); + appendWlanAp("SSID 5", 40, 0, CMManagerShim::WlanSecModeOpen); + + mWidget->updateContent(mIaps, mAps, 0); + + QCOMPARE(mListWidget->count(), 5); + verifyIap(0, 1); + verifyIap(1, 2); + verifyAp(2, QString("SSID 3"), CMManagerShim::WlanSecModeOpen); + verifyAp(3, QString("SSID 4"), CMManagerShim::WlanSecModeWep); + verifyAp(4, QString("SSID 5"), CMManagerShim::WlanSecModeOpen); + + mIaps.clear(); + appendWlanIap(3, 0, "SSID 3", "SSID 3", 10, CMManagerShim::WlanSecModeOpen); + appendWlanIap(1, 0, "SSID 1", "SSID 1", 20, CMManagerShim::WlanSecModeWpa); + appendWlanIap(2, 0, "SSID 2", "SSID 2", 30, CMManagerShim::WlanSecModeWpa); + mAps.clear(); + appendWlanAp("SSID 4", 30, 0, CMManagerShim::WlanSecModeWep); + appendWlanAp("SSID 5", 40, 0, CMManagerShim::WlanSecModeOpen); + appendWlanAp("SSID 6", 30, 0, CMManagerShim::WlanSecModeWep); + appendWlanAp("SSID 7", 40, 0, CMManagerShim::WlanSecModeOpen); + + mWidget->updateContent(mIaps, mAps, 3); + + QCOMPARE(mListWidget->count(), 7); + verifyIap(0, 3); + verifyIap(1, 1); + verifyIap(2, 2); + verifyAp(3, QString("SSID 4"), CMManagerShim::WlanSecModeWep); + verifyAp(4, QString("SSID 5"), CMManagerShim::WlanSecModeOpen); + verifyAp(5, QString("SSID 6"), CMManagerShim::WlanSecModeWep); + verifyAp(6, QString("SSID 7"), CMManagerShim::WlanSecModeOpen); + + mIaps.clear(); + appendWlanIap(4, 0, "SSID X", "SSID X", 10, CMManagerShim::WlanSecModeWpa); + appendWlanIap(2, 0, "SSID 2", "SSID 2", 20, CMManagerShim::WlanSecModeWpa); + appendWlanIap(3, 0, "SSID 3", "SSID 3", 10, CMManagerShim::WlanSecModeOpen); + appendWlanIap(5, 0, "SSID 3", "SSID 3", 50, CMManagerShim::WlanSecModeWapi); + mAps.clear(); + appendWlanAp("SSID 4", 30, 0, CMManagerShim::WlanSecModeOpen); + appendWlanAp("SSID 4a", 40, 0, CMManagerShim::WlanSecModeOpen); + appendWlanAp("SSID 7", 76, 0, CMManagerShim::WlanSecModeOpen); + appendWlanAp("SSID 7", 90, 0, CMManagerShim::WlanSecModeWep); + appendWlanAp("SSID 8", 30, 0, CMManagerShim::WlanSecModeWpa); + appendWlanAp("SSID 9", 30, 0, CMManagerShim::WlanSecModeWpa); + + mWidget->updateContent(mIaps, mAps, 4); + + QCOMPARE(mListWidget->count(), 10); + verifyIap(0, 4); + verifyIap(1, 2); + verifyIap(2, 3); + verifyIap(3, 5); + verifyAp(4, QString("SSID 4"), CMManagerShim::WlanSecModeOpen); + verifyAp(5, QString("SSID 4a"), CMManagerShim::WlanSecModeOpen); + verifyAp(6, QString("SSID 7"), CMManagerShim::WlanSecModeOpen); + verifyAp(7, QString("SSID 7"), CMManagerShim::WlanSecModeWep); + verifyAp(8, QString("SSID 8"), CMManagerShim::WlanSecModeWpa); + verifyAp(9, QString("SSID 9"), CMManagerShim::WlanSecModeWpa); + + mIaps.clear(); + appendWlanIap(3, 0, "SSID 3", "SSID 3", 50, CMManagerShim::WlanSecModeOpen); + mAps.clear(); + + mWidget->updateContent(mIaps, mAps, 0); + + QCOMPARE(mListWidget->count(), 1); + verifyIap(0, 3); + + mIaps.clear(); + mAps.clear(); + + mWidget->updateContent(mIaps, mAps, 0); + + QCOMPARE(mListWidget->count(), 0); +} + +/*! + This function tests Wlan list widget content updating. + */ + +void TestWlanSniffer::testUpdateContentRobustness2() +{ + QSharedPointer iap2(new WlanQtUtilsIap()); + iap2->setValue(WlanQtUtilsIap::ConfIdIapId, 2); + iap2->setValue(WlanQtUtilsIap::ConfIdNetworkId, 0); + iap2->setValue(WlanQtUtilsIap::ConfIdName, "SSID 2"); + iap2->setValue(WlanQtUtilsAp::ConfIdSsid, "SSID 2"); + iap2->setValue(WlanQtUtilsAp::ConfIdSignalStrength, 10); + iap2->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa); + QSharedPointer iap4(new WlanQtUtilsIap()); + iap4->setValue(WlanQtUtilsIap::ConfIdIapId, 4); + iap4->setValue(WlanQtUtilsIap::ConfIdNetworkId, 0); + iap4->setValue(WlanQtUtilsIap::ConfIdName, "SSID 4"); + iap4->setValue(WlanQtUtilsAp::ConfIdSsid, "SSID 4"); + iap4->setValue(WlanQtUtilsAp::ConfIdSignalStrength, 20); + iap4->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa); + + appendWlanAp("SSID 1", 20, 0, CMManagerShim::WlanSecModeOpen); + appendWlanAp("SSID 3", 20, 0, CMManagerShim::WlanSecModeWpa); + appendWlanAp("SSID 5", 20, 0, CMManagerShim::WlanSecModeWpa); + appendWlanAp("SSID 6", 20, 0, CMManagerShim::WlanSecModeWpa); + + mIaps.append(iap2); + mIaps.append(iap4); + + mWidget->updateContent(mIaps, mAps, 0); + + QCOMPARE(mListWidget->count(), 6); + verifyIap(0, 2); + verifyIap(1, 4); + verifyAp(2, QString("SSID 1"), CMManagerShim::WlanSecModeOpen); + verifyAp(3, QString("SSID 3"), CMManagerShim::WlanSecModeWpa); + verifyAp(4, QString("SSID 5"), CMManagerShim::WlanSecModeWpa); + verifyAp(5, QString("SSID 6"), CMManagerShim::WlanSecModeWpa); + + mIaps.clear(); + mAps.clear(); + mIaps.append(iap2); + appendWlanAp("SSID 1", 20, 0, CMManagerShim::WlanSecModeOpen); + + mWidget->updateContent(mIaps, mAps, 0); + + QCOMPARE(mListWidget->count(), 2); + verifyIap(0, 2); + verifyAp(1, QString("SSID 1"), CMManagerShim::WlanSecModeOpen); + + mIaps.clear(); + mAps.clear(); + mIaps.append(iap2); + mIaps.append(iap4); + appendWlanAp("SSID 1", 20, 0, CMManagerShim::WlanSecModeOpen); + appendWlanAp("SSID 3", 20, 0, CMManagerShim::WlanSecModeWpa); + appendWlanAp("SSID 5", 20, 0, CMManagerShim::WlanSecModeWpa); + appendWlanAp("SSID 6", 20, 0, CMManagerShim::WlanSecModeWpa); + + mWidget->updateContent(mIaps, mAps, 0); + + QCOMPARE(mListWidget->count(), 6); + verifyIap(0, 2); + verifyIap(1, 4); + verifyAp(2, QString("SSID 1"), CMManagerShim::WlanSecModeOpen); + verifyAp(3, QString("SSID 3"), CMManagerShim::WlanSecModeWpa); + verifyAp(4, QString("SSID 5"), CMManagerShim::WlanSecModeWpa); + verifyAp(5, QString("SSID 6"), CMManagerShim::WlanSecModeWpa); +} + +/*! + This function tests list sorting. The list content comes in "random" order, + and the list widget should sort the list alphabetically. + */ + +void TestWlanSniffer::testUpdateContentSort() +{ + appendWlanIap(1, 0, "Dada", "dada", 20, CMManagerShim::WlanSecModeOpen); + appendWlanIap(2, 0, "salakka", "salakka", 30, CMManagerShim::WlanSecModeWpa); + appendWlanIap(3, 0, "lahna", "lahna", 40, CMManagerShim::WlanSecModeOpen); + appendWlanIap(4, 0, "Labiili", "labiili", 50, CMManagerShim::WlanSecModeOpen); + appendWlanIap(5, 0, "ABCD", "ABCD", 60, CMManagerShim::WlanSecModeWpa); + appendWlanIap(6, 0, "connected", "connected", 60, CMManagerShim::WlanSecModeOpen); + appendWlanIap(7, 0, "IAP 1", "IAP 1", 10, CMManagerShim::WlanSecModeOpen); + appendWlanIap(8, 0, "IAP 10", "IAP 10", 10, CMManagerShim::WlanSecModeOpen); + appendWlanIap(9, 0, "IAP 2", "IAP 2", 10, CMManagerShim::WlanSecModeOpen); + appendWlanIap(10, 0, "IAP 11", "IAP 11", 10, CMManagerShim::WlanSecModeOpen); + + appendWlanAp("jokuap", 20, 0, CMManagerShim::WlanSecModeWpa); + appendWlanAp("Jippii", 30, 0, CMManagerShim::WlanSecModeOpen); + appendWlanAp("jalava", 40, 0, CMManagerShim::WlanSecModeWpa); + appendWlanAp("abba", 50, 0, CMManagerShim::WlanSecModeOpen); + appendWlanAp("hippokampus", 60, 0, CMManagerShim::WlanSecModeOpen); + + mWidget->updateContent(mIaps, mAps, 6); + + QCOMPARE(mListWidget->count(), 15); + verifyIap(0, 6); + verifyIap(1, 5); + verifyIap(2, 1); + verifyIap(3, 7); + verifyIap(4, 8); + verifyIap(5, 10); + verifyIap(6, 9); + verifyIap(7, 4); + verifyIap(8, 3); + verifyIap(9, 2); + verifyAp(10, QString("abba"), CMManagerShim::WlanSecModeOpen); + verifyAp(11, QString("hippokampus"), CMManagerShim::WlanSecModeOpen); + verifyAp(12, QString("jalava"), CMManagerShim::WlanSecModeWpa); + verifyAp(13, QString("Jippii"), CMManagerShim::WlanSecModeOpen); + verifyAp(14, QString("jokuap"), CMManagerShim::WlanSecModeWpa); +} + +/*! + This function tests list scrolling. There's no way to verify in this test + that the scrolling actually works, but let's execute the code at least. + */ + +void TestWlanSniffer::testScrollTo() +{ + appendWlanIap(1, 0, "SSID 1", "SSID 1", 15, CMManagerShim::WlanSecModeWpa); + appendWlanIap(2, 0, "SSID 2", "SSID 2", 95, CMManagerShim::WlanSecModeWpa); + appendWlanAp("SSID 3", 20, 0, CMManagerShim::WlanSecModeOpen); + appendWlanAp("SSID 4", 30, 0, CMManagerShim::WlanSecModeWep); + appendWlanAp("SSID 5", 40, 0, CMManagerShim::WlanSecModeOpen); + appendWlanAp("SSID 6", 20, 0, CMManagerShim::WlanSecModeOpen); + appendWlanAp("SSID 7", 30, 0, CMManagerShim::WlanSecModeWep); + appendWlanAp("SSID 8", 40, 0, CMManagerShim::WlanSecModeOpen); + appendWlanAp("SSID 9", 20, 0, CMManagerShim::WlanSecModeOpen); + appendWlanAp("SSID 10", 30, 0, CMManagerShim::WlanSecModeWep); + appendWlanAp("SSID 11", 40, 0, CMManagerShim::WlanSecModeOpen); + appendWlanAp("SSID 12", 20, 0, CMManagerShim::WlanSecModeOpen); + appendWlanAp("SSID 13", 30, 0, CMManagerShim::WlanSecModeWep); + appendWlanAp("SSID 14", 40, 0, CMManagerShim::WlanSecModeOpen); + + mWidget->updateContent(mIaps, mAps, 0); + + QCOMPARE(mListWidget->count(), 14); + + // Scroll to last row + mWidget->scrollTo(13); + // Scroll to non-existing row -> ignored + mWidget->scrollTo(20); + // Scroll to first row + mWidget->scrollTo(0); + + QCOMPARE(mListWidget->count(), 14); +} + +/*! + This function verifies that the item on "row" is an IAP matching the given parameters. + */ + +void TestWlanSniffer::verifyIap(int row, int iapId) +{ + QVERIFY(mListWidget->item(row)->data().canConvert()); + int id = mListWidget->item(row)->data().value(); + QCOMPARE(id, iapId); +} + +/*! + This function verifies that the item on "row" is an AP matching the given parameters. + */ + +void TestWlanSniffer::verifyAp(int row, QString ssid, int securityMode) +{ + QVERIFY(mListWidget->item(row)->data().canConvert()); + WlanQtUtilsAp ap = mListWidget->item(row)->data().value(); + QCOMPARE(ap.value(WlanQtUtilsAp::ConfIdSsid).toString(), ssid); + QCOMPARE(ap.value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(), securityMode); +} + +/*! + Sub test case for appending an AP to AP list. +*/ + +void TestWlanSniffer::appendWlanAp( + QString ssId, + int signalStrength, + int networkMode, + int securityMode) +{ + QSharedPointer ap(new WlanQtUtilsAp()); + ap->setValue(WlanQtUtilsAp::ConfIdSsid, ssId); + ap->setValue(WlanQtUtilsAp::ConfIdSignalStrength, signalStrength); + ap->setValue(WlanQtUtilsAp::ConfIdConnectionMode, networkMode); + ap->setValue(WlanQtUtilsAp::ConfIdSecurityMode, securityMode); + ap->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false); + mAps.append(ap); +} + +/*! + Sub test case for appending an IAP to IAP list. +*/ + +void TestWlanSniffer::appendWlanIap( + int iapId, + int netId, + QString name, + QString ssId, + int signalStrength, + int securityMode) +{ + WlanQtUtilsIap *iap = new WlanQtUtilsIap(); + iap->setValue(WlanQtUtilsIap::ConfIdIapId, iapId); + iap->setValue(WlanQtUtilsIap::ConfIdNetworkId, netId); + iap->setValue(WlanQtUtilsIap::ConfIdName, name); + iap->setValue(WlanQtUtilsAp::ConfIdSsid, ssId); + iap->setValue(WlanQtUtilsAp::ConfIdSignalStrength, signalStrength); + iap->setValue(WlanQtUtilsAp::ConfIdSecurityMode, securityMode); + mIaps.append(QSharedPointer(iap)); +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/tsrc/t_wlansniffer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/tsrc/t_wlansniffer.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,91 @@ +/* +* 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 "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* This is the header file for testing Wlan Sniffer application. +*/ + +#ifndef T_WLANSNIFFER_H +#define T_WLANSNIFFER_H + +// System includes + +#include +#include + +// User includes + +// Forward declarations + +class HbListWidget; +class WlanQtUtilsIap; +class WlanQtUtilsAp; +class WlanSnifferListWidget; + +// External data types + +// Constants + +// Class declaration + +class TestWlanSniffer: public QObject +{ + Q_OBJECT + +private slots: + + // Functions from QTest framework. + void initTestCase(); + void cleanupTestCase(); + void init(); + void cleanup(); + + // Test functions for WlanSnifferListWidget class + void testUpdateContentIapAdded(); + void testUpdateContentApAdded(); + void testUpdateContentIapRemoved(); + void testUpdateContentApRemoved(); + void testUpdateContentIapConnected(); + void testUpdateContentIapDisconnected(); + void testUpdateContentRobustness1(); + void testUpdateContentRobustness2(); + void testUpdateContentSort(); + void testScrollTo(); + +private: + + // Helper functions, that is, sub test cases. + void verifyIap(int row, int iapId); + void verifyAp(int row, QString ssid, int securityMode); + void appendWlanAp( + QString ssId, + int signalStrength, + int networkMode, + int securityMode); + void appendWlanIap( + int iapId, + int netId, + QString name, + QString ssId, + int signalStrength, + int securityMode); + +private: // data + + HbListWidget *mListWidget; + WlanSnifferListWidget *mWidget; + QList< QSharedPointer > mIaps; + QList< QSharedPointer > mAps; +}; + +#endif // T_WLANSNIFFER_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/tsrc/t_wlansniffer.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/tsrc/t_wlansniffer.pro Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,49 @@ +# +# 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 "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# WLAN Sniffer UT project file. +# + +CONFIG += qtestlib hb + +TEMPLATE = app +TARGET = t_wlansniffer + +TARGET.CAPABILITY = ALL -TCB + +DEPENDPATH += . + +#Store generated files to their own directory +MOC_DIR = build +RCC_DIR = build + +INCLUDEPATH += \ + . \ + ../inc \ + ../traces \ + ../../../inc + +# Input +HEADERS += \ + t_wlansniffer.h \ + ../inc/wlansnifferlistitem.h \ + ../inc/wlansnifferlistwidget.h \ + ../traces/OstTraceDefinitions.h + +SOURCES += \ + t_wlansniffer.cpp \ + ../src/wlansnifferlistitem.cpp \ + ../src/wlansnifferlistwidget.cpp + +symbian*::LIBS += -lwlanqtutilities diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferapplication/wlansnifferapplication.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferapplication/wlansnifferapplication.pro Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,79 @@ +# +# Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# 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". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# Project file for WLAN Sniffer application. +# + +TEMPLATE = app +TARGET = wlansniffer +TARGET.CAPABILITY = CAP_APPLICATION NetworkControl +DEPENDPATH += . +# Own headers +INCLUDEPATH += \ + inc \ + traces +# wlanutilities Private API +INCLUDEPATH += ../../inc +CONFIG += hb no_icon service + +# Temporary solution to fix tracecompiler +# When tracecompiler is fixed, this can be removed +symbian: { + MMP_RULES += "USERINCLUDE traces" +} + +#Store generated files to their own directory +MOC_DIR = build +RCC_DIR = build + +TRANSLATIONS = wlansniffer.ts + +# Input +SOURCES += \ + src/main.cpp \ + src/wlansniffer.cpp \ + src/wlansnifferengine.cpp \ + src/wlansnifferlistitem.cpp \ + src/wlansnifferlistview.cpp \ + src/wlansnifferlistwidget.cpp \ + src/wlansniffermainwindow.cpp \ + src/wlansnifferservice.cpp + +HEADERS += \ + inc/wlansniffer.h \ + inc/wlansnifferengine.h \ + inc/wlansnifferlistitem.h \ + inc/wlansnifferlistview.h \ + inc/wlansnifferlistwidget.h \ + inc/wlansniffermainwindow.h \ + inc/wlansnifferservice.h \ + traces/OstTraceDefinitions.h + +RESOURCES = res/wlansniffer.qrc + +SERVICE.FILE = res/service_conf.xml +SERVICE.OPTIONS = embeddable + +# Common libraries +LIBS += -lwlanqtutilities -lxqservice -lxqserviceutil -lqtsysteminfo -lwlanwizard -lxqsettingsmanager + +symbian*: { + TARGET.UID3 = 0x10281CAA + + BLD_INF_RULES.prj_exports += "rom/wlansniffer.iby CORE_MW_LAYER_IBY_EXPORT_PATH(wlansniffer.iby)" + BLD_INF_RULES.prj_exports += "rom/wlansniffer_resources.iby LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(wlansniffer_resources.iby)" + + # Enable for QtHighway tracing + # DEFINES += WLANSNIFFER_SERVICETRACES +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferkeepalive/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferkeepalive/group/bld.inf Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,26 @@ +/* +* 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 "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Build info file for Wlan Sniffer Keepalive process +*/ + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +../rom/wsfkeepalive.iby CORE_MW_LAYER_IBY_EXPORT_PATH(wsfkeepalive.iby) + +PRJ_MMPFILES +wsfkeepalive.mmp diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferkeepalive/group/wsfkeepalive.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferkeepalive/group/wsfkeepalive.mmp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,44 @@ +/* +* 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 "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Project definition file for Wlan Sniffer Keepalive process. +*/ + +TARGET wlansnifferkeepalive.exe +TARGETTYPE exe +UID 0x100039CE 0x2002FF5F + +USERINCLUDE ..\inc +USERINCLUDE ..\traces +MW_LAYER_SYSTEMINCLUDE + +SOURCEPATH ..\src +SOURCE main.cpp +SOURCE wsfkeepalive.cpp +SOURCE wsfkeepaliveconnmon.cpp +SOURCE wsfkeepaliveconnmondisc.cpp +SOURCE wsfkeepaliveesock.cpp +SOURCE wsfkeepalivetimer.cpp + +LIBRARY euser.lib +LIBRARY connmon.lib +LIBRARY esock.lib +LIBRARY extendedconnpref.lib +LIBRARY netmeta.lib + +CAPABILITY CAP_APPLICATION NetworkControl + +#ifdef ENABLE_ABIV2_MODE + DEBUGGABLE_UDEBONLY +#endif diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferkeepalive/inc/wsfkeepalive.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferkeepalive/inc/wsfkeepalive.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,164 @@ +/* +* 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 "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Main implementation of Wlan Sniffer Keepalive application. +*/ + +#ifndef WSFKEEPALIVE_H +#define WSFKEEPALIVE_H + +// System includes + +// User includes + +#include "wsfkeepalivetimer.h" + +// Forward declarations + +class CWsfKeepaliveConnMon; +class CWsfKeepaliveConnMonDisc; +class CWsfKeepaliveEsock; + +// External data types + +// Global function prototypes + +// Constants + +// Class declaration + +/** + * Main implementation of Wlan Sniffer Keepalive application. + * + * This class contains the actual application logic, which monitors + * Wlan connections and keeps them alive, if needed. + */ +class CWsfKeepalive : public CBase, public MWsfKeepaliveTimerNotify + { + // Friend classes: + friend class CWsfKeepaliveTestSuite; + +public: + + // Data types + + // Constants + + /** Invalid/not available connection ID */ + static const TUint KInvalidConnectionId = 0; + + /** Constructors */ + + /** + * Two-phased constructor. + * + * @return New object allocated from heap + */ + static CWsfKeepalive* NewL(); + + /**> Destructor */ + virtual ~CWsfKeepalive(); + +public: + + /** + * Timer expiration handler. Disconnects the monitored connection, + * if needed. Restarts timer, if needed. + * + * @param aError Status of the timer event + */ + void TimerExpired( TInt aError ); + + /** + * Wlan connection event handler. Shares and starts to monitor the + * opened connection, if necessary. + * + * @param aConnectionId ID of the opened connection + * @param aIapId IAP ID of the opened connection + */ + void WlanConnectionOpenedL( TUint aConnectionId, TUint aIapId ); + + /** + * Wlan connection event handler. Stops monitoring the connection. + */ + void WlanConnectionClosed(); + +protected: + +private: + + CWsfKeepalive(); + + void ConstructL(); + + TBool OpenedByWlanSniffer( TUint aConnectionId ); + + TBool NoRealClients( TUint aConnectionId ); + + void SetState( TUint aState ); + +private: // Data + + // Constants + + /** + * State values for the keepalive implementation + */ + enum + { + /** Not monitoring any connection */ + EInactive, + /** Monitoring connection, which has no real clients */ + EActiveNoClients, + /** Monitoring connection, which has one or more real clients */ + EActiveWithClients + }; + + /** + * Timer for polling users of a connection + */ + CWsfKeepaliveTimer* iTimer; + + /** + * Connection Monitor class reference + */ + CWsfKeepaliveConnMon* iConnMon; + + /** + * Connection Disconnector class reference + */ + CWsfKeepaliveConnMonDisc* iConnMonDisc; + + /** + * RConnection handler class reference + */ + CWsfKeepaliveEsock* iEsock; + + /** + * Time when keepalive started for monitored connection + */ + TTime iKeepaliveStart; + + /** + * ID of monitored connection, KInvalidConnectionId if not valid + */ + TUint iConnectionId; + + /** + * State of the keepalive implementation + */ + TUint iState; + }; + +#endif // WSFKEEPALIVE_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferkeepalive/inc/wsfkeepaliveconnmon.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferkeepalive/inc/wsfkeepaliveconnmon.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,107 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * Connection Monitor interface implementation. + */ + +#ifndef WSFKEEPALIVECONNMON_H +#define WSFKEEPALIVECONNMON_H + +// System includes + +#include +#include + +// User includes + +// Forward declarations + +class CWsfKeepalive; + +// External data types + +// Global function prototypes + +// Constants + +// Class declaration + +/** + * Connection Monitor interface implementation. + * + * This class uses the Connection Monitor interface to monitor status + * of Wlan connections we might be interested in. + */ +class CWsfKeepaliveConnMon : public CBase, public MConnectionMonitorObserver + { + // Friend classes: + +public: + + // Data types + + /** Constructors */ + + /** + * Two-phased constructor. + * + * @param aNotify Status of Wlan connections is notified to this class + * @return New object allocated from heap + */ + static CWsfKeepaliveConnMon* NewL( CWsfKeepalive& aNotify ); + + /**> Destructor */ + virtual ~CWsfKeepaliveConnMon(); + +public: + + /** + * Connection Monitor connection client info getter. + * + * @param aClientInfo Where to store information + * @param aConnectionId ID of the connection, whose info is requested + */ + void GetClientInfo( + TConnMonClientEnumBuf& aClientInfo, + TUint aConnectionId ); + +protected: + +private: + + CWsfKeepaliveConnMon( CWsfKeepalive& aNotify ); + + void ConstructL(); + + void EventL( const CConnMonEventBase& aConnMonEvent ); + +private: // Data + + /** + * Status of Wlan connections is notified to this class + */ + CWsfKeepalive& iNotify; + + /** + * Handle to Connection Monitor Server + */ + RConnectionMonitor iMonitor; + + /** + * Id of the connection we are currently monitoring + */ + TUint iMonitoringConnectionId; + }; + +#endif // WSFKEEPALIVECONNMON_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferkeepalive/inc/wsfkeepaliveconnmondisc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferkeepalive/inc/wsfkeepaliveconnmondisc.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,91 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * Connection Monitor disconnect interface implementation. + */ + +#ifndef WSFKEEPALIVECONNMONDISC_H +#define WSFKEEPALIVECONNMONDISC_H + +// System includes + +#include + +// User includes + +// Forward declarations + +class RConnectionMonitor; + +// External data types + +// Global function prototypes + +// Constants + +// Class declaration + +/** + * Connection Monitor disconnect interface implementation. + * + * This class uses the Connection Monitor interface to disconnect + * connections regardless of the amount of users for the connection. + */ +class CWsfKeepaliveConnMonDisc : public CBase + { + // Friend classes: + +public: + + // Data types + + /** Constructors */ + + /** + * Two-phased constructor. + * + * @return New object allocated from heap + */ + static CWsfKeepaliveConnMonDisc* NewL(); + + /**> Destructor */ + virtual ~CWsfKeepaliveConnMonDisc(); + +public: + + /** + * Disconnects the given connection regardless of the amount of + * users for the connection. + * + * @param aConnectionId ID of the connection to disconnect + */ + void Disconnect( TUint aConnectionId ); + +protected: + +private: + + CWsfKeepaliveConnMonDisc(); + + void ConstructL(); + +private: // Data + + /** + * Handle to Connection Monitor Server + */ + RConnectionMonitor iMonitor; + }; + +#endif // WSFKEEPALIVECONNMONDISC_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferkeepalive/inc/wsfkeepaliveesock.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferkeepalive/inc/wsfkeepaliveesock.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,100 @@ +/* +* 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 "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Esock library (RConnection) interface implementation. +*/ + +#ifndef WSFKEEPALIVEESOCK_H +#define WSFKEEPALIVEESOCK_H + +// System includes + +#include + +// User includes + +// Forward declarations + +// External data types + +// Global function prototypes + +// Constants + +// Class declaration + +/** + * Esock library (RConnection) interface implementation. + * + * This class implements RConnection opening and closing using the Esock + * library. + */ +class CWsfKeepaliveEsock : public CActive +{ + // Friend classes: + +public: + + // Data types + + /** Constructors */ + + /** + * Two-phased constructor. + * + * @return New object allocated from heap + */ + static CWsfKeepaliveEsock* NewL(); + + /**> Destructor */ + virtual ~CWsfKeepaliveEsock(); + +public: + + /** + * Starts connection creation. + * + * @param aIapId ID of the IAP to connect + */ + void ConnectL( TUint aIapId ); + + /** + * Stops connection. + */ + void Disconnect(); + +private: + + CWsfKeepaliveEsock(); + + void ConstructL(); + + void RunL(); + + void DoCancel(); + +private: // Data + + /** + * Handle to Socket Server + */ + RSocketServ iSocketServer; + + /** + * Handle to RConnection object + */ + RConnection iConnection; +}; + +#endif // WSFKEEPALIVEESOCK_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferkeepalive/inc/wsfkeepalivetimer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferkeepalive/inc/wsfkeepalivetimer.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,121 @@ +/* +* 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 "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Timer implementation. +*/ + +#ifndef WSFKEEPALIVETIMER_H +#define WSFKEEPALIVETIMER_H + +// System includes + +#include + +// User includes + +// Forward declarations + +// External data types + +// Global function prototypes + +// Constants + +// Class declaration + +/** + * Timer interface class. + * + * This is an interface class, which the Keepalive implementation needs + * to inherit in order to receive timer notifications. + */ +class MWsfKeepaliveTimerNotify + { +public: + + /** + * Pure virtual timer expiration function that needs to be + * implemented in the Keepalive implementation class. + * + * @param aError Status of the timer event + */ + virtual void TimerExpired( TInt aError ) = 0; + }; + +/** + * Timer implementation. + * + * This is the actual timer implementation class. + */ +class CWsfKeepaliveTimer: public CActive +{ + // Friend classes: + +public: + + // Data types + + /** Constructors */ + + /** + * Two-phased constructor. + * + * @param aNotify Timer expirations are notified to this class + * @return New object allocated from heap + */ + static CWsfKeepaliveTimer* NewL( MWsfKeepaliveTimerNotify& aNotify ); + + /**> Destructor */ + virtual ~CWsfKeepaliveTimer(); + +public: + + /** + * Sets the timer to expire after the given interval. + * + * @param aInterval Interval in microseconds + */ + void After( TTimeIntervalMicroSeconds32 aInterval ); + + /** + * Stops the timer. + */ + void Stop(); + +protected: + +private: + + CWsfKeepaliveTimer( MWsfKeepaliveTimerNotify& aNotify ); + + void ConstructL(); + + void RunL(); + + void DoCancel(); + +private: // Data + + /** + * Actual timer object + */ + RTimer iTimer; + + /** + * Timer expirations are notified to this class + */ + MWsfKeepaliveTimerNotify& iNotify; + }; + +#endif // WSFKEEPALIVETIMER_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferkeepalive/rom/wsfkeepalive.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferkeepalive/rom/wsfkeepalive.iby Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,29 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * Wlan Sniffer Keepalive process iby. + */ + +#ifndef WSFKEEPALIVE_IBY +#define WSFKEEPALIVE_IBY + +#include + +#ifdef __PROTOCOL_WLAN + +file=ABI_DIR\BUILD_DIR\wlansnifferkeepalive.exe PROGRAMS_DIR\wlansnifferkeepalive.exe + +#endif // __PROTOCOL_WLAN + +#endif // WSFKEEPALIVE_IBY diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferkeepalive/src/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferkeepalive/src/main.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,108 @@ +/* +* 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 "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Wlan Sniffer Keepalive main function. +*/ + +// System include files + +#include +#include + +// User include files + +#include "wsfkeepalive.h" +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "mainTraces.h" +#endif + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// Main implementation run in the active scheduler. +// --------------------------------------------------------------------------- +// +LOCAL_C void MainL() + { + OstTraceFunctionEntry0( WSFKEEPALIVEMAINL_ENTRY ); + + // Create the main implementation class and start monitoring events + CWsfKeepalive* implementation = CWsfKeepalive::NewL(); + + // Start active scheduler + CActiveScheduler::Start(); + + // All finished, cleanup + delete implementation; + + OstTraceFunctionExit0( WSFKEEPALIVEMAINL_EXIT ); + } + +// --------------------------------------------------------------------------- +// Starts main implementation. +// --------------------------------------------------------------------------- +// +LOCAL_C void DoStartL() + { + OstTraceFunctionEntry0( WSFKEEPALIVEDOSTARTL_ENTRY ); + + // Create active scheduler (to run active objects) + CActiveScheduler* scheduler = new (ELeave) CActiveScheduler(); + CleanupStack::PushL( scheduler ); + CActiveScheduler::Install( scheduler ); + + MainL(); + + // Delete active scheduler + CleanupStack::PopAndDestroy( scheduler ); + + OstTraceFunctionExit0( WSFKEEPALIVEDOSTARTL_EXIT ); + } + +// ======== GLOBAL FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// Main function of the application executable. +// --------------------------------------------------------------------------- +// +GLDEF_C TInt E32Main() + { + OstTraceFunctionEntry0( WSFKEEPALIVEE32MAIN_ENTRY ); + + // Create cleanup stack + __UHEAP_MARK; + CTrapCleanup* cleanup = CTrapCleanup::New(); + + // Run application code inside TRAP harness + TRAPD( mainError, DoStartL() ); + if ( mainError ) + { + OstTrace1( + TRACE_FATAL, + _E32MAIN_ERROR, + "::E32Main Error;mainError=%d", + mainError ); + } + + delete cleanup; + __UHEAP_MARKEND; + + OstTraceFunctionExit0( WSFKEEPALIVEE32MAIN_EXIT ); + return KErrNone; + } diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferkeepalive/src/wsfkeepalive.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferkeepalive/src/wsfkeepalive.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,332 @@ +/* +* 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 "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Main implementation of Wlan Sniffer Keepalive application. +*/ + +// System include files + +#include + +// User include files + +#include "wsfkeepalivetimer.h" +#include "wsfkeepaliveconnmon.h" +#include "wsfkeepaliveconnmondisc.h" +#include "wsfkeepaliveesock.h" +#include "wsfkeepalive.h" +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wsfkeepaliveTraces.h" +#endif + +// External function prototypes + +// Local constants + +// We need to poll for client info every 5 seconds +static const int KKeepalivePollInterval = 5000000; + +// We can close a connection after 5 minutes of inactivity +static const int KKeepaliveInactivityInterval = 300; + +// UID of Wlan sniffer application +static const TUid KWlanSnifferUid = { 0x10281CAA }; + +// List of UIDs of clients not considered as "real" +static const TUid KDiscardedClientUids[] = + { + { 0x2002FF5F }, // Sniffer keepalive process, that is, us + KWlanSnifferUid, // Sniffer application (wlansniffer.exe) + { 0x101fD9C5 } // DHCP server (dhcpserv.exe) + }; + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +CWsfKeepalive* CWsfKeepalive::NewL() + { + OstTraceFunctionEntry0( CWSFKEEPALIVE_NEWL_ENTRY ); + + CWsfKeepalive* me = new ( ELeave ) CWsfKeepalive(); + CleanupStack::PushL( me ); + me->ConstructL(); + CleanupStack::Pop( me ); + + OstTraceFunctionExit0( CWSFKEEPALIVE_NEWL_EXIT ); + return me; + } + +CWsfKeepalive::~CWsfKeepalive() + { + OstTraceFunctionEntry0( DUP1_CWSFKEEPALIVE_CWSFKEEPALIVE_ENTRY ); + + delete iEsock; + delete iConnMonDisc; + delete iConnMon; + delete iTimer; + + OstTraceFunctionExit0( DUP1_CWSFKEEPALIVE_CWSFKEEPALIVE_EXIT ); + } + +void CWsfKeepalive::TimerExpired( TInt aError ) + { + OstTraceFunctionEntry0( CWSFKEEPALIVE_TIMEREXPIRED_ENTRY ); + + TBool restartTimer = ETrue; // Should we restart timer or not? + if ( aError == KErrNone ) + { + // Timer successfully completed, handle it + if ( NoRealClients( iConnectionId ) ) + { + TTime now; + now.UniversalTime(); + + // Check whether we are moving from EActiveWithClients to + // EActiveNoClients + if ( iState == EActiveWithClients ) + { + OstTrace0( + TRACE_NORMAL, + CWSFKEEPALIVE_TIMEREXPIRED_RESET, + "CWsfKeepalive::TimerExpired Keepalive time reset" ); + + // Connection had clients, but doesn't anymore. Keepalive + // inactivity time starts now + iKeepaliveStart = now; + } + // Check whether keepalive time has been reached + else if ( iKeepaliveStart + + TTimeIntervalSeconds( KKeepaliveInactivityInterval ) <= now ) + { + OstTrace0( + TRACE_NORMAL, + CWSFKEEPALIVE_TIMEREXPIRED_DONE, + "CWsfKeepalive::TimerExpired Keepalive time expired" ); + + // Keepalive time limit expired, connection should be stopped + iEsock->Disconnect(); + iConnMonDisc->Disconnect( iConnectionId ); + restartTimer = EFalse; + } + + // There are now no real clients for the connection + SetState( EActiveNoClients ); + } + else + { + // One or more real clients are using the connection + SetState( EActiveWithClients ); + } + } + else + { + // Timer not successful, probably because we stopped it + restartTimer = EFalse; + } + + if ( restartTimer ) + { + TTimeIntervalMicroSeconds32 interval( KKeepalivePollInterval ); + iTimer->After( interval ); + } + + OstTraceFunctionExit0( CWSFKEEPALIVE_TIMEREXPIRED_EXIT ); + } + +void CWsfKeepalive::WlanConnectionOpenedL( TUint aConnectionId, TUint aIapId ) + { + OstTraceFunctionEntry0( CWSFKEEPALIVE_WLANCONNECTIONOPENEDL_ENTRY ); + + OstTraceExt2( + TRACE_NORMAL, + CWSFKEEPALIVE_WLANCONNECTIONOPENED, + "CWsfKeepalive::WlanConnectionOpened;aConnectionId=%u;aIapId=%u", + aConnectionId, + aIapId ); + + // We are only interested in connections opened by the Wlan Sniffer + if ( OpenedByWlanSniffer( aConnectionId ) ) + { + // Start to monitor this connection, and add us as a user to the + // connection + iConnectionId = aConnectionId; + iEsock->ConnectL( aIapId ); + + // Assume there are no real clients yet. Setup timer for polling + // when real clients might be added to the connection + SetState( EActiveNoClients ); + iKeepaliveStart.UniversalTime(); + + OstTrace0( + TRACE_NORMAL, + CWSFKEEPALIVE_WLANCONNECTIONOPENED_RESET, + "CWsfKeepalive::WlanConnectionOpened Keepalive time reset" ); + + TTimeIntervalMicroSeconds32 interval( KKeepalivePollInterval ); + iTimer->After( interval ); + } + + OstTraceFunctionExit0( CWSFKEEPALIVE_WLANCONNECTIONOPENEDL_EXIT ); + } + +void CWsfKeepalive::WlanConnectionClosed() + { + OstTraceFunctionEntry0( CWSFKEEPALIVE_WLANCONNECTIONCLOSED_ENTRY ); + + // No need to monitor anything anymore + SetState( EInactive ); + iConnectionId = KInvalidConnectionId; + // Stop also the polling timer + iTimer->Stop(); + + OstTraceFunctionExit0( CWSFKEEPALIVE_WLANCONNECTIONCLOSED_EXIT ); + } + +// --------------------------------------------------------------------------- +// Default constructor +// --------------------------------------------------------------------------- +// +CWsfKeepalive::CWsfKeepalive() : + iConnectionId( KInvalidConnectionId ), + iState( EInactive ) + { + OstTraceFunctionEntry0( CWSFKEEPALIVE_CWSFKEEPALIVE_ENTRY ); + OstTraceFunctionExit0( CWSFKEEPALIVE_CWSFKEEPALIVE_EXIT ); + } + +// --------------------------------------------------------------------------- +// Leaving constructor +// --------------------------------------------------------------------------- +// +void CWsfKeepalive::ConstructL() + { + OstTraceFunctionEntry0( CWSFKEEPALIVE_CONSTRUCTL_ENTRY ); + + iTimer = CWsfKeepaliveTimer::NewL( *this ); + iConnMon = CWsfKeepaliveConnMon::NewL( *this ); + iConnMonDisc = CWsfKeepaliveConnMonDisc::NewL(); + iEsock = CWsfKeepaliveEsock::NewL(); + + OstTraceFunctionExit0( CWSFKEEPALIVE_CONSTRUCTL_EXIT ); + } + +// --------------------------------------------------------------------------- +// Checks whether the given connection was opened by the Wlan Sniffer +// application +// --------------------------------------------------------------------------- +// +TBool CWsfKeepalive::OpenedByWlanSniffer( TUint aConnectionId ) + { + OstTraceFunctionEntry0( CWSFKEEPALIVE_OPENEDBYWLANSNIFFER_ENTRY ); + + TBool retVal = EFalse; + + // Get all clients of this connection + TConnMonClientEnumBuf clientInfo; + iConnMon->GetClientInfo( clientInfo, aConnectionId ); + + // Check whether Wlan sniffer is one of the clients + for ( TInt i( 0 ); i < clientInfo().iCount; ++i ) + { + if ( clientInfo().iUid[i] == KWlanSnifferUid ) + { + // Match found, stop looking + retVal = ETrue; + break; + } + } + + OstTraceExt2( + TRACE_NORMAL, + CWSFKEEPALIVE_OPENEDBYWLANSNIFFER, + "CWsfKeepalive::OpenedByWlanSniffer;aConnectionId=%u;retVal=%u", + aConnectionId, + retVal ); + + OstTraceFunctionExit0( CWSFKEEPALIVE_OPENEDBYWLANSNIFFER_EXIT ); + return retVal; + } + +// --------------------------------------------------------------------------- +// Checks whether there are any real clients using the given connection +// --------------------------------------------------------------------------- +// +TBool CWsfKeepalive::NoRealClients( TUint aConnectionId ) + { + OstTraceFunctionEntry0( CWSFKEEPALIVE_NOREALCLIENTS_ENTRY ); + + // Get all clients of this connection + TConnMonClientEnumBuf clientInfo; + iConnMon->GetClientInfo( clientInfo, aConnectionId ); + + // Get the client count + TInt clientCount = clientInfo().iCount; + + TInt discardedClientCount = sizeof( KDiscardedClientUids ) / sizeof( TUid ); + + // Decrease count by each non-real client we must discard + for ( TInt i( 0 ); i < clientInfo().iCount; ++i ) + { + for ( TInt j( 0 ); j < discardedClientCount; ++j ) + { + if ( clientInfo().iUid[i] == KDiscardedClientUids[j] ) + { + OstTrace1( + TRACE_NORMAL, + CWSFKEEPALIVE_NOREALCLIENTS_DISCARD, + "CWsfKeepalive::NoRealClients Client discarded;clientInfo().iUid[i].iUid=%x", + clientInfo().iUid[i].iUid ); + --clientCount; + break; + } + } + } + + // If we reached zero, there were no real clients + TBool retVal = clientCount == 0 ? ETrue : EFalse; + OstTraceExt2( + TRACE_NORMAL, + CWSFKEEPALIVE_NOREALCLIENTS, + "CWsfKeepalive::NoRealClients;aConnectionId=%u;retVal=%u", + aConnectionId, + retVal ); + + OstTraceFunctionExit0( CWSFKEEPALIVE_NOREALCLIENTS_EXIT ); + return retVal; + } + +// --------------------------------------------------------------------------- +// Sets the given state and traces the transition, if state changed. +// --------------------------------------------------------------------------- +// +void CWsfKeepalive::SetState( TUint aState ) + { + OstTraceFunctionEntry0( CWSFKEEPALIVE_SETSTATE_ENTRY ); + +#ifdef OST_TRACE_COMPILER_IN_USE + if ( aState != iState ) + { + OstTrace1( + TRACE_NORMAL, + CWSFKEEPALIVE_SETSTATE, + "CWsfKeepalive::SetState;aState=%{State}", + aState ); + } +#endif + iState = aState; + + OstTraceFunctionExit0( CWSFKEEPALIVE_SETSTATE_EXIT ); + } diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferkeepalive/src/wsfkeepaliveconnmon.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferkeepalive/src/wsfkeepaliveconnmon.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,213 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * Connection Monitor interface implementation. + */ + +// System include files + +#include +#include + +// User include files + +#include "wsfkeepalive.h" +#include "wsfkeepaliveconnmon.h" +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wsfkeepaliveconnmonTraces.h" +#endif + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +CWsfKeepaliveConnMon* CWsfKeepaliveConnMon::NewL( CWsfKeepalive& aNotify ) + { + OstTraceFunctionEntry0( CWSFKEEPALIVECONNMON_NEWL_ENTRY ); + + CWsfKeepaliveConnMon* me = new ( ELeave ) CWsfKeepaliveConnMon( aNotify ); + CleanupStack::PushL( me ); + me->ConstructL(); + CleanupStack::Pop( me ); + + OstTraceFunctionExit0( CWSFKEEPALIVECONNMON_NEWL_EXIT ); + return me; + } + +CWsfKeepaliveConnMon::~CWsfKeepaliveConnMon() + { + OstTraceFunctionEntry0( + DUP1_CWSFKEEPALIVECONNMON_CWSFKEEPALIVECONNMON_ENTRY ); + + // Stop monitoring observer events + iMonitor.CancelNotifications(); + iMonitor.Close(); + + OstTraceFunctionExit0( + DUP1_CWSFKEEPALIVECONNMON_CWSFKEEPALIVECONNMON_EXIT ); + } + +void CWsfKeepaliveConnMon::GetClientInfo( + TConnMonClientEnumBuf& aClientInfo, + TUint aConnectionId ) + { + OstTraceFunctionEntry0( CWSFKEEPALIVECONNMON_GETCLIENTINFO_ENTRY ); + + // Get all clients of this connection + TRequestStatus status; + iMonitor.GetPckgAttribute( + aConnectionId, + 0, + KClientInfo, + aClientInfo, + status ); + User::WaitForRequest( status ); + if ( status.Int() != KErrNone ) + { + // Make sure we don't try to use the result buffer since its + // contents are not ok + aClientInfo().iCount = 0; + } + +#ifdef OST_TRACE_COMPILER_IN_USE + for ( TInt i( 0 ); i < aClientInfo().iCount; ++i ) + { + OstTrace1( + TRACE_NORMAL, + CWSFKEEPALIVECONNMON_GETCLIENTINFO, + "CWsfKeepaliveConnMon::GetClientInfo Client ID;aClientInfo().iUid[i].iUid=%x", + aClientInfo().iUid[i].iUid ); + } +#endif + + OstTraceFunctionExit0( CWSFKEEPALIVECONNMON_GETCLIENTINFO_EXIT ); + } + +// --------------------------------------------------------------------------- +// Default constructor +// --------------------------------------------------------------------------- +// +CWsfKeepaliveConnMon::CWsfKeepaliveConnMon( CWsfKeepalive& aNotify ) : + iNotify( aNotify ), + iMonitoringConnectionId( CWsfKeepalive::KInvalidConnectionId ) + { + OstTraceFunctionEntry0( CWSFKEEPALIVECONNMON_CWSFKEEPALIVECONNMON_ENTRY ); + OstTraceFunctionExit0( CWSFKEEPALIVECONNMON_CWSFKEEPALIVECONNMON_EXIT ); + } + +// --------------------------------------------------------------------------- +// Leaving constructor +// --------------------------------------------------------------------------- +// +void CWsfKeepaliveConnMon::ConstructL() + { + OstTraceFunctionEntry0( CWSFKEEPALIVECONNMON_CONSTRUCTL_ENTRY ); + + iMonitor.ConnectL(); + // Start monitoring observer events + iMonitor.NotifyEventL( *this ); + + OstTraceFunctionExit0( CWSFKEEPALIVECONNMON_CONSTRUCTL_EXIT ); + } + +// --------------------------------------------------------------------------- +// Event method is called every time an observer event occures +// --------------------------------------------------------------------------- +// +void CWsfKeepaliveConnMon::EventL( const CConnMonEventBase& aConnMonEvent ) + { + OstTraceFunctionEntry0( CWSFKEEPALIVECONNMON_EVENTL_ENTRY ); + + TUint connectionId = aConnMonEvent.ConnectionId(); + TInt bearer; + TRequestStatus status; + + OstTraceExt2( + TRACE_NORMAL, + CWSFKEEPALIVECONNMON_EVENTL_EVENTTYPE, + "CWsfKeepaliveConnMon::EventL;connectionId=%u;aConnMonEvent.EventType()=%{ConnMonEvent}", + connectionId, + aConnMonEvent.EventType() ); + + const CConnMonConnectionStatusChange* connectionStatusChangeEvent; + switch ( aConnMonEvent.EventType() ) + { + case EConnMonDeleteConnection: + // We are only interested in one connection + if ( connectionId == iMonitoringConnectionId ) + { + iNotify.WlanConnectionClosed(); + iMonitoringConnectionId = CWsfKeepalive::KInvalidConnectionId; + } + break; + + case EConnMonConnectionStatusChange: + connectionStatusChangeEvent = + static_cast< + const CConnMonConnectionStatusChange* >( &aConnMonEvent ); + + OstTrace1( + TRACE_NORMAL, + CWSFKEEPALIVECONNMON_EVENTL_CONNSTATUS, + "CWsfKeepaliveConnMon::EventL;connectionStatusChangeEvent->ConnectionStatus()=%{ConnMonConnStatus}", + connectionStatusChangeEvent->ConnectionStatus() ); + + // We are only interested in connected event + if ( connectionStatusChangeEvent->ConnectionStatus() + == KLinkLayerOpen ) + { + // Get the connection bearer type. + iMonitor.GetIntAttribute( + connectionId, + 0, + KBearer, + bearer, + status ); + User::WaitForRequest( status ); + + // We are only interested in WLAN connections + if ( status.Int() == KErrNone && bearer == EBearerWLAN ) + { + // Get connection IAP ID. + TUint iapId = 0; + iMonitor.GetUintAttribute( + connectionId, + 0, + KIAPId, + iapId, + status ); + User::WaitForRequest( status ); + + if ( status == KErrNone ) + { + iNotify.WlanConnectionOpenedL( connectionId, iapId ); + // Remember this connection + iMonitoringConnectionId = connectionId; + } + } + } + break; + + default: + // Not interesting + break; + } + + OstTraceFunctionExit0( CWSFKEEPALIVECONNMON_EVENTL_EXIT ); + } diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferkeepalive/src/wsfkeepaliveconnmondisc.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferkeepalive/src/wsfkeepaliveconnmondisc.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,98 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * Connection Monitor disconnect interface implementation. + */ + +// System include files + +#include + +// User include files + +#include "wsfkeepaliveconnmondisc.h" +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wsfkeepaliveconnmondiscTraces.h" +#endif + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +CWsfKeepaliveConnMonDisc* CWsfKeepaliveConnMonDisc::NewL() + { + OstTraceFunctionEntry0( CWSFKEEPALIVECONNMONDISC_NEWL_ENTRY ); + + CWsfKeepaliveConnMonDisc* me = new ( ELeave ) CWsfKeepaliveConnMonDisc(); + CleanupStack::PushL( me ); + me->ConstructL(); + CleanupStack::Pop( me ); + + OstTraceFunctionExit0( CWSFKEEPALIVECONNMONDISC_NEWL_EXIT ); + return me; + } + +CWsfKeepaliveConnMonDisc::~CWsfKeepaliveConnMonDisc() + { + OstTraceFunctionEntry0( + DUP1_CWSFKEEPALIVECONNMONDISC_CWSFKEEPALIVECONNMONDISC_ENTRY ); + + iMonitor.Close(); + + OstTraceFunctionExit0( + DUP1_CWSFKEEPALIVECONNMONDISC_CWSFKEEPALIVECONNMONDISC_EXIT ); + } + +void CWsfKeepaliveConnMonDisc::Disconnect( TUint aConnectionId ) + { + OstTraceFunctionEntry0( CWSFKEEPALIVECONNMONDISC_DISCONNECT_ENTRY ); + + TInt KErr = iMonitor.SetBoolAttribute( + aConnectionId, + 0, + KConnectionStop, + ETrue ); + + OstTraceFunctionExit0( CWSFKEEPALIVECONNMONDISC_DISCONNECT_EXIT ); + } + +// --------------------------------------------------------------------------- +// Default constructor +// --------------------------------------------------------------------------- +// +CWsfKeepaliveConnMonDisc::CWsfKeepaliveConnMonDisc() + { + OstTraceFunctionEntry0( + CWSFKEEPALIVECONNMONDISC_CWSFKEEPALIVECONNMONDISC_ENTRY ); + OstTraceFunctionExit0( + CWSFKEEPALIVECONNMONDISC_CWSFKEEPALIVECONNMONDISC_EXIT ); + } + +// --------------------------------------------------------------------------- +// Leaving constructor +// --------------------------------------------------------------------------- +// +void CWsfKeepaliveConnMonDisc::ConstructL() + { + OstTraceFunctionEntry0( CWSFKEEPALIVECONNMONDISC_CONSTRUCTL_ENTRY ); + + iMonitor.ConnectL(); + + OstTraceFunctionExit0( CWSFKEEPALIVECONNMONDISC_CONSTRUCTL_EXIT ); + } diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferkeepalive/src/wsfkeepaliveesock.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferkeepalive/src/wsfkeepaliveesock.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,151 @@ +/* +* 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 "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Esock library (RConnection) interface implementation. +*/ + +// System include files + +#include +#include +#include +#include + +// User include files + +#include "wsfkeepaliveesock.h" +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wsfkeepaliveesockTraces.h" +#endif + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +CWsfKeepaliveEsock* CWsfKeepaliveEsock::NewL() + { + OstTraceFunctionEntry0( CWSFKEEPALIVEESOCK_NEWL_ENTRY ); + + CWsfKeepaliveEsock* me = new ( ELeave ) CWsfKeepaliveEsock(); + CleanupStack::PushL( me ); + me->ConstructL(); + CleanupStack::Pop( me ); + + OstTraceFunctionExit0( CWSFKEEPALIVEESOCK_NEWL_EXIT ); + return me; + } + +CWsfKeepaliveEsock::~CWsfKeepaliveEsock() + { + OstTraceFunctionEntry0( + DUP1_CWSFKEEPALIVEESOCK_CWSFKEEPALIVEESOCK_ENTRY ); + + Cancel(); + iSocketServer.Close(); + + OstTraceFunctionExit0( DUP1_CWSFKEEPALIVEESOCK_CWSFKEEPALIVEESOCK_EXIT ); + } + +void CWsfKeepaliveEsock::ConnectL( TUint aIapId ) + { + OstTraceFunctionEntry0( CWSFKEEPALIVEESOCK_CONNECTL_ENTRY ); + + // Open an RConnection object. + User::LeaveIfError( iConnection.Open( iSocketServer ) ); + + // Create overrides for connection preferences to force opening of the + // given IAP without any user prompts. + TConnPrefList prefList; + TExtendedConnPref prefs; + prefs.SetIapId( aIapId ); + prefs.SetNoteBehaviour( TExtendedConnPref::ENoteBehaviourConnSilent ); + prefList.AppendL( &prefs ); + + // Start a connection with connection preferences + iConnection.Start( prefList, iStatus ); + + SetActive(); + + OstTraceFunctionExit0( CWSFKEEPALIVEESOCK_CONNECTL_EXIT ); + } + +void CWsfKeepaliveEsock::Disconnect() + { + OstTraceFunctionEntry0( CWSFKEEPALIVEESOCK_DISCONNECT_ENTRY ); + + iConnection.Close(); + + OstTraceFunctionExit0( CWSFKEEPALIVEESOCK_DISCONNECT_EXIT ); + } + +// --------------------------------------------------------------------------- +// Default constructor +// --------------------------------------------------------------------------- +// +CWsfKeepaliveEsock::CWsfKeepaliveEsock() : + CActive( EPriorityStandard ) + { + OstTraceFunctionEntry0( CWSFKEEPALIVEESOCK_CWSFKEEPALIVEESOCK_ENTRY ); + OstTraceFunctionExit0( CWSFKEEPALIVEESOCK_CWSFKEEPALIVEESOCK_EXIT ); + } + +// --------------------------------------------------------------------------- +// Leaving constructor +// --------------------------------------------------------------------------- +// +void CWsfKeepaliveEsock::ConstructL() + { + OstTraceFunctionEntry0( CWSFKEEPALIVEESOCK_CONSTRUCTL_ENTRY ); + + CActiveScheduler::Add( this ); + User::LeaveIfError( iSocketServer.Connect() ); + + OstTraceFunctionExit0( CWSFKEEPALIVEESOCK_CONSTRUCTL_EXIT ); + } + +// --------------------------------------------------------------------------- +// Handles an active object's request completion event +// --------------------------------------------------------------------------- +// +void CWsfKeepaliveEsock::RunL() + { + OstTraceFunctionEntry0( CWSFKEEPALIVEESOCK_RUNL_ENTRY ); + + OstTrace1( + TRACE_NORMAL, + CWSFKEEPALIVEESOCK_RUNL, + "CWsfKeepaliveEsock::RunL;iStatus.Int()=%d", + iStatus.Int() ); + + OstTraceFunctionExit0( CWSFKEEPALIVEESOCK_RUNL_EXIT ); + } + +// --------------------------------------------------------------------------- +// Implements cancellation of an outstanding request +// --------------------------------------------------------------------------- +// +void CWsfKeepaliveEsock::DoCancel() + { + OstTraceFunctionEntry0( CWSFKEEPALIVEESOCK_DOCANCEL_ENTRY ); + + // Disconnect a (possibly) ongoing request + Disconnect(); + + OstTraceFunctionExit0( CWSFKEEPALIVEESOCK_DOCANCEL_EXIT ); + } diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferkeepalive/src/wsfkeepalivetimer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferkeepalive/src/wsfkeepalivetimer.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,132 @@ +/* +* 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 "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Timer implementation. +*/ + +// System include files + +// User include files + +#include "wsfkeepalivetimer.h" +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wsfkeepalivetimerTraces.h" +#endif + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +CWsfKeepaliveTimer* CWsfKeepaliveTimer::NewL( + MWsfKeepaliveTimerNotify& aNotify ) + { + OstTraceFunctionEntry0( CWSFKEEPALIVETIMER_NEWL_ENTRY ); + + CWsfKeepaliveTimer* me = + new ( ELeave ) CWsfKeepaliveTimer( aNotify ); + CleanupStack::PushL( me ); + me->ConstructL(); + CleanupStack::Pop( me ); + + OstTraceFunctionExit0( CWSFKEEPALIVETIMER_NEWL_EXIT ); + return me; + } + +CWsfKeepaliveTimer::~CWsfKeepaliveTimer() + { + OstTraceFunctionEntry0( DUP1_CWSFKEEPALIVETIMER_CWSFKEEPALIVETIMER_ENTRY ); + + Cancel(); + iTimer.Close(); + + OstTraceFunctionExit0( DUP1_CWSFKEEPALIVETIMER_CWSFKEEPALIVETIMER_EXIT ); + } + +void CWsfKeepaliveTimer::After( TTimeIntervalMicroSeconds32 aInterval ) + { + OstTraceFunctionEntry0( CWSFKEEPALIVETIMER_AFTER_ENTRY ); + + // Cancel a (possibly) ongoing timer before starting new one + Cancel(); + iTimer.After( iStatus, aInterval ); + SetActive(); + + OstTraceFunctionExit0( CWSFKEEPALIVETIMER_AFTER_EXIT ); + } + +void CWsfKeepaliveTimer::Stop() + { + OstTraceFunctionEntry0( CWSFKEEPALIVETIMER_STOP_ENTRY ); + + iTimer.Cancel(); + + OstTraceFunctionExit0( CWSFKEEPALIVETIMER_STOP_EXIT ); + } + +// --------------------------------------------------------------------------- +// Default constructor +// --------------------------------------------------------------------------- +// +CWsfKeepaliveTimer::CWsfKeepaliveTimer( MWsfKeepaliveTimerNotify& aNotify ) : + CActive( EPriorityStandard ), + iNotify( aNotify ) + { + OstTraceFunctionEntry0( CWSFKEEPALIVETIMER_CWSFKEEPALIVETIMER_ENTRY ); + OstTraceFunctionExit0( CWSFKEEPALIVETIMER_CWSFKEEPALIVETIMER_EXIT ); + } + +// --------------------------------------------------------------------------- +// Leaving constructor +// --------------------------------------------------------------------------- +// +void CWsfKeepaliveTimer::ConstructL() + { + OstTraceFunctionEntry0( CWSFKEEPALIVETIMER_CONSTRUCTL_ENTRY ); + + CActiveScheduler::Add( this ); + User::LeaveIfError( iTimer.CreateLocal() ); + + OstTraceFunctionExit0( CWSFKEEPALIVETIMER_CONSTRUCTL_EXIT ); + } + +// --------------------------------------------------------------------------- +// Handles an active object's request completion event +// --------------------------------------------------------------------------- +// +void CWsfKeepaliveTimer::RunL() + { + OstTraceFunctionEntry0( CWSFKEEPALIVETIMER_RUNL_ENTRY ); + + iNotify.TimerExpired( iStatus.Int() ); + + OstTraceFunctionExit0( CWSFKEEPALIVETIMER_RUNL_EXIT ); + } + +// --------------------------------------------------------------------------- +// Implements cancellation of an outstanding request +// --------------------------------------------------------------------------- +// +void CWsfKeepaliveTimer::DoCancel() + { + OstTraceFunctionEntry0( CWSFKEEPALIVETIMER_DOCANCEL_ENTRY ); + + iTimer.Cancel(); + + OstTraceFunctionExit0( CWSFKEEPALIVETIMER_DOCANCEL_EXIT ); + } diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferkeepalive/traces/OstTraceDefinitions.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferkeepalive/traces/OstTraceDefinitions.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,21 @@ +/* +* 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 "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* OST trace definition header. +*/ + +#ifndef __OSTTRACEDEFINITIONS_H__ +#define __OSTTRACEDEFINITIONS_H__ +#include +#endif diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlansniffer/wlansnifferkeepalive/traces/trace.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlansniffer/wlansnifferkeepalive/traces/trace.properties Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,51 @@ + + + + Inactive + ActiveNoClients + ActiveWithClients + + + + EConnMonCreateConnection + EConnMonDeleteConnection + EConnMonCreateSubConnection + EConnMonDeleteSubConnection + EConnMonDownlinkDataThreshold + EConnMonUplinkDataThreshold + EConnMonNetworkStatusChange + EConnMonConnectionStatusChange + EConnMonConnectionActivityChange + EConnMonNetworkRegistrationChange + EConnMonBearerChange + EConnMonSignalStrengthChange + EConnMonBearerAvailabilityChange + EConnMonIapAvailabilityChange + EConnMonTransmitPowerChange + EConnMonSNAPsAvailabilityChange + EConnMonNewWLANNetworkDetected + EConnMonOldWLANNetworkLost + EConnMonPacketDataAvailable + EConnMonPacketDataUnavailable + EConnMonBearerInfoChange + EConnMonBearerGroupChange + + + + KConnectionUninitialised + KStartingSelection + KFinishedSelection + KConnectionFailure + KDataTransferTemporarilyBlocked + KLinkLayerOpen + KLinkLayerClosed + KConfigDaemonLoading + KConfigDaemonLoaded + KConfigDaemonStartingRegistration + KConfigDaemonFinishedRegistration + KConfigDaemonStartingDeregistration + KConfigDaemonFinishedDeregistrationStop + KConfigDaemonUnloading + KConfigDaemonUnloaded + + \ No newline at end of file diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanutilities.pro --- a/wlanutilities/wlanutilities.pro Fri May 14 10:30:51 2010 +0300 +++ b/wlanutilities/wlanutilities.pro Mon May 24 21:11:39 2010 +0300 @@ -1,5 +1,5 @@ # -# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). # All rights reserved. # This component and the accompanying materials are made available # under the terms of "Eclipse Public License v1.0" @@ -12,19 +12,17 @@ # Contributors: # # Description: +# Project file for wlanutilities directory in wirelessacc package. # TEMPLATE = subdirs SUBDIRS += \ wlanqtutilities \ + wlanwizard \ wlansniffer \ wlanentryplugin \ wlanindicatorplugin \ cpwlansettingsplugin - + CONFIG += ordered - -symbian*: { - SYMBIAN_PLATFORMS = WINSCW ARMV5 -} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/bwins/wlanwizardu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/bwins/wlanwizardu.def Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,18 @@ +EXPORTS + ?qt_metacall@WlanWizard@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 1 NONAME ; int WlanWizard::qt_metacall(enum QMetaObject::Call, int, void * *) + ?setParameters@WlanWizard@@QAEXABVQString@@HH_N11@Z @ 2 NONAME ; void WlanWizard::setParameters(class QString const &, int, int, bool, bool, bool) + ?metaObject@WlanWizard@@UBEPBUQMetaObject@@XZ @ 3 NONAME ; struct QMetaObject const * WlanWizard::metaObject(void) const + ?trUtf8@WlanWizard@@SA?AVQString@@PBD0@Z @ 4 NONAME ; class QString WlanWizard::trUtf8(char const *, char const *) + ?tr@WlanWizard@@SA?AVQString@@PBD0H@Z @ 5 NONAME ; class QString WlanWizard::tr(char const *, char const *, int) + ?trUtf8@WlanWizard@@SA?AVQString@@PBD0H@Z @ 6 NONAME ; class QString WlanWizard::trUtf8(char const *, char const *, int) + ??_EWlanWizard@@UAE@I@Z @ 7 NONAME ; WlanWizard::~WlanWizard(unsigned int) + ?show@WlanWizard@@QAEXXZ @ 8 NONAME ; void WlanWizard::show(void) + ?cancelled@WlanWizard@@IAEXXZ @ 9 NONAME ; void WlanWizard::cancelled(void) + ?tr@WlanWizard@@SA?AVQString@@PBD0@Z @ 10 NONAME ; class QString WlanWizard::tr(char const *, char const *) + ?getStaticMetaObject@WlanWizard@@SAABUQMetaObject@@XZ @ 11 NONAME ; struct QMetaObject const & WlanWizard::getStaticMetaObject(void) + ??1WlanWizard@@UAE@XZ @ 12 NONAME ; WlanWizard::~WlanWizard(void) + ?finished@WlanWizard@@IAEXH_N@Z @ 13 NONAME ; void WlanWizard::finished(int, bool) + ?staticMetaObject@WlanWizard@@2UQMetaObject@@B @ 14 NONAME ; struct QMetaObject const WlanWizard::staticMetaObject + ??0WlanWizard@@QAE@PAVHbMainWindow@@@Z @ 15 NONAME ; WlanWizard::WlanWizard(class HbMainWindow *) + ?qt_metacast@WlanWizard@@UAEPAXPBD@Z @ 16 NONAME ; void * WlanWizard::qt_metacast(char const *) + diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/eabi/wlanwizardu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/eabi/wlanwizardu.def Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,18 @@ +EXPORTS + _ZN10WlanWizard11qt_metacallEN11QMetaObject4CallEiPPv @ 1 NONAME + _ZN10WlanWizard11qt_metacastEPKc @ 2 NONAME + _ZN10WlanWizard13setParametersERK7QStringiibbb @ 3 NONAME + _ZN10WlanWizard16staticMetaObjectE @ 4 NONAME DATA 16 + _ZN10WlanWizard19getStaticMetaObjectEv @ 5 NONAME + _ZN10WlanWizard4showEv @ 6 NONAME + _ZN10WlanWizard8finishedEib @ 7 NONAME + _ZN10WlanWizard9cancelledEv @ 8 NONAME + _ZN10WlanWizardC1EP12HbMainWindow @ 9 NONAME + _ZN10WlanWizardC2EP12HbMainWindow @ 10 NONAME + _ZN10WlanWizardD0Ev @ 11 NONAME + _ZN10WlanWizardD1Ev @ 12 NONAME + _ZN10WlanWizardD2Ev @ 13 NONAME + _ZNK10WlanWizard10metaObjectEv @ 14 NONAME + _ZTI10WlanWizard @ 15 NONAME + _ZTV10WlanWizard @ 16 NONAME + diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/inc/wlanwizard.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/inc/wlanwizard.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,88 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * WLAN Wizard API + * + */ + +#ifndef WLANWIZARD_H +#define WLANWIZARD_H + +// System includes +#include + +// User includes + +// Forward declarations +class HbMainWindow; +class WlanWizardPrivate; +class TestWlanWizardUi; + +// External data types + +// Constants +#ifdef BUILD_WLAN_WIZARD_DLL +#define WLAN_WIZARD_EXPORT Q_DECL_EXPORT +#else +#define WLAN_WIZARD_EXPORT Q_DECL_IMPORT +#endif + +/*! + @addtogroup group_wlan_wizard_api + @{ + */ +class WLAN_WIZARD_EXPORT WlanWizard: public QObject +{ + Q_OBJECT + +public: + explicit WlanWizard(HbMainWindow *mainWindow ); + virtual ~WlanWizard(); + + void setParameters( + const QString &ssid, + int networkMode, + int securityMode, + bool usePsk, + bool hidden, + bool wps); + +signals: + void cancelled(); + void finished(int iapId, bool connected); + +public slots: + void show(); + +protected: + +protected slots: + +private: + Q_DISABLE_COPY(WlanWizard) + +private slots: + +private: + //! Pointer to private implementation + WlanWizardPrivate *d_ptr; + + // Friend classes + friend class WlanWizardPrivate; + friend class TestWlanWizardUi; +}; + +/*! @} */ + +#endif /* WLANWIZARD_H_ */ diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/inc/wlanwizard_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/inc/wlanwizard_p.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,192 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * WLAN Wizard: Private implementation. + * + */ + +#ifndef WLANWIZARD_P_H +#define WLANWIZARD_P_H + +// System includes +#include +#include + +// User includes +#include "wlanwizardhelper.h" + +// Forward declarations +class QTimer; +class HbTranslator; +class HbStackedWidget; +class HbWidget; +class HbLabel; +class HbDialog; +class HbAction; +class HbDocumentLoader; +class HbMainWindow; +class WlanQtUtils; +class WlanWizardPlugin; +class WlanWizardPage; +class WlanWizard; +class EapWizard; +class WpsWizard; + +class TestWlanWizardUi; + +// External data types + +// Constants + +/*! + @addtogroup group_wlan_wizard + @{ + */ +class WlanWizardPrivate: public QObject, public WlanWizardHelper +{ + Q_OBJECT + +public: + // API implementation + WlanWizardPrivate(WlanWizard* wizard, HbMainWindow *mainWindow); + virtual ~WlanWizardPrivate(); + + void setParameters( + const QString &ssid, + int networkMode, + int securityMode, + bool usePsk, + bool hidden, + bool wps); + + void show(); + +public: + // For WLAN Wizard pages + int getNextPageId( + const QString &ssid, + int networkMode, + int securityMode, + bool usePsk, + bool hidden, + bool wps); + + WlanQtUtils* wlanQtUtils() const; + WlanWizardPlugin* wlanWizardPlugin() const; + bool isEapEnabled() const; + bool handleIap(); + +public: + // from WlanWizardHelper, for all wizards + virtual QVariant configuration(ConfigurationId confId) const; + virtual void setConfiguration(ConfigurationId confId, const QVariant &value); + virtual void enableNextButton(bool enable); + virtual void enablePrevButton(bool enable); + virtual void addPage(int pageId, WlanWizardPage *page); + virtual void nextPage(); + virtual HbMainWindow* mainWindow() const; + virtual bool isCurrentPage(const HbWidget *page) const; + virtual int nextPageId(bool useWps); + +signals: + +public slots: + +protected: + +protected slots: + +private: + Q_DISABLE_COPY(WlanWizardPrivate) + static const int PageTimeout = 1500; + +private slots: + void cancelTriggered(); + void previousTriggered(); + void nextTriggered(); + void finishTriggered(); + void onTimeOut(); + void startPageOperation(); + +private: + void toNextPage(); + void showPage(int pageId, bool removeFromStack); + void createPages(); + void closeViews(); + void updateFrame(int pageId); + void loadDocml(); + void disconnectActions(); + +private: + // Not owned pointers + //! Pointer to Wizard API class, needed to send signals + WlanWizard *q_ptr; + //! Pointer to mainwindow from where the wizard was launched + HbMainWindow *mMainWindow; + //! used for timer protected pages (progressbar) + QTimer *mPageTimer; + //! Wizard heading aka HbDialog::heading + HbLabel *mTitle; + //! Toolbar action: Next + HbAction *mActionNext; + //! Toolbar action: Previous + HbAction *mActionPrevious; + //! Toolbar action: Finish + HbAction *mActionFinish; + //! Toolbar action: Cancel + HbAction *mActionCancel; + /*! acts as HbDialog::contentWidget. When next is clicked a wizard page + (HbWidget) is added to the stack. When prev is pressed the current + item is removed from the stack. The previous pages are always in the + stacked widget + */ + HbStackedWidget *mStackedWidget; + + // Owned pointers + + //! Dialog, from docml + QScopedPointer mDialog; + //! Translator + QScopedPointer mTranslator; + //! Provides services like: create/update iap, scan, connect, disconnect + QScopedPointer mWlanQtUtils; + //! Document loader for docml + QScopedPointer mDocLoader; + //! Extensible Authentication Protocol (EAP) Wizard plugin, instantiated + //! when required + EapWizard* mEapWizard; + //! Wifi Protected Setup (WPS) Wizard plugin, instantiated when required + WpsWizard* mWpsWizard; + //! Maps UI object of page into a control object + QHash mPageMapper; + //! Maps page id to control object of page. + QHash mPages; + + //! Holds wlan wizard configurations. + QHash mConfigurations; + //! holds the page id which is displayed when WlanWizard::show() is called + int mFirstPageId; + //! Flag to keep track if movement to next page is allowed when timer is used + bool mPageFinished; + //! flag to indicate that wizard has been closed via either cancel or finish + bool mClosed; + + // Friend classes + friend class WlanWizard; + friend class TestWlanWizardUi; +}; + +/*! @} */ + +#endif // WLANWIZARD_P_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/inc/wlanwizardhelper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/inc/wlanwizardhelper.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,194 @@ +/* +* 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 "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Wizard Plugin API: Interface for plugins to wizard services. +*/ + +#ifndef WLANWIZARDHELPER_H +#define WLANWIZARDHELPER_H + +// System includes +#include + +// User includes + +// Forward declarations +class HbMainWindow; +class HbWidget; +class WlanWizardPage; + +// External data types + +// Constants + +/*! + * @addtogroup group_wlan_wizard_api_internal + * @{ + */ + +/*! + This class specifies the interface class that wizard plugins (EAP and WPS) + can use to access wizard framework services. + */ +class WlanWizardHelper +{ +public: + /*! + WLAN Wizard configuration, which are accessible by wlan wizard and it's + plugins. WLAN wizard pages uses this information to store configurations + from ui and state events. + + Please remember to update trace.properties upon changes. + */ + enum ConfigurationId { + //! QString: WLAN Network name (aka SSID) + ConfSsid = 0, + //! int: CMManagerShim::WlanConnectionMode + ConfNetworkMode = 1, + //! int: CMManagerShim::WlanSecMode + ConfSecurityMode = 2, + //! QString: WPA PSK + ConfKeyWpa = 3, + //! QString: WEP Key 1 + ConfKeyWep1 = 4, + //! QString: WEP Key 2 + ConfKeyWep2 = 5, + //! QString: WEP Key 3 + ConfKeyWep3 = 6, + //! QString: WEP Key 4 + ConfKeyWep4 = 7, + //! int: CMManagerShim:::WlanWepKeyIndex, Default WEP Key index + ConfKeyWepDefault = 8, + //! bool: Internet Connectivity Test result, true passed. + ConfIctStatus = 9, + //! int, -1 (WlanQtUtils::IapIdNone): not defined: IAP ID + ConfIapId = 10, + //! bool: true if connection was established successfully + ConfConnected = 11, + //! bool: if true hidden WLAN + ConfHiddenWlan = 12, + //! bool: if true use psk, if false use EAP + ConfUsePsk = 13, + //! bool: if true processing connection page is required. + ConfProcessSettings = 14, + //! QString: Localized error string for WlanWizardPageGenericError + ConfGenericErrorString = 15, + }; + +public: + + /*! + Reader method for wlan configurations. + + See ConfigurationId for further details about the data types in QVariant. + + @param [in] confId Defines what configuration is read. + + @return configuration value. + */ + virtual QVariant configuration(ConfigurationId confId) const = 0; + + /*! + Sets wlan configuration value for given configuration identifier. + See ConfigurationId for further details about the data types in QVariant. + + @param [in] confId Configuration Identifier do to be set + @param [in] value Value for configuration. + */ + virtual void setConfiguration( + ConfigurationId confId, + const QVariant &value) = 0; + + /*! + Enables the next button in wizard. + + @param [in] enable to enable button set to true. + */ + virtual void enableNextButton(bool enable) = 0; + + /*! + Enables the previous button in wizard. + + @param [in] enable to enable button set to true. + */ + virtual void enablePrevButton(bool enable) = 0; + + /*! + Adds a new wizard page into the wizard framework. + + @param [in] pageId The identifier of Page. See WlanWizardPage::PageIds. + @param [in] page New wizard page. + */ + virtual void addPage(int pageId, WlanWizardPage *page) = 0; + + /*! + Triggers movement to the next page. + + @note This operation has been protected with 1.5 second timer to prevent + too short lasting pages. + + @note Must be used with WlanWizardPage::startOperation(). + */ + virtual void nextPage() = 0; + + /*! + @return the main window of wizard. + */ + virtual HbMainWindow *mainWindow() const = 0; + + /*! + Checks if provided page visualization is the current visible page. + + @param [in] page Wizard Page visualization to be checked + + @return true if the page is currently visible. + */ + virtual bool isCurrentPage(const HbWidget *page) const = 0; + + /*! + Can be used to get correct page id based on the existing configuration. + + This method can be used in so called entry points to wizards + - WLAN Wizard has been lauched and setParameters() has been called + - WLAN Wizard makes own internal scanning + - WPS Wizard uses manual configuration mode. + + @param [in] useWps true: if WPS Wizard needs to be opened, false: otherwise + + @return Page Id based on configurations: + - WEP/WPA(2) with PSK: WlanWizardPageInternal::PageKeyQuery + - Open: WlanWizardPage::PageProcessSettings + - 802.1x or WPA (2) with EAP: WlanWizardPage::PageEapStart + - UseWps: WlanWizardPage::PageWpsStart + */ + virtual int nextPageId(bool useWps) = 0; + +signals: + +public slots: + +protected: + +protected slots: + +private: + +private slots: + +private: // data +}; + +/*! @} */ + +#endif // WLANWIZARDHELPER_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/inc/wlanwizardpage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/inc/wlanwizardpage.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,202 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * WLAN Wizard Plugin API: Interface for wizard pages. + * + */ + +#ifndef WLANWIZARDPAGE_H +#define WLANWIZARDPAGE_H + +// System includes + +// User includes + +// Forward declarations +class HbWidget; + +// External data types + +// Constants + +/*! + @addtogroup group_wlan_wizard_api_internal + @{ + */ + +/*! + Interface for wizard pages. + + Princibles of the interface, see description of the method for detailed + information. + - initializePage() is called at first to create the UI visualizatio + - showPage() is called to detect whether next button should be enabled. This + method is called every time before the current page is displayed. + - requiresStartOperation() is called to check if page needs timer protection. + This is mainly used for pages where are progress bar and some asyncronous + operation with network layer, which commands on success to progress to next + wizard page. + - startOperation() is called to start page operation, this is called if above + method returs true. + - nextId() is called when user presses next toolbar button or when page has + called WlanWizardHelper::nextPage() method, which is used with timer + protected pages. + - previousTriggered() is called when previous toolbar button is pressed. + - cancelTriggered() is called when cancel toolbar button is pressed. + + Wizard Page must implement all pure virtual methods + - initializePage() + - nextId() + + For other methods there is default implementation, which can be overwritten. + */ +class WlanWizardPage +{ +public: + /*! + Defines common page ids for wizard and page id pools for wizard plugins. + + Remember to update trace.properties file upon changes. + */ + enum PageIds { + //! No need to change the wizard page. + PageNone = 0, + //! Process settings. Start connection and runs ict + PageProcessSettings, + //! Generic Error note page + PageGenericError, + //! Starting value for WLAN wizard page ids. Defined by WLAN Wizard. + PageWlanStart = 0x1000, + //! Starting value for EAP wizard page ids. Defined by EAP Wizard. + PageEapStart = 0x2000, + //! Starting value for WPS wizard page ids. Defined by WPS Wizard. + PageWpsStart = 0x3000, + }; + +public: + + /*! + Creates a visualization of the wizard page and returns ownership of the + object to the caller. Wizard framework deletes the visualization at the + desctructor of WlanWizardPrivate implementation. WizardPage control + object can safely use the same pointer during the life time of the + control object. This method is called every time when moving to a new + page, not when user presses "previous" button. showPage() method is + called in both cases. + + @return pointer to a visualization of the page. + */ + virtual HbWidget* initializePage() = 0; + + /*! + This method is called, after a visualization is created with + initializePage() method, to detect whether next button should be enabled + or not. It is up to the policy of the page when next button should be + enabled. This method is called everytime before the current + active page is displayed. In other words this method is "aboutToShow()" + + Default implementation: wizard page is valid and next button is enabled. + + @return validity. + */ + virtual bool showPage() + { + return true; + }; + + /*! + If the wizard page requires timer protection and asyncronous time + lasting operation, 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 by this method. + - 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 needed. + */ + + virtual bool requiresStartOperation() + { + return false; + }; + + /*! + 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(). + */ + virtual void startOperation() {}; + + /*! + Returns id of next page. This method is called when end user has pressed + "next" toolbar button or WlanWizardHelper::nextPage() is called. + + In case the wizard page does not want to make any movement forwards + WlanWizardPage::PageNone MUST be returned. + + @param [out] removeFromStack return value to the caller, if this page + needs to be removed from the stack, which means that this page cannot be + accessible from the next page using "previous" toolbar button. + + @return page identifier of next wizard page + */ + virtual int nextId(bool &removeFromStack) const = 0; + + /*! + This method is called when "previous" button has been pressed. + + Default implementation: one page backwards + + @return how many steps should be gone backwards. + */ + virtual int previousTriggered() + { + return OneStepBackwards; + }; + + /*! + This method is called when "cancel" button has been pressed. + + Default implementation: No actions. + */ + virtual void cancelTriggered() {}; + +signals: + +public slots: + +protected: + //! default value for previousTriggered(), step one step. + static const int OneStepBackwards = 1; + +protected slots: + +private: + +private slots: + +private: // data +}; + +/*! @} */ + +#endif // WLANWIZARDPAGE_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/inc/wlanwizardpagegenericerror.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/inc/wlanwizardpagegenericerror.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,73 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * WLAN Wizard Page: Generic error page + * + */ + +#ifndef WLANWIZARDPAGEGENERICERROR_H +#define WLANWIZARDPAGEGENERICERROR_H + +// System includes + +// User includes +#include "wlanwizardpageinternal.h" + +// Forward declarations +class HbLabel; +class WlanWizardPrivate; + +// External data types + +// Constants + +/*! + @addtogroup group_wlan_wizard + @{ + */ + +class WlanWizardPageGenericError : public WlanWizardPageInternal +{ +public: + explicit WlanWizardPageGenericError(WlanWizardPrivate* parent); + virtual ~WlanWizardPageGenericError(); + +public: // From WlanWizardPage + HbWidget* initializePage(); + int nextId(bool &removeFromStack) const; + bool showPage(); + +signals: + +public slots: + +protected: + +protected slots: + +private: + Q_DISABLE_COPY(WlanWizardPageGenericError) + +private slots: + +private: // data + //! Pointer to visialization of this page + HbWidget *mWidget; + //! Error label. Gets string from WlanWizardHelper::ConfGenericErrorString + HbLabel *mLabel; +}; + +/*! @} */ + +#endif // WLANWIZARDPAGEGENERICERROR_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/inc/wlanwizardpageinternal.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/inc/wlanwizardpageinternal.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,92 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * WLAN Wizard: Interface for wizard pages (wlan internal). + * + */ + +#ifndef WLANWIZARDPAGEINTERNAL_H +#define WLANWIZARDPAGEINTERNAL_H + +// System includes +#include + +// User includes +#include "wlanwizardpage.h" + +// Forward declarations +class HbWidget; +class WlanWizardPrivate; + +// External data types + +// Constants + +/*! + @addtogroup group_wlan_wizard + @{ + */ + +class WlanWizardPageInternal : public QObject, public WlanWizardPage +{ +public: + /*! + WLAN Wizard internal pages. + + Remember to update trace.properties file upon changes. + */ + enum WlanPageIds { + //! SSID Query + PageSsid = WlanWizardPage::PageWlanStart, + //! Scanning page + PageScanning, + //! Manual network security selection page + PageNetworkSecurity, + //! WEP/WPA(2) key query page + PageKeyQuery, + //! WLAN Network mode page + PageNetworkMode, + //! Wizard summary page + PageSummary, + }; + +public: // from WlanWizardPage + explicit WlanWizardPageInternal(WlanWizardPrivate *wizard); + virtual ~WlanWizardPageInternal(); + +public: + //! Pointer to private object. Provides services to pages + WlanWizardPrivate* mWizard; + +signals: + +public slots: + +protected: + //! default value for previousTriggered(), step one step. + static const int OneStepBackwards = 1; + +protected slots: + +private: + Q_DISABLE_COPY(WlanWizardPageInternal) + +private slots: + +private: // data +}; + +/*! @} */ + +#endif // WLANWIZARDPAGEINTERNAL_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/inc/wlanwizardpagekeyquery.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/inc/wlanwizardpagekeyquery.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,90 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * WLAN Wizard Page: Key Query page for WEP and WPA (2). + * + */ + +#ifndef WLANWIZARDPAGEKEYQUERY_H +#define WLANWIZARDPAGEKEYQUERY_H + +// System includes + +// User includes +#include "wlanwizardpageinternal.h" +#include "wlanwizardutils.h" + +// Forward declarations +class QChar; +class HbLabel; +class HbLineEdit; +class HbDocumentLoader; +class WlanWizardPrivate; + +// External data types + +// Constants + +/*! + @addtogroup group_wlan_wizard + @{ + */ + +class WlanWizardPageKeyQuery: public WlanWizardPageInternal +{ + Q_OBJECT +public: + explicit WlanWizardPageKeyQuery(WlanWizardPrivate* parent); + virtual ~WlanWizardPageKeyQuery(); + +public: // From WlanWizardPageInternal + HbWidget* initializePage(); + int nextId(bool &removeFromStack) const; + bool showPage(); + +signals: + +public slots: + void loadDocmlSection(Qt::Orientation orientation); + +protected: + bool eventFilter(QObject *obj, QEvent *event); + +protected slots: + +private: + Q_DISABLE_COPY(WlanWizardPageKeyQuery) + QString keyStatusToErrorString(WlanWizardUtils::KeyStatus status) const; + +private slots: + +private: + // NOT OWNED + //! Visualization of the page + HbWidget *mWidget; + //! Title text for line editor + HbLabel *mLabelTitle; + //! Line editor for WLAN WEP / WPA PSK key + HbLineEdit *mLineEdit; + //! Label for key specific error texts + HbLabel *mLabelError; + + // OWNED + //! docml document loader + HbDocumentLoader *mDocLoader; +}; + +/*! @} */ + +#endif // WLANWIZARDPAGEKEYQUERY_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/inc/wlanwizardpagenetworkmode.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/inc/wlanwizardpagenetworkmode.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,148 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * WLAN Wizard Page: Manual Network mode query page. + * + */ + +/* + * %version: 8 % + */ + +#ifndef WLANWIZARDPAGENETWORKMODE_H +#define WLANWIZARDPAGENETWORKMODE_H + +// System includes + +// User includes +#include "wlanwizardpageinternal.h" + +// Forward declarations +class HbRadioButtonList; +class HbLabel; +class WlanWizardPrivate; +class HbDocumentLoader; + +// External data types + +// Constants + +/*! + * @addtogroup group_wlan_wizard + * @{ + */ + +class WlanWizardPageNetworkMode : public WlanWizardPageInternal +{ + Q_OBJECT +public: + + /*! + * Constructor method for the network mode view object + * @param parent pointer to parent object. + */ + WlanWizardPageNetworkMode(WlanWizardPrivate* parent); + + /*! + * Destructor for the network mode view object. + */ + ~WlanWizardPageNetworkMode(); + + +public: // From WlanWizardPageInternal + /*! + * Page initialization procedures. Inherited from WlanWizardPage. + */ + HbWidget* initializePage(); + + /*! + * Evaluates the network mode selection and sets the configuration in + * the wlanwizard. + * @param removeFromStack output parameter that returns false + * @return WlanWizardPageSecurityMode page id. + */ + int nextId(bool &removeFromStack) const; + + /*! + * This method is overrides the default implementation from WlanWizardPage. + * It indicates whether the Next-button should be enabled or not. + * @return true, if a mode has been selected. + */ + bool showPage(); + +public slots: + /*! + * Is invoked when user selects a mode from the radio button list. + * (HbRadioButtonList's itemSelected-signal) + */ + void itemSelected(int index); + + /*! + * Loads the document orientation information from occ_add_wlan_02_03.docml. + * This is called each time phone orientation changes. + * @param orientation indicates whether the phone is in portrait or + * landscape mode. + */ + void loadDocml(Qt::Orientation orientation); + +private: + + /*! + * A support function to map the radio button list to a generic network + * mode list. This enables the changing of button order without it + * affecting the entire class. + */ + void addToList(QStringList &list, const QString &item, int mode, bool isHidden); + + /*! + * Pointer to the view. + */ + HbWidget *mWidget; + + /*! + * Pointer to the radio button list object. + */ + HbRadioButtonList *mList; + + /*! + * Pointer to the label object. + */ + HbLabel *mLabel; + + /*! + * Pointer to document loader object. + */ + HbDocumentLoader *mLoader; + + /*! + * True, if a mode has been selected. False otherwise. + */ + bool mValid; + + /*! + * List of network modes. This list is tied to the radio buttons during + * the initialization of the page. + */ + QList mNetworkModes; + + /*! + * List of publicity modes. This list is tied to the radio buttons during + * the initialization of the page. + */ + QList mIsHidden; +}; + +/*! @} */ + +#endif diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/inc/wlanwizardpageprocessingsettings.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/inc/wlanwizardpageprocessingsettings.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,95 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * WLAN Wizard Page: Processing settings, connection and running ict. + * + */ + +#ifndef WLANWIZARDPAGEPROCESSINGSETTINGS_H +#define WLANWIZARDPAGEPROCESSINGSETTINGS_H + +// System includes + +// User includes +#include "wlanwizardpageinternal.h" +#ifdef ICT_RESULT_ENUM +#include "wlanqtutils.h" +#endif + +// Forward declarations +class HbDocumentLoader; +class HbLabel; +class WlanWizardPrivate; + +// External data types + +// Constants + +/*! + @addtogroup group_wlan_wizard + @{ + */ + +class WlanWizardPageProcessingSettings: public WlanWizardPageInternal +{ + Q_OBJECT +public: + explicit WlanWizardPageProcessingSettings(WlanWizardPrivate* parent); + virtual ~WlanWizardPageProcessingSettings(); + +public: // From WlanWizardPage + HbWidget* initializePage(); + int nextId(bool &removeFromStack) const; + bool showPage(); + bool requiresStartOperation(); + void startOperation(); + +signals: + +public slots: + void loadDocmlSection(Qt::Orientation orientation); + void wlanNetworkClosed(int iapId, int reason); +#ifdef ICT_RESULT_ENUM + void ictResult(int iapId, WlanLoginIctsResultType result); +#else + void ictResult(int iapId, bool result); +#endif + void wlanNetworkOpened(int iapId); + +protected: + +protected slots: + +private: + Q_DISABLE_COPY(WlanWizardPageProcessingSettings) + +private slots: + +private: // data + // OWNED + //! Docml document loader + HbDocumentLoader *mDocLoader; + + // NOT OWNED + //! Visualization of the page + HbWidget *mWidget; + //! Title for text in the page + HbLabel *mLabel; + //! PageId for next wizard page + int mNextPageId; +}; + +/*! @} */ + +#endif // WLANWIZARDPAGEPROCESSINGSETTINGS_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/inc/wlanwizardpagescanning.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/inc/wlanwizardpagescanning.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,168 @@ +/* +* 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 "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Wizard Page: Scan processing +*/ + +#ifndef WLANWIZARDPAGESCANNING_H +#define WLANWIZARDPAGESCANNING_H + +// System includes + +// User includes +#include "wlanwizardpageinternal.h" +#include "wlanwizard.h" + +// Forward declarations +class WlanWizardPrivate; +class HbLabel; +class HbProgressBar; +class HbDocumentLoader; + +// External data types + +// Constants + +/*! + * @addtogroup group_wlan_wizard + * @{ + */ + +class WlanWizardPageScanning: public WlanWizardPageInternal +{ + Q_OBJECT + +public: + /*! + * Constructor method for the scanning view object. + * @param parent pointer to parent object. + */ + WlanWizardPageScanning(WlanWizardPrivate* parent); + + /*! + * Destructor for the scanning view object. + */ + ~WlanWizardPageScanning(); + + /*! + * Page initialization procedures. Inherited from WlanWizardPage. + * @see WlanWizardPage + */ + HbWidget* initializePage(); + + /*! + * Validates the scan results and sets the configuration in the wlanwizard. + * @param removeFromStack output parameter that returns true. + * @return depending on the scan results, returns the appropriate view + * identifier. + */ + int nextId(bool &removeFromStack) const; + + /*! + * Reimplements the default function in WlanWizardPage. + * @return true + * @see WlanWizardPage + */ + bool requiresStartOperation(); + + /*! + * Reimplements the empty default function in WlanWizardPage. Initiates + * AP scan. + * @see WlanWizardPage + */ + void startOperation(); + + /*! + * This method is overrides the default implementation from WlanWizardPage. + * It indicates whether the Next-button should be enabled or not. + * @return always false - the scanning proceeds to next window + * automatically or not at all. + */ + bool showPage(); + +public slots: + /*! + * Loads the document orientation information from occ_add_wlan_06.docml + * This is called each time phone orientation changes. + * @param orientation indicates whether the phone is in portrait or + * landscape mode. + */ + void loadDocml(Qt::Orientation orientation); + + /*! + * Checks whether the view is active. If it is, execute wlanScanApReady. If + * not, set mScanResultsAvailable to true. + */ + void wlanScanResultPreCheck(); + + /*! + * Processes the direct scan results. If no results were found, the next + * page is network mode query. + * If match is found and scan result indicates + * a) Open network, the next page is result processing. + * b) Network with WEP/WPA/WPA2 protection, the next page is key query. + * c) EAP protected network, the next page is EAP type query. + * d) WPS support, the next page is WPS configuration page. + * All matching results are considered hidden networks. + */ + void wlanScanDirectReady(); + +private: + /*! + * Processes the Access Point scan results in search for an access point + * with an SSID that matches the SSID given by the user. If no match is + * found, a direct scan is initiated with the SSID given by the user. + * If match is found and scan result indicates + * a) Open network, the next page is result processing. + * b) Network with WEP/WPA/WPA2 protection, the next page is key query. + * c) EAP protected network, the next page is EAP type query. + * d) WPS support, the next page is WPS configuration page. + * All matching results are considered public networks. + */ + void wlanScanApReady(); + + /*! + * Pointer to the view. + */ + HbWidget *mWidget; + + /*! + * Pointer to the label widget. + */ + HbLabel *mLabel; + + /*! + * Pointer to the progress bar widget. + */ + HbProgressBar *mBar; + + /*! + * Pointer to document loader object. + */ + HbDocumentLoader *mLoader; + + /*! + * The next page identifier. + */ + int mNextPageId; + + /*! + * Indicator, whether AP scan results are available or not + */ + bool mScanResultsAvailable; +}; + +/*! @} */ + +#endif diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/inc/wlanwizardpagesecuritymode.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/inc/wlanwizardpagesecuritymode.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,168 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * WLAN Wizard Page: Security mode selection + * + */ + +/* + * %version: 10 % + */ + +#ifndef WLANWIZARDPAGESECURITYMODE_H +#define WLANWIZARDPAGESECURITYMODE_H + +// System includes + +// User includes +#include "wlanwizardpageinternal.h" + +// Forward declarations +class HbRadioButtonList; +class HbLabel; +class WlanWizardPrivate; +class HbDocumentLoader; + +// External data types + +// Constants + +/*! + * @addtogroup group_wlan_wizard + * @{ + */ + +class WlanWizardPageSecurityMode: public WlanWizardPageInternal +{ + Q_OBJECT +public: + /*! + * Constructor method for the Sequrity mode query view object. + * @param parent pointer to parent object. + */ + WlanWizardPageSecurityMode(WlanWizardPrivate* parent); + + /*! + * Destructor for the Sequrity mode query view object. + */ + ~WlanWizardPageSecurityMode(); + + /*! + * Page initialization procedures. Inherited from WlanWizardPage. + * @see WlanWizardPage + */ + HbWidget* initializePage(); + + /*! + * Validates the Sequrity more selection and sets the configuration in + * the wlanwizard. + * @param removeFromStack output parameter that returns false. + * @return depending on the sequrity mode, returns the appropriate view + * identifier. + */ + int nextId(bool &removeFromStack) const; + + /*! + * This method is overrides the default implementation from WlanWizardPage. + * It indicates whether the Next-button should be enabled or not. + * @return true, if a mode has been selected. + */ + bool showPage(); + +private slots: + /*! + * Is invoked when user selects a mode from the radio button list. + * (HbRadioButtonList's itemSelected-signal) + * @param index of the selected item in the radio button list. + */ + void itemSelected(int index); + + /*! + * Loads the document orientation information from occ_add_wlan_02_03.docml + * This is called each time phone orientation changes. + * @param orientation indicates whether the phone is in portrait or + * landscape mode. + */ + void loadDocml(Qt::Orientation orientation); + +private: + + /*! + * Support function that creates the contents of the security mode list. + */ + void populateSecModeList(); + + /*! + * A support function to map the radio button list to a generic network + * mode list. This enables the changing of button order without it + * affecting the entire class. + * @param list is a reference to a local list that will be placed as an + * argument to the radio button list. + * @param item is a reference to the text value that is appended to the + * list + * @param mode is the security mode associated with the item + * @param page is the id of the next wizard page when this item is selected. + * @param psk indicates whether password needs to be queried. + */ + void addToList(QStringList &list, const QString &item, int mode, int page, + bool psk); + + /*! + * Pointer to the view. + */ + HbWidget *mWidget; + + /*! + * Pointer to the radio button list object. + */ + HbRadioButtonList *mList; + + /*! + * Pointer to the label object. + */ + HbLabel *mLabel; + + /*! + * Pointer to document loader object. + */ + HbDocumentLoader *mLoader; + + /*! + * True, if a mode has been selected. False otherwise. + */ + bool mValid; + + /*! + * List of sequrity modes. This list is tied to the radio buttons during + * the initialization of the page. + */ + QList mSecModes; + + /*! + * List of page identifiers. This list is tied to the radio buttons during + * the initialization of the page. + */ + QList mPageIds; + + /*! + * List of password usage. This list is tied to the radio buttons during + * the initialization of the page. True, if password is to be queried, + * false otherwise + */ + QList mUsePsk; +}; + +/*! @} */ + +#endif diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/inc/wlanwizardpagessid.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/inc/wlanwizardpagessid.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,141 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * WLAN Wizard Page: Ssid query + * + */ + +#ifndef WLANWIZARDPAGESSID_H +#define WLANWIZARDPAGESSID_H + +// System includes + +// User includes +#include "wlanwizardpageinternal.h" +#include "wlanwizardutils.h" + +// Forward declarations +class WlanWizardPrivate; +class HbLabel; +class HbLineEdit; +class HbDocumentLoader; +class TestWlanWizardUi; + +// External data types + +// Constants + +/*! + * @addtogroup group_wlan_wizard + * @{ + */ + +class WlanWizardPageSsid: public WlanWizardPageInternal +{ + Q_OBJECT + friend class TestWlanWizardUi; +public: + /*! + * Constructor method for the SSID query view object. + * @param parent pointer to parent object. + */ + WlanWizardPageSsid(WlanWizardPrivate* parent); + + /*! + * Destructor for the SSID query view object. + */ + ~WlanWizardPageSsid(); + + /*! + * Page initialization procedures. Inherited from WlanWizardPage. + */ + HbWidget* initializePage(); + + /*! + * This method is overrides the default implementation from WlanWizardPage. + * It indicates whether the Next-button should be enabled or not. + * @return true, if mSsid edit field is not empty. + */ + virtual bool showPage(); + + /*! + * Validates the SSID selection and sets the configuration in + * the wlanwizard. + * @param removeFromStack output parameter that returns false. + * @return WlanWizardPageScanning page id. + */ + int nextId(bool &removeFromStack) const; + +public slots: + /*! + * Loads the document orientation information from occ_add_wlan_01_04.docml + * This is called each time phone orientation changes. + * @param orientation indicates whether the phone is in portrait or + * landscape mode. + */ + void loadDocml(Qt::Orientation orientation); + + /*! + * Executed when changes have been made to the mSsid field. + * @param text is not used at this point. + */ + void textChanged(const QString &text); + +protected: + /*! + * Reimplements QObject function that is invoked on any event. This + * function handles only a focus event to mSsid edit field. + * @param obj contains the object, where the event originates from. + * @param event contains the event id. + */ + bool eventFilter(QObject *obj, QEvent *event); + +private: + /*! + * Converts status identifier to plain-text QString format. + * @param status indicates SSID status code. + * @return status text. + */ + QString SsidStatusToErrorString(WlanWizardUtils::SsidStatus status) const; + +private: + /*! + * Pointer to the view. + */ + HbWidget *mWidget; + + /*! + * Pointer to the header label object. + */ + HbLabel *mLabel; + + /*! + * Pointer to the line edit object. + */ + HbLineEdit *mSsid; + + /*! + * Pointer to error label object. + */ + HbLabel *mLabelError; + + /*! + * Pointer to the document loader object. + */ + HbDocumentLoader *mLoader; +}; + +/*! @} */ + +#endif diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/inc/wlanwizardpagesummary.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/inc/wlanwizardpagesummary.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,77 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * WLAN Wizard Page: Summary + * + */ + +#ifndef WLANWIZARDPAGESUMMARY_H +#define WLANWIZARDPAGESUMMARY_H + +// System includes + +// User includes +#include "wlanwizardpageinternal.h" + +// Forward declarations +class HbLabel; +class WlanWizardPrivate; +class HbListWidget; + +// External data types + +// Constants + +/*! + @addtogroup group_wlan_wizard + @{ + */ + +class WlanWizardPageSummary : public WlanWizardPageInternal +{ +public: + explicit WlanWizardPageSummary(WlanWizardPrivate* parent); + virtual ~WlanWizardPageSummary(); + +public: // From WlanWizardPage + HbWidget* initializePage(); + int nextId(bool &removeFromStack) const; + +signals: + +public slots: + +protected: + +protected slots: + +private: + Q_DISABLE_COPY(WlanWizardPageSummary) + void loadDocml(); + QString networkModeText() const; + QString securityModeText() const; + void addDynamicItems(int &row); + void appendToList(int &row, const QString title, const QString value); + void appendToListPluginInfo(WlanWizardPlugin::Summary id, int &row); + +private slots: + +private: // data + //! Visualization of the page + HbListWidget *mListWidget; +}; + +/*! @} */ + +#endif // WLANWIZARDPAGESUMMARY_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/inc/wlanwizardplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/inc/wlanwizardplugin.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,123 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * WLAN Wizard Plugin API: Service required from the wizard plugin. + * + */ + +#ifndef WLANWIZARDPLUGIN_H +#define WLANWIZARDPLUGIN_H + +// System includes + +// User includes + +// Forward declarations + +// External data types + +// Constants + +/*! + @addtogroup group_wlan_wizard_api_internal + @{ + */ + +/*! + Interface that wizard plugin must implement or at least the plugin MUST + inherit this interface and use the default implementations. + */ +class WlanWizardPlugin +{ +public: + /*! + Enumerators for WLAN Wizard summary page. + */ + enum Summary { + //! EAP Outer Type + SummaryEapOuterType = 0, + //! EAP Inner Type + SummaryEapInnerType, + //! EAP Fast: Provisioning mode + SummaryEapFastProvisioningMode, + }; + +public: + /*! + This method is used to query summary items from the wizard plugins + that are eap and wps wizard. + + Both item and value are localized strings. + + @param [in] sum Summary id to be queried + @param [out] item The item string is returned here + @param [out] value the value of item is returned here. + + @return true if summary item is found, false otherwise. + */ + virtual bool summary( + WlanWizardPlugin::Summary sum, + QString &item, + QString &value) + { + Q_UNUSED(sum); + Q_UNUSED(item); + Q_UNUSED(value); + return false; + }; + + /*! + Stores wizard specific settings if any. + */ + virtual bool storeSettings() + { + return true; + }; + + /*! + Deletes wizard specific settings if any. + */ + virtual void deleteSettings() {}; + + /*! + Maps plugin specific error codes into a localized string. + + @param [in] errorCode Symbian error code. + + @return If mapping can be done a localized error string is returned + otherwise an empty string is returned. In case of empty string wlanwizard + will use default error code. + */ + virtual QString errorString(int errorCode) + { + Q_UNUSED(errorCode); + return QString(); + } +signals: + +public slots: + +protected: + +protected slots: + +private: + +private slots: + +private: // data +}; +/*! @} */ + +#endif /* WLANWIZARDPLUGIN_H */ diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/inc/wlanwizardsummaryviewitem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/inc/wlanwizardsummaryviewitem.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,63 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * Wlan Wizard Page: Summary: Custom list view item + */ + +#ifndef WLANWIZARDSUMMARYLISTVIEWITEM_H +#define WLANWIZARDSUMMARYLISTVIEWITEM_H + +// System includes +#include + +// User includes + +// Forward declarations + +// External data types + +// Constants + +/*! + @addtogroup group_wlan_wizard + @{ + */ + +class WlanWizardSummaryListViewItem : public HbListViewItem +{ +public: + explicit WlanWizardSummaryListViewItem(QGraphicsItem* parent = 0); + virtual ~WlanWizardSummaryListViewItem(); + + virtual HbAbstractViewItem* createItem(); + virtual void updateChildItems(); + +signals: + +public slots: + +protected: + +protected slots: + +private: + +private slots: + +private: // data +}; + +/*! @} */ + +#endif // WLANWIZARDSUMMARYLISTVIEWITEM_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/inc/wlanwizardutils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/inc/wlanwizardutils.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,88 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * WLAN Wizard Utilities + * + */ + +#ifndef WLANWIZARDUTILS_H +#define WLANWIZARDUTILS_H + +// System includes + +// User includes + +// Forward declarations + +// External data types + +// Constants + +/*! + @addtogroup group_wlan_wizard + @{ + */ + +class WlanWizardUtils +{ +public: + enum KeyStatus { + KeyStatusOk = 0, + KeyStatusIllegalCharacters, + KeyStatusWpaTooShort, + KeyStatusWpaTooLong, + KeyStatusWepInvalidLength, + }; + + enum SsidStatus { + SsidStatusOk = 0, + SsidStatusIllegalCharacters, + SsidStatusInvalidLength + }; + + static const int SsidMinLength = 1; + static const int SsidMaxLength = 32; + static const int WpaMinLength = 8; + static const int WpaMaxLength = 64; + static const int WepHex64BitMaxLength = 10; + static const int WepHex128BitMaxLength = 26; + static const int WepAscii64BitMaxLength = 5; + static const int WepAscii128BitMaxLength = 13; + +public: + static KeyStatus validateWepKey(const QString &key); + static KeyStatus validateWpaKey(const QString &key); + static KeyStatus isAscii(const QString &key); + static KeyStatus isHex(const QString &key); + static SsidStatus validateSsid(const QString &ssid); + +signals: + +public slots: + +protected: + +protected slots: + +private: + Q_DISABLE_COPY(WlanWizardUtils) + +private slots: + +private: // data +}; + +/*! @} */ + +#endif /* WLANWIZARDUTILS_H */ diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/resources/custom.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/resources/custom.css Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,11 @@ +HbDialog#dialog:portrait +{ +pref-width: var(hb-param-screen-width); +pref-height: var(hb-param-screen-height); +} + +HbDialog#dialog:landscape +{ +pref-width: var(hb-param-screen-width); +pref-height: var(hb-param-screen-height); +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/resources/hblistviewitem.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/resources/hblistviewitem.css Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,31 @@ + +HbListViewItem[layoutName="wlanwizardsummaryitem"]{ + layout:wlanwizardsummaryitem-portrait; +} + +HbListViewItem[layoutName="wlanwizardsummaryitem"]:landscape{ + layout:wlanwizardsummaryitem-landscape; +} + +HbListViewItem::text-1[layoutName="wlanwizardsummaryitem"]{ + text-height: var(hb-param-text-height-secondary); + font-variant: primary; + text-align: left; + size-policy-horizontal: preferred; + pref-width:-1; +} + +HbListViewItem::text-1[layoutName="wlanwizardsummaryitem"]:landscape{ + text-height: var(hb-param-text-height-secondary); + font-variant: primary; + text-align: left; + size-policy-horizontal: fixed; + fixed-width: expr((var(hb-param-screen-width) - var(hb-param-margin-gene-middle-horizontal)) / 2 - var(hb-param-margin-gene-screen) - var(hb-param-margin-gene-popup)); +} + +HbListViewItem::text-2[layoutName="wlanwizardsummaryitem"]{ + text-height: var(hb-param-text-height-tiny); + font-variant: secondary; + pref-width:-1; + text-align: left; +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/resources/hblistviewitem.widgetml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/resources/hblistviewitem.widgetml Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/resources/occ_add_wlan_01_04.docml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/resources/occ_add_wlan_01_04.docml Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + +
+ + + + + +
diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/resources/occ_add_wlan_02_03.docml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/resources/occ_add_wlan_02_03.docml Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,48 @@ + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + +
+ + + + + +
diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/resources/occ_add_wlan_05.docml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/resources/occ_add_wlan_05.docml Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,7 @@ + + + + + + + diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/resources/occ_add_wlan_06.docml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/resources/occ_add_wlan_06.docml Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + +
+ + + + + +
diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/resources/occ_add_wlan_error.docml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/resources/occ_add_wlan_error.docml Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/resources/occ_wlan_wizard_main.docml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/resources/occ_wlan_wizard_main.docml Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/resources/resource.qrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/resources/resource.qrc Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,17 @@ + + + occ_wlan_wizard_main.docml + occ_add_wlan_05.docml + occ_add_wlan_06.docml + occ_add_wlan_02_03.docml + occ_add_wlan_01_04.docml + occ_add_wlan_error.docml + + + custom.css + + + hblistviewitem.css + hblistviewitem.widgetml + + diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/rom/wlanwizard.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/rom/wlanwizard.iby Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* IBY file for WLAN Wizard +*/ + +#ifndef WLANWIZARD_IBY +#define WLANWIZARD_IBY + +#include +#include + +#ifdef __PROTOCOL_WLAN + +file=ABI_DIR\BUILD_DIR\wlanwizard.dll SHARED_LIB_DIR\wlanwizard.dll + +#endif // __PROTOCOL_WLAN + +#endif // WLANWIZARD_IBY diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/rom/wlanwizard_resources.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/rom/wlanwizard_resources.iby Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,30 @@ +/* +* 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 "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Wizard resource iby. +*/ + +#ifndef WLANWIZARD_RESOURCES_IBY +#define WLANWIZARD_RESOURCES_IBY + +#include +#include + +#ifdef __PROTOCOL_WLAN + +data=DATAZ_/QT_TRANSLATIONS_DIR/wlanwizard.qm QT_TRANSLATIONS_DIR/wlanwizard.qm + +#endif // __PROTOCOL_WLAN + +#endif // WLANWIZARD_RESOURCES_IBY diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/src/wlanwizard.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/src/wlanwizard.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,174 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * WLAN Wizard: API. + * + */ + +// System includes + +// User includes +#include "wlanwizard.h" +#include "wlanwizard_p.h" + +/*! + \class WlanWizard + \brief Interface of WLAN Wizard. + + Example usage: + \code + MyClass::createWizard() { + mWizard = new WlanWizard(mainWindow()); + connect( + mWizard, SIGNAL(finished(int, bool)), + this, SLOT(finished(int, bool))); + connect(mWizard, SIGNAL(cancelled()), this, SLOT(cancelled())); + + // If client know the parameters for WLAN Access Point call following + mWizard->setParameters( + "MySSid", + CmManagerShim::Infra, + CmManagerShim::WlanSecModeWpa, + true, // WPA-PSK + false, // Non-Hidden + false ); // Non-Wifi Protected Setup + + // and execute wizard + mWizard->show(); + } + + void MyClass::finished(int iapId, bool connected) { + // User has successfully created WLAN IAP with the wizard. + + // if connected equals to true, wizard has established connection to it + // now the client needs to connect also to given IAP Id to keep the + // connection open. + // see WlanQtUtils or RConnection. + + // Delete wizard. Do not delete in this call stack since this call has + // been done from the context of the wizards call stack. + mWizard->deleteLater(); + mWizard = NULL; + } + + void MyClass::cancelled() { + // wizard operation was cancelled by user, iap has not been created + // and WLAN connection is not established + + // Delete wizard. Do not delete in this call stack since this call has + // been done from the context of the wizards call stack. + mWizard->deleteLater(); + mWizard = NULL; + } + \endcode + + Implements wizard based on wizard pattern. + */ + +/*! + \fn void WlanWizard::cancelled() + This signal is emitted when the execution of wizard has been cancelled. + */ + +/*! + \fn void WlanWizard::finished(int iapId, bool connected) + This signal is emitted when the execution of wizard has been finished + succesfully. + + @param iapId IAP ID that has been created. + @param connected true if the connection to wlan has been established. + */ + +// External function prototypes + +// Local constants + + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +/*! + Constructor of WLAN Wizard. + + @param [in] mainWindow HbMainWindow to where the wizard is going to be executed. + */ +WlanWizard::WlanWizard(HbMainWindow *mainWindow) : + d_ptr(new WlanWizardPrivate(this, mainWindow)) +{ +} + +/*! + Destructor. + */ +WlanWizard::~WlanWizard() +{ + delete d_ptr; +} + +/*! + Client can set the known WLAN Access Point configurations to speed up wizard + processing and make it easier for end user. + + Values for network mode (CmManagerShim::WlanConnectionMode) and security mode + (CmManagerShim::WlanSecMode). + + Supported configuration sets: + - Open: \a ssid \a networkMode \a securityMode + - WEP: \a ssid \a networkMode \a securityMode + - WPA (2) with EAP: \a ssid \a networkMode \a securityMode \a usePsk (false) + - WPA (2) with PSK: \a ssid \a networkMode \a securityMode \a usePsk (true) + - 802.1x: \a ssid \a networkMode \a securityMode + + Hidden WLAN: + \a hidden can be used with \a networkMode CmManagerShim::Infra + + Wifi Protected Setup + \a wps can be used with Open, WEP and WPA (2) with PSK. + + @param [in] ssid The name of WLAN network (ssid), max length 32 characters. + @param [in] networkMode Network mode of known access point + @param [in] securityMode Security mode of known access point + @param [in] usePsk used only with WPA or WPA2 \a securityMode + @param [in] hidden if true WLAN is hidden. + @param [in] wps is Wifi Protected Setup supported? + */ +void WlanWizard::setParameters( + const QString &ssid, + int networkMode, + int securityMode, + bool usePsk, + bool hidden, + bool wps) +{ + d_ptr->setParameters(ssid, networkMode, securityMode, usePsk, hidden, wps); +} + +/*! + Executes the wizard and shows the first page. + + @note it is not allowed to call this method twice with same instance. + + Possible signals: + - finished(int, bool): called after wizard has successfully completed + - cancelled(): user has cancelled the wizard operations. + + First page for the wizard is SSID (WLAN network name) query or if + setParameters() has been called the first page is determined based on the + given configuration combination. + */ +void WlanWizard::show() +{ + d_ptr->show(); +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/src/wlanwizard_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/src/wlanwizard_p.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,1066 @@ +/* +* 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 "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Wizard: Private implementation. +*/ + +// System includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// User includes +#ifdef WLAN_WIZARD_RND_EAP +#include "eapwizard.h" +#endif + +#ifdef WLAN_WIZARD_RND_WPS +#include "wpswizard.h" +#endif +#include "wlanqtutils.h" +#include "wlanqtutilsap.h" +#include "wlanwizardplugin.h" +#include "wlanwizard.h" +#include "wlanwizard_p.h" +#include "wlanwizardutils.h" +#include "wlanwizardpagekeyquery.h" +#include "wlanwizardpagesummary.h" +#include "wlanwizardpageprocessingsettings.h" +#include "wlanwizardpagegenericerror.h" + +#ifdef WLAN_WIZARD_RND +#include "wlanwizardpagessid.h" +#include "wlanwizardpagenetworkmode.h" +#include "wlanwizardpagescanning.h" +#include "wlanwizardpagesecuritymode.h" +#endif + +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wlanwizard_pTraces.h" +#endif + +/*! + \class WlanWizardPrivate + \brief Private implementation of WlanWizard. Implements the interface + WlanWizardHelper to the wizard plugins. + */ + +// External function prototypes + +// Local constants + +/*! + \var PageTimeout Timeout for timer protected pages. 1.5sec + */ + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +/*! + Constructor of private implementation. + + @param [in] wizard Pointer to the API class. + @param [in] mainWindow pointer to mainwindow. + */ +WlanWizardPrivate::WlanWizardPrivate( + WlanWizard* wizard, + HbMainWindow *mainWindow) : + QObject(wizard), + q_ptr(wizard), + mMainWindow(mainWindow), + mPageTimer(new QTimer(this)), + mTitle(NULL), + mActionNext(NULL), + mActionPrevious(NULL), + mActionFinish(NULL), + mActionCancel(NULL), + mStackedWidget(NULL), + mDialog(NULL), + mTranslator(new HbTranslator("wlanwizard")), + mWlanQtUtils(new WlanQtUtils()), + mDocLoader(new HbDocumentLoader(mainWindow)), + mEapWizard(NULL), + mWpsWizard(NULL), + mFirstPageId(WlanWizardPageInternal::PageNone), + mPageFinished(false), + mClosed(false) +{ + OstTrace1( TRACE_BORDER, WLANWIZARDPRIVATE_WLANWIZARDPRIVATE, + "WlanWizardPrivate::WlanWizardPrivate;this=%x", + this ); + + // Set initial values for configurations + setConfiguration(ConfIapId, WlanQtUtils::IapIdNone); + setConfiguration(ConfConnected, false); + setConfiguration(ConfHiddenWlan, false); + setConfiguration(ConfProcessSettings, false); + setConfiguration(ConfIctStatus, false); + + // Initialize timer for timer protected pages + mPageTimer->setSingleShot(true); + + // Load the wizard frame (title, content, actions) from docml + loadDocml(); + + // Creates the control object of the wlan wizard pages. + createPages(); + + // First page is SSID query, unless client sets configurations via + // setParameters(), which decides the first page.. + mFirstPageId = WlanWizardPageInternal::PageSsid; + + OstTraceExt2( TRACE_BORDER, WLANWIZARDPRIVATE_WLANWIZARDPRIVATE_DONE, + "WlanWizardPrivate::WlanWizardPrivate - done;" + "this=%x;mFirstPageId=%{PageIds}", + ( unsigned )this, mFirstPageId ); +} + +/*! + Destructor. + */ +WlanWizardPrivate::~WlanWizardPrivate() +{ + OstTrace1( TRACE_BORDER, WLANWIZARDPRIVATE_DWLANWIZARDPRIVATE, + "WlanWizardPrivate::~WlanWizardPrivate;this=%x", + this ); + + // Remove wizard pages from stackedwidgets, since stackedwidget owns the + // objects and all pages are deleted below. + while (mStackedWidget->count()) { + mStackedWidget->removeAt(0); + } + + // Delete UI instances (HbWidget) of pages + QHashIterator i(mPageMapper); + while (i.hasNext()) { + i.next(); + delete i.key(); + } + mPageMapper.clear(); + + // WlanWizardPage objects are automatically deleted since this is the + // parent of the objects. + mPages.clear(); + +#ifdef WLAN_WIZARD_RND_EAP + delete mEapWizard; +#endif +#ifdef WLAN_WIZARD_RND_WPS + delete mWpsWizard; +#endif + // timer is cancelled/deleted automatically when the parent (this) is deleted + + // TODO: See TSW Error: MTAA-854DK8 and loadDocml() + HbStyleLoader::unregisterFilePath(":/css/custom.css"); + + OstTrace1( TRACE_BORDER, WLANWIZARDPRIVATE_DWLANWIZARDPRIVATE_DONE, + "WlanWizardPrivate::~WlanWizardPrivate-Done;this=%x", + this ); +} + +/*! + See WlanWizard::setParameters(). + */ +void WlanWizardPrivate::setParameters( + const QString &ssid, + int networkMode, + int securityMode, + bool usePsk, + bool hidden, + bool wps) +{ + OstTrace1( TRACE_BORDER, WLANWIZARDPRIVATE_SETPARAMETERS, + "WlanWizardPrivate::setParameters;this=%x", + this ); + + mFirstPageId = getNextPageId( + ssid, networkMode, securityMode, usePsk, hidden, wps); + + OstTrace1( TRACE_BORDER, WLANWIZARDPRIVATE_SETPARAMETERS_DONE, + "WlanWizardPrivate::setParameters - Done;this=%x", + this ); +} + +/*! + See WlanWizard::show(). + */ +void WlanWizardPrivate::show() +{ + OstTraceExt2( TRACE_BORDER, WLANWIZARDPRIVATE_SHOW, + "WlanWizardPrivate::show;this=%x;mFirstPageId=%{PageIds}", + ( unsigned )this, mFirstPageId ); + + Q_ASSERT(mClosed == false); + showPage(mFirstPageId, false); + mDialog->show(); + + OstTrace1( TRACE_BORDER, WLANWIZARDPRIVATE_SHOW_DONE, + "WlanWizardPrivate::show - Done;this=%x;", + (unsigned)this ); +} + +/*! + See WlanWizard::setParameters() for descriptions of parameters. + + Based on the provided parameters next page id is returned. + + @return next page id based on provided configurations. + */ +int WlanWizardPrivate::getNextPageId( + const QString &ssid, + int networkMode, + int securityMode, + bool usePsk, + bool hidden, + bool wps) +{ + setConfiguration(ConfProcessSettings, true); + setConfiguration(ConfSsid, ssid); + setConfiguration(ConfNetworkMode, networkMode); + setConfiguration(ConfSecurityMode, securityMode); + setConfiguration(ConfUsePsk, usePsk); + setConfiguration(ConfHiddenWlan, hidden); + + OstTrace1( TRACE_NORMAL, WLANWIZARDPRIVATE_GETNEXTPAGEID, + "WlanWizardPrivate::getNextPageId;wps=%u", + wps ); + + return nextPageId(wps); +} + +/*! + Utility method for WLAN Wizard pages to query the wlanqtutils class. + + @return a valid pointer to WlanQtUtils class. + */ +WlanQtUtils* WlanWizardPrivate::wlanQtUtils() const +{ + Q_ASSERT(mWlanQtUtils); + return mWlanQtUtils.data(); +} + +/*! + Utility method for WLAN Wizard pages to query active wizard plugin object + + @return NULL in case plugin is not active. + */ +WlanWizardPlugin* WlanWizardPrivate::wlanWizardPlugin() const +{ + WlanWizardPlugin* plugin = NULL; + + if (isEapEnabled()) { +#ifdef WLAN_WIZARD_RND_EAP + plugin = mEapWizard; + Q_ASSERT(plugin); +#endif + } + + OstTrace1( TRACE_NORMAL, WLANWIZARDPRIVATE_WLANWIZARDPLUGIN, + "WlanWizardPrivate::wlanWizardPlugin;plugin=%x", + plugin ); + + return plugin; +} + +/*! + Utility method for WLAN Wizard pages to query if EAP mode is active at the + moment + + @return true in case EAP is currently activated. + */ +bool WlanWizardPrivate::isEapEnabled() const +{ + bool ret = false; + int secMode = configuration(ConfSecurityMode).toInt(); + + if (((secMode == CMManagerShim::WlanSecModeWpa || + secMode == CMManagerShim::WlanSecModeWpa2) && + !configuration(ConfUsePsk).toBool()) || + secMode == CMManagerShim::WlanSecMode802_1x) { + ret = true; + } + + OstTrace1( TRACE_NORMAL, WLANWIZARDPRIVATE_ISEAPENABLED, + "WlanWizardPrivate::isEapEnabled;ret=%u", + ret ); + + return ret; +} + +/*! + Creates new iap or updates existing iap. + + @return false in case IAP creation/update failed. + */ +bool WlanWizardPrivate::handleIap() +{ + OstTrace0( TRACE_FLOW, WLANWIZARDPRIVATE_HANDLEIAP, + "WlanWizardPrivate::handleIap" ); + + bool ret = true; + bool usePsk = true; + int securityMode = configuration(ConfSecurityMode).toInt(); + WlanQtUtilsAp wlanAp; + + // Set configuration + wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, configuration(ConfSsid)); + wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, + configuration(ConfNetworkMode)); + wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, securityMode ); + wlanAp.setValue(WlanQtUtilsAp::ConfIdHidden, configuration(ConfHiddenWlan)); + + switch (securityMode) { + case CMManagerShim::WlanSecModeWep: + wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey1, configuration(ConfKeyWep1)); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey2, configuration(ConfKeyWep2)); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey3, configuration(ConfKeyWep3)); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey4, configuration(ConfKeyWep4)); + wlanAp.setValue( + WlanQtUtilsAp::ConfIdWepDefaultIndex, + configuration(ConfKeyWepDefault)); + break; + + case CMManagerShim::WlanSecModeWpa: + case CMManagerShim::WlanSecModeWpa2: + usePsk = configuration(ConfUsePsk).toBool(); + wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, usePsk); + if (usePsk){ + wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPsk, configuration(ConfKeyWpa)); + } + break; + + default: + Q_ASSERT(securityMode == CMManagerShim::WlanSecModeOpen || + securityMode == CMManagerShim::WlanSecMode802_1x); + // No WLAN Specific configuration + break; + } + + // Create IAP if does not exists or update the existing IAP + int referenceId = configuration(ConfIapId).toInt(); + if (referenceId == WlanQtUtils::IapIdNone) { + OstTrace0( TRACE_FLOW, WLANWIZARDPRIVATE_HANDLEIAP_CREATE, + "WlanWizardPrivate::handleIap: Create IAP" ); + + referenceId = mWlanQtUtils->createIap(&wlanAp); + setConfiguration(ConfIapId, referenceId); + + if (referenceId == WlanQtUtils::IapIdNone) { + ret = false; + } + } else { + OstTrace0( TRACE_FLOW, WLANWIZARDPRIVATE_HANDLEIAP_UPDATE, + "WlanWizardPrivate::handleIap: Update IAP" ); + + ret = mWlanQtUtils->updateIap(referenceId, &wlanAp); + } + + if (ret) { + // Store Wizard plugin specific settings here. + WlanWizardPlugin* plugin = wlanWizardPlugin(); + if (plugin) { + OstTrace0( TRACE_FLOW, WLANWIZARDPRIVATE_HANDLEIAP_PLUGIN, + "WlanWizardPrivate::handleIap: Plugin" ); + // Plugin gets the IAP ID from configuration + ret = plugin->storeSettings(); + } + } + + OstTrace1( TRACE_FLOW, WLANWIZARDPRIVATE_HANDLEIAP_DONE, + "WlanWizardPrivate::handleIap: Done;ret=%d", + ret ); + + return ret; +} + +/*! + See WlanWizardHelper::configuration(). + */ +QVariant WlanWizardPrivate::configuration(ConfigurationId confId) const +{ + Q_ASSERT(mConfigurations.contains(confId)); + +#ifdef OST_TRACE_COMPILER_IN_USE + QString tmp; + QDebug tmpStream(&tmp); + tmpStream << mConfigurations[confId]; + TPtrC16 string( tmp.utf16(), tmp.length() ); + + OstTraceExt2( TRACE_NORMAL, WLANWIZARDPRIVATE_CONFIGURATIONS, + "WlanWizardPrivate::configuration;confId=%{ConfigurationId};string=%S", + (uint)confId, string ); +#endif + + return mConfigurations[confId]; +} + +/*! + See WlanWizardHelper::setConfiguration(). + */ +void WlanWizardPrivate::setConfiguration( + ConfigurationId confId, + const QVariant &value) +{ +#ifdef OST_TRACE_COMPILER_IN_USE + QString tmp; + QDebug tmpStream(&tmp); + tmpStream << value; + TPtrC16 string( tmp.utf16(), tmp.length() ); + + OstTraceExt2( TRACE_NORMAL, WLANWIZARDPRIVATE_SETCONFIGURATION, + "WlanWizardPrivate::setConfiguration;" + "confId=%{ConfigurationId};string=%S", + (uint)confId, string ); +#endif + + mConfigurations[confId] = value; +} + +/*! + See WlanWizardHelper::enableNextButton(). + */ +void WlanWizardPrivate::enableNextButton(bool enable) +{ + OstTraceExt2( TRACE_FLOW, WLANWIZARDPRIVATE_ENABLENEXTBUTTON, + "WlanWizardPrivate::enableNextButton;this=%x;enable=%x", + (unsigned)this, (uint)enable ); + mActionNext->setEnabled(enable); +} + +/*! + See WlanWizardHelper::enablePrevButton(). + */ +void WlanWizardPrivate::enablePrevButton(bool enable) +{ + OstTraceExt2( TRACE_FLOW, WLANWIZARDPRIVATE_ENABLEPREVBUTTON, + "WlanWizardPrivate::enablePrevButton;this=%x;enable=%x", + (unsigned)this, (uint)(enable) ); + + mActionPrevious->setEnabled(enable); +} + +/*! + See WlanWizardHelper::addPage(). + */ +void WlanWizardPrivate::addPage(int pageId, WlanWizardPage *page) +{ + OstTraceExt3( TRACE_FLOW, WLANWIZARDPRIVATE_ADDPAGE, + "WlanWizardPrivate::addPage;this=%x;pageId=%{PageIds};page=%x", + (unsigned)this, pageId, (uint)(page) ); + + Q_ASSERT(!mPages.contains(pageId)); + mPages[pageId] = page; +} + +/*! + See WlanWizardHelper::nextPage(). + */ +void WlanWizardPrivate::nextPage() +{ + OstTrace1( TRACE_FLOW, WLANWIZARDPRIVATE_NEXTPAGE, + "WlanWizardPrivate::nextPage;this=%x", + this ); + + mPageFinished = true; + toNextPage(); +} + +/*! + See WlanWizardHelper::mainWindow(). + */ +HbMainWindow* WlanWizardPrivate::mainWindow() const +{ + return mMainWindow; +} + +/*! + See WlanWizardHelper::isCurrentPage(). + */ +bool WlanWizardPrivate::isCurrentPage(const HbWidget *page) const +{ + bool ret = false; + if (mStackedWidget->currentWidget() == page) { + ret = true; + } + + OstTraceExt2( TRACE_FLOW, WLANWIZARDPRIVATE_ISCURRENTPAGE, + "WlanWizardPrivate::isCurrentPage;page=%x;ret=%d", + (uint)page, ret); + + return ret; +} + +/*! + See WlanWizardHelper::nextPageId() + */ +int WlanWizardPrivate::nextPageId(bool useWps) +{ + int ret; + int secMode = configuration(WlanWizardHelper::ConfSecurityMode).toInt(); + switch (secMode) { + case CMManagerShim::WlanSecModeWep: + ret = WlanWizardPageInternal::PageKeyQuery; + break; + + case CMManagerShim::WlanSecModeWpa: + case CMManagerShim::WlanSecModeWpa2: + if (configuration(WlanWizardHelper::ConfUsePsk).toBool()) { + ret = WlanWizardPageInternal::PageKeyQuery; + } else { +#ifdef WLAN_WIZARD_RND_EAP + ret = WlanWizardPage::PageEapStart; +#else + ret = WlanWizardPageInternal::PageProcessSettings; + setConfiguration(ConfSecurityMode, CMManagerShim::WlanSecModeOpen); +#endif + + } + break; + + case CMManagerShim::WlanSecMode802_1x: +#ifdef WLAN_WIZARD_RND_EAP + ret = WlanWizardPage::PageEapStart; +#else + ret = WlanWizardPageInternal::PageProcessSettings; + setConfiguration(ConfSecurityMode, CMManagerShim::WlanSecModeOpen); +#endif + break; + + case CMManagerShim::WlanSecModeWapi: + case CMManagerShim::WlanSecModeOpen: + default: + Q_ASSERT( + secMode == CMManagerShim::WlanSecModeOpen || + secMode == CMManagerShim::WlanSecModeWapi); + + setConfiguration(ConfSecurityMode, CMManagerShim::WlanSecModeOpen); + ret = WlanWizardPageInternal::PageProcessSettings; + break; + } + + Q_UNUSED(useWps); +#ifdef WLAN_WIZARD_RND_WPS + // TODO: WPS: and switch case above to else branch + if (useWps) { + ret = WlanWizardPage::PageWpsStart; + } +#endif + + OstTraceExt3( TRACE_NORMAL, WLANWIZARDPRIVATE_NEXTPAGEID, + "WlanWizardPrivate::nextPageId;this=%x;useWps=%x;ret=%{PageIds}", + ( unsigned )this, ( TUint )( useWps ), ret ); + + return ret; +} + +/*! + Called when Cancel toolbar button is pressed. In case IAP has been created + it will be disconnected and the IAP settings are deleted and finally the + wizard is closed. + + Indicates also to the current wizard page that cancel has been pressed. + */ +void WlanWizardPrivate::cancelTriggered() +{ + OstTrace1( TRACE_BORDER, WLANWIZARDPRIVATE_CANCELTRIGGERED, + "WlanWizardPrivate::cancelTriggered;this=%x", + this ); + + // Disconnect receiving more signals from any actions + disconnectActions(); + + mPageTimer->stop(); + + HbWidget *widget = qobject_cast(mStackedWidget->currentWidget()); + Q_ASSERT(widget); + mPageMapper[widget]->cancelTriggered(); + + int referenceId = configuration(ConfIapId).toInt(); + if (referenceId != WlanQtUtils::IapIdNone) { + // call disconnect even if + // - connection is not open + // - connection establishment is ongoing + mWlanQtUtils->disconnectIap(referenceId); + + // if IAP deletion fails, there is nothing we can do with it + mWlanQtUtils->deleteIap(referenceId); + WlanWizardPlugin* plugin = wlanWizardPlugin(); + if (plugin) { + // if deletion of plugin specific configuration fails we are not + // able to do anything + plugin->deleteSettings(); + } + setConfiguration(ConfIapId, WlanQtUtils::IapIdNone); + } + closeViews(); + Q_ASSERT(q_ptr); + + OstTrace0( TRACE_BORDER, WLANWIZARDPRIVATE_CANCELTRIGGERED_EMIT, + "WlanWizardPrivate::cancelTriggered - emit cancelled()" ); + + emit q_ptr->cancelled(); + + OstTrace1( TRACE_BORDER, WLANWIZARDPRIVATE_CANCELTRIGGERED_DONE, + "WlanWizardPrivate::cancelTriggered - Done;this=%x", this ); +} + +/*! + Called when Previous toolbar button is pressed. Shows the previous wizard + page in stacked widget and indicates wizard page that previous has been + pressed. + */ +void WlanWizardPrivate::previousTriggered() +{ + OstTrace1( TRACE_BORDER, WLANWIZARDPRIVATE_PREVIOUSTRIGGERED, + "WlanWizardPrivate::previousTriggered;this=%x", + this ); + + mPageTimer->stop(); + + int index = mStackedWidget->currentIndex(); + HbWidget *widget = qobject_cast(mStackedWidget->currentWidget()); + Q_ASSERT(widget); + int back = mPageMapper[widget]->previousTriggered(); + + // check that at least one page is left in the stack + Q_ASSERT( back < mStackedWidget->count()); + + // When a widget which is last in the stack is removed the currentindex + // is automatically updated. + for (int i = 0; i < back; ++i) { + mStackedWidget->removeAt(index - i); + } + + widget = qobject_cast (mStackedWidget->currentWidget()); + Q_ASSERT(widget); + WlanWizardPage* page = mPageMapper[widget]; + Q_ASSERT(page); + // In error case if page (value) is not found default contructed key is + // returned, in this case default value for int is 0 which means PageNone. + updateFrame(mPages.key(page)); + enableNextButton(page->showPage()); + + OstTrace1( TRACE_BORDER, WLANWIZARDPRIVATE_PREVIOUSTRIGGERED_DONE, + "WlanWizardPrivate::previousTriggered - Done;this=%x", + this ); +} + +/*! + Next toolbar button has been pressed. Wizard framework asks from the current + page what should be the next page id and shows it. + */ +void WlanWizardPrivate::nextTriggered() +{ + OstTrace1( TRACE_BORDER, WLANWIZARDPRIVATE_NEXTTRIGGERED, + "WlanWizardPrivate::nextTriggered;this=%x", + this ); + + mPageTimer->stop(); + + HbWidget *widget = qobject_cast(mStackedWidget->currentWidget()); + Q_ASSERT(widget); + + bool removeFromStack; + int pageId = mPageMapper[widget]->nextId(removeFromStack); + showPage(pageId, removeFromStack); + + OstTrace1( TRACE_BORDER, WLANWIZARDPRIVATE_NEXTTRIGGERED_DONE, + "WlanWizardPrivate::nextTriggered - Done;this=%x", + this ); +} + +/*! + Finish button has been pressed. Closes the wizard and sends finished() + signal to the client. + */ +void WlanWizardPrivate::finishTriggered() +{ + OstTrace1( TRACE_BORDER, WLANWIZARDPRIVATE_FINISHTRIGGERED, + "WlanWizardPrivate::finishTriggered;this=%x", + this ); + + // Disconnect receiving more signals from any actions + disconnectActions(); + + mPageTimer->stop(); + closeViews(); + + Q_ASSERT(q_ptr); + emit q_ptr->finished( + configuration(ConfIapId).toInt(), + configuration(ConfConnected).toBool()); + + OstTrace1( TRACE_BORDER, WLANWIZARDPRIVATE_FINISHTRIGGERED_DONE, + "WlanWizardPrivate::finishTriggered - Done;this=%x", + this ); +} + +/*! + In case wizard page is using timer protection for the page, this is the + slot to handle the callback from the timer. + */ +void WlanWizardPrivate::onTimeOut() +{ + OstTrace1( TRACE_BORDER, WLANWIZARDPRIVATE_ONTIMEOUT, + "WlanWizardPrivate::onTimeOut;this=%x", + this ); + + toNextPage(); + + OstTrace1( TRACE_BORDER, WLANWIZARDPRIVATE_ONTIMEOUT_DONE, + "WlanWizardPrivate::onTimeOut - Done;this=%x", + this ); +} + +/*! + Slot to start wizard page operation asynchronous. Starts also the timer + to protect the wizard page. + */ +void WlanWizardPrivate::startPageOperation() +{ + // Process this if wizard has not been closed + if (mClosed == false) { + OstTrace1( TRACE_BORDER, WLANWIZARDPRIVATE_STARTPAGEOPERATION, + "WlanWizardPrivate::startPageOperation;this=%x", + this ); + + HbWidget *widget = + qobject_cast(mStackedWidget->currentWidget()); + Q_ASSERT(widget); + mPageFinished = false; + mPageTimer->start(PageTimeout); + mPageMapper[widget]->startOperation(); + + OstTrace1( TRACE_BORDER, WLANWIZARDPRIVATE_STARTPAGEOPERATION_DONE, + "WlanWizardPrivate::startPageOperation - DONE;this=%x", + this ); + } +} + +/*! + In case the wizard page uses timer protection this method determines when + the next page is shown. + */ +void WlanWizardPrivate::toNextPage() +{ + if (mPageFinished && !(mPageTimer->isActive())) { + OstTrace1( TRACE_FLOW, WLANWIZARDPRIVATE_TONEXTPAGE, + "WlanWizardPrivate::toNextPage;this=%x", + this ); + + // process this asynchronous. Main purpose is to release the current + // call stack and process the page change using new call stack + QMetaObject::invokeMethod(this, "nextTriggered", Qt::QueuedConnection); + } +} + +/*! + Show requested page and removes the current wizard page from the stack if + required. This method updates the title and toolbar accordingly. + + See WlanWizardPage::nextId() + + @param [in] pageId Wizard Page ID to be shown + @param [in] removeFromStack if true the current wizard page is removed from + the stackedwidget. + */ +void WlanWizardPrivate::showPage(int pageId, bool removeFromStack) +{ + OstTraceExt3( TRACE_FLOW, WLANWIZARDPRIVATE_SHOWPAGE, + "WlanWizardPrivate::showPage;this=%x;" + "pageId=%{PageIds};removeFromStack=%x", + ( unsigned )this, pageId, ( TUint )( removeFromStack ) ); + + // PageNone is returned by wizard pages when some validation of page content + // has not passed and the page does not want to process wizard to next page + if (pageId == WlanWizardPage::PageNone) { + return; + } + + // PageProcessSettings is shown only when WLAN AP is found in scanning + // 1/ when client calls setParameters() + // 2/ scanning page has found match with given SSID + if (pageId == WlanWizardPage::PageProcessSettings) { + if (configuration(ConfProcessSettings).toBool() == false) { + if (handleIap()){ + pageId = WlanWizardPageInternal::PageSummary; + } else { + pageId = WlanWizardPage::PageGenericError; + setConfiguration( + ConfGenericErrorString, + hbTrId("txt_occ_dialog_unable_to_save_settings_please_ret")); + } + OstTraceExt2( TRACE_FLOW, WLANWIZARDPRIVATE_SHOWPAGE_UPDATE, + "WlanWizardPrivate::showPage - change page;this=%x;" + "pageId=%{PageIds}", + ( unsigned )this, pageId); + } + } + +#ifdef WLAN_WIZARD_RND_EAP + if (pageId == WlanWizardPage::PageEapStart) { + if (!mEapWizard) { + // EAP Wizard will add wizard pages at construction phase using + // WlanWizardHelper::addPage() + mEapWizard = new EapWizard(this); + } + } +#endif +#ifdef WLAN_WIZARD_RND_WPS + if (pageId == WlanWizardPage::PageWpsStart) { + if (!mWpsWizard) { + // WPS Wizard will add wizard pages at construction phase using + // WlanWizardHelper::addPage() + mWpsWizard = new WpsWizard(this); + } + } +#endif + + // Create visualization of next page and store it to mappers + WlanWizardPage* page = mPages[pageId]; + Q_ASSERT(page); + HbWidget* widget = page->initializePage(); + Q_ASSERT(widget); + mPageMapper[widget] = page; + + // index calculation has to be happened before adding new widget into + // the stacked widget. Since the internal implementation of stackedwidget + // sets the first widget in the stack to current widget.. + // and when there are not any widgets in the stack the current index is + // -1. Valid index starts from 0. + int index = mStackedWidget->currentIndex(); + + if (removeFromStack) { + // widget is removed from the stacked widget, not deleted + mStackedWidget->removeAt(index); + } else { + index++; + } + mStackedWidget->addWidget(widget); + mStackedWidget->setCurrentIndex(index); + updateFrame(pageId); + enableNextButton(page->showPage()); + + // If wizard page needs to start some control operation trigger it + // asyncronously so that the UI gets more priority to get painted correctly + // before any operation takes place in wizard page. This is important for + // timer protected pages. Makes wizard to work smother from UI perspective + if (page->requiresStartOperation()) { + OstTrace0( TRACE_FLOW, WLANWIZARDPRIVATE_SHOWPAGE_INVOKE, + "WlanWizardPrivate::showPage - Invoke startOperation" ); + + QMetaObject::invokeMethod(this, "startPageOperation", Qt::QueuedConnection); + } +} + +/*! + Creates all control objects of WLAN wizard pages which are inherited from + WlanWizardPage and adds those into a internal database. + */ +void WlanWizardPrivate::createPages() +{ + OstTrace0( TRACE_NORMAL, WLANWIZARDPRIVATE_CREATEPAGES, + "WlanWizardPrivate::createPages" ); + + addPage(WlanWizardPageInternal::PageKeyQuery, + new WlanWizardPageKeyQuery(this)); + + addPage(WlanWizardPageInternal::PageProcessSettings, + new WlanWizardPageProcessingSettings(this)); + + addPage(WlanWizardPageInternal::PageSummary, + new WlanWizardPageSummary(this)); + + addPage(WlanWizardPageInternal::PageGenericError, + new WlanWizardPageGenericError(this)); + +#ifdef WLAN_WIZARD_RND + addPage(WlanWizardPageInternal::PageSsid, new WlanWizardPageSsid(this)); + + addPage(WlanWizardPageInternal::PageScanning, + new WlanWizardPageScanning(this)); + + addPage(WlanWizardPageInternal::PageNetworkMode, + new WlanWizardPageNetworkMode(this)); + + addPage(WlanWizardPageInternal::PageNetworkSecurity, + new WlanWizardPageSecurityMode(this)); +#endif +} + +/*! + Called when wizard is closed + - cancelled by the user + - finished by the user + */ +void WlanWizardPrivate::closeViews() +{ + mClosed = true; + mDialog->close(); +} + +/*! + This method takes care of the title of wizard and toolbutton. Correct items + are selected based on the \a pageId and the amount of objects in the stacked + widget. + + @param [in] pageId Wizard Page Id + */ +void WlanWizardPrivate::updateFrame(int pageId) +{ + int currentIndex = mStackedWidget->currentIndex(); + + OstTraceExt3( TRACE_FLOW, WLANWIZARDPRIVATE_UPDATEFRAME, + "WlanWizardPrivate::updateFrame;this=%x;pageId=%{PageIds};currentIndex=%d", + (unsigned)this, pageId, (uint)(currentIndex) ); + + // For last page (summary) show Finish instead of Next button + if (pageId == WlanWizardPageInternal::PageSummary) { + mTitle->setPlainText(hbTrId("txt_occ_title_wlan_setup_wizard_summary")); + mActionFinish->setVisible(true); + mActionNext->setVisible(false); + mActionPrevious->setVisible(false); + } else { + // Index starts from zero, wizard page numbering starts from one. + mTitle->setPlainText( + hbTrId("txt_occ_title_wlan_setup_wizard_step_l1").arg( + currentIndex + 1)); + mActionFinish->setVisible(false); + mActionNext->setVisible(true); + + // If first page is shown then Previous button is disabled + if (currentIndex < 1) { + mActionPrevious->setVisible(false); + } else { + mActionPrevious->setVisible(true); + if (pageId == WlanWizardPage::PageProcessSettings) { + mActionPrevious->setEnabled(false); + } else { + mActionPrevious->setEnabled(true); + } + } + } +} + +/*! + Loads widgets and objects from the docml file. + */ +void WlanWizardPrivate::loadDocml() +{ + bool ok = true; + + mDocLoader->load(":/docml/occ_wlan_wizard_main.docml", &ok); + Q_ASSERT(ok); + + mDialog.reset( qobject_cast (mDocLoader->findWidget("dialog")) ); + Q_ASSERT(mDialog != NULL); + + mTitle = qobject_cast (mDocLoader->findWidget("title")); + Q_ASSERT(mTitle != NULL); + + mStackedWidget = + qobject_cast (mDocLoader->findWidget("stackedWidget")); + Q_ASSERT(mStackedWidget != NULL); + + mActionNext = qobject_cast (mDocLoader->findObject("actionNext")); + Q_ASSERT(mActionNext != NULL); + + mActionPrevious = + qobject_cast (mDocLoader->findObject("actionPrevious")); + Q_ASSERT(mActionPrevious != NULL); + + mActionFinish = + qobject_cast (mDocLoader->findObject("actionFinish")); + Q_ASSERT(mActionFinish != NULL); + + mActionCancel = + qobject_cast (mDocLoader->findObject("actionCancel")); + Q_ASSERT(mActionCancel != NULL); + + // Actions are added from left to right to the toolbar of dialog + mDialog->addAction(mActionPrevious); + mDialog->addAction(mActionCancel); + mDialog->addAction(mActionNext); + mDialog->addAction(mActionFinish); + + // TODO: workaround to prevent action to close the dialog + disconnect(mActionPrevious, SIGNAL(triggered()), mDialog.data(), SLOT(close())); + disconnect(mActionCancel, SIGNAL(triggered()), mDialog.data(), SLOT(close())); + disconnect(mActionNext, SIGNAL(triggered()), mDialog.data(), SLOT(close())); + disconnect(mActionFinish, SIGNAL(triggered()), mDialog.data(), SLOT(close())); + + ok = true; + ok = connect(mPageTimer, SIGNAL(timeout()), this, SLOT(onTimeOut())); + Q_ASSERT(ok); + + ok = connect( + mActionNext, SIGNAL(triggered()), + this, SLOT(nextTriggered())); + Q_ASSERT(ok); + + ok = connect( + mActionPrevious, SIGNAL(triggered()), + this, SLOT(previousTriggered())); + Q_ASSERT(ok); + + ok = connect( + mActionFinish, SIGNAL(triggered()), + this, SLOT(finishTriggered())); + Q_ASSERT(ok); + + ok = connect( + mActionCancel, SIGNAL(triggered()), + this, SLOT(cancelTriggered())); + Q_ASSERT(ok); + + // TODO: workaround for full screen dialog, with docml it is possible to + // define fullscreen dialog, mut resize is not done correctly when orientation + // is changed. See TSW Error: MTAA-854DK8 + ok = HbStyleLoader::registerFilePath(":/css/custom.css"); + Q_ASSERT(ok); +} + +/*! + Disconnect receiving triggered() signal from any toolbar action. + */ +void WlanWizardPrivate::disconnectActions() +{ + disconnect( + mActionNext, SIGNAL(triggered()), + this, SLOT(nextTriggered())); + + disconnect( + mActionPrevious, SIGNAL(triggered()), + this, SLOT(previousTriggered())); + + disconnect( + mActionFinish, SIGNAL(triggered()), + this, SLOT(finishTriggered())); + + disconnect( + mActionCancel, SIGNAL(triggered()), + this, SLOT(cancelTriggered())); +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/src/wlanwizardpagegenericerror.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/src/wlanwizardpagegenericerror.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,123 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * WLAN Wizard Page: Generic error page. + * + */ + +// System includes +#include +#include +#include +#include + +// User includes +#include "wlanwizard_p.h" +#include "wlanwizardpagegenericerror.h" +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wlanwizardpageprocessingsettingsTraces.h" +#endif + +/*! + \class WlanWizardPageGenericError + \brief Implements generic error page for wizard. + + Error text is read from the configurations + (WlanWizardHelper::ConfGenericErrorString) of the wizard. + */ + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + + +/*! + Constructor. + + @param [in] parent pointer to private implementation of wizard. + */ +WlanWizardPageGenericError::WlanWizardPageGenericError( + WlanWizardPrivate* parent) : + WlanWizardPageInternal(parent), + mWidget(NULL), + mLabel(NULL) +{ +} + +/*! + Destructor. + */ +WlanWizardPageGenericError::~WlanWizardPageGenericError() +{ + // signals are automatically disconnected +} + +/*! + See WlanWizardPage::initializePage() + */ +HbWidget* WlanWizardPageGenericError::initializePage() +{ + // Create the visualization at the first time + if (!mWidget) { + HbDocumentLoader docLoader(mWizard->mainWindow()); + + bool ok; + docLoader.load(":/docml/occ_add_wlan_error.docml", &ok); + Q_ASSERT(ok); + + mWidget = qobject_cast (docLoader.findWidget("occ_add_wlan_error")); + Q_ASSERT(mWidget != NULL); + + mLabel = qobject_cast (docLoader.findWidget("dialog")); + Q_ASSERT(mLabel != NULL); + } + + // Get the error string from the wizards configurations + mLabel->setPlainText( + mWizard->configuration( + WlanWizardHelper::ConfGenericErrorString).toString()); + + return mWidget; +} + +/*! + See WlanWizardPage::nextId() + + @param [out] removeFromStack return value is always false + + @return WlanWizardPageInternal::PageNone + */ +int WlanWizardPageGenericError::nextId(bool &removeFromStack) const +{ + removeFromStack = false; + return WlanWizardPageInternal::PageNone; +} + + +/*! + See WlanWizardPage::showPage() + + @return false. Next button is dimmed when the page is displayed. + */ +bool WlanWizardPageGenericError::showPage() +{ + return false; +} + + diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/src/wlanwizardpageinternal.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/src/wlanwizardpageinternal.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,56 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * WLAN Wizard: Interface for wizard pages (wlan internal). + * + */ + +// System includes +#include + +// User includes +#include "wlanwizard_p.h" +#include "wlanwizardpageinternal.h" + +/*! + \class WlanWizardPageInternal + \brief Interface for internal wlan wizard pages. Contains pointer to private + implementation of wlan wizard. + */ + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +/*! + Constructor + + @param [in] wizard pointer to private implementation of wizard + */ +WlanWizardPageInternal::WlanWizardPageInternal(WlanWizardPrivate *wizard) : + QObject(wizard), + mWizard(wizard) +{ +} + +/*! + Destructor. + */ +WlanWizardPageInternal::~WlanWizardPageInternal() +{ +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/src/wlanwizardpagekeyquery.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/src/wlanwizardpagekeyquery.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,270 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * WLAN Wizard Page: Key query page for WEP and WPA (2). + * + */ + +// System includes +#include +#include +#include +#include +#include +#include + +// User includes +#include "wlanwizard.h" +#include "wlanwizard_p.h" +#include "wlanwizardpagekeyquery.h" +#include "wlanwizardutils.h" + +/*! + \class WlanWizardPageKeyQuery + \brief Implements Key Query page for WEP and WPA. + */ + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + + +/*! + Constructor. + + @param [in] parent pointer to private implementation of wizard. + */ +WlanWizardPageKeyQuery::WlanWizardPageKeyQuery(WlanWizardPrivate* parent) : + WlanWizardPageInternal(parent), + mWidget(NULL), + mLabelTitle(NULL), + mLineEdit(NULL), + mLabelError(NULL), + mDocLoader(NULL) +{ +} + +/*! + Destructor. + */ +WlanWizardPageKeyQuery::~WlanWizardPageKeyQuery() +{ + delete mDocLoader; + + // Wizard framework deletes the visualization (owns mWidget). +} + +/*! + See WlanWizardPage::initializePage() + + Initializes the key query page and initializes objects based on the security + mode. + */ +HbWidget* WlanWizardPageKeyQuery::initializePage() +{ + if (!mWidget) { + bool ok; + + mDocLoader = new HbDocumentLoader(mWizard->mainWindow()); + + // Load document common part + mDocLoader->load(":/docml/occ_add_wlan_01_04.docml", &ok); + Q_ASSERT(ok); + + // Initialize orientation + loadDocmlSection(mWizard->mainWindow()->orientation()); + + // Load widgets + mWidget = + qobject_cast (mDocLoader->findWidget("occ_add_wlan_01")); + Q_ASSERT(mWidget != NULL); + + mLabelTitle = qobject_cast (mDocLoader->findWidget("dialog")); + Q_ASSERT(mLabelTitle != NULL); + + mLineEdit = qobject_cast (mDocLoader->findWidget("lineEditKey")); + Q_ASSERT(mLineEdit != NULL); + + mLabelError = + qobject_cast (mDocLoader->findWidget("labelErrorNote")); + Q_ASSERT(mLabelError != NULL); + + ok = connect( + mWizard->mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)), + this, SLOT(loadDocmlSection(Qt::Orientation))); + Q_ASSERT(ok); + + HbEditorInterface editInterface(mLineEdit); + editInterface.setInputConstraints(HbEditorConstraintLatinAlphabetOnly); + editInterface.setSmileyTheme(HbSmileyTheme()); + mLineEdit->setInputMethodHints( + Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase); + mLineEdit->installEventFilter(this); + } + + if (mWizard->configuration(WlanWizardHelper::ConfSecurityMode) == + CMManagerShim::WlanSecModeWep) { + mLineEdit->setMaxLength(WlanWizardUtils::WepHex128BitMaxLength); + } else { + mLineEdit->setMaxLength(WlanWizardUtils::WpaMaxLength); + } + + mLabelTitle->setPlainText( + hbTrId("txt_occ_dialog_enter_key_for_1").arg(mWizard->configuration( + WlanWizardPrivate::ConfSsid).toString())); + + return mWidget; +} + +/*! + Loads docml at initialization phase and when HbMainWindow sends orientation() + signal. + + @param [in] orientation to be loaded. + */ +void WlanWizardPageKeyQuery::loadDocmlSection(Qt::Orientation orientation) +{ + bool ok = false; + + // Load the orientation specific section + if (orientation == Qt::Horizontal) { + mDocLoader->load( + ":/docml/occ_add_wlan_01_04.docml", "landscape_section", &ok); + Q_ASSERT(ok); + } else { + Q_ASSERT(orientation == Qt::Vertical); + mDocLoader->load( + ":/docml/occ_add_wlan_01_04.docml", "portrait_section", &ok); + Q_ASSERT(ok); + } +} + +/*! + See WlanWizardPage::nextId() + + @param [in,out] removeFromStack return value is always false + + @return In case user has entered incorrect key an appropriate error text is + displayed and WlanWizardPage::PageNone is returned. + + In case user has entered a valid WEP or WPA key, the key is stored into + internal configuration and WlanWizardPage::PageProcessSettings is returned. + + */ +int WlanWizardPageKeyQuery::nextId(bool &removeFromStack) const +{ + WlanWizardUtils::KeyStatus status(WlanWizardUtils::KeyStatusOk); + int pageId = WlanWizardPage::PageNone; + int secMode = mWizard->configuration( + WlanWizardPrivate::ConfSecurityMode).toInt(); + + if (secMode == CMManagerShim::WlanSecModeWep) { + status = WlanWizardUtils::validateWepKey(mLineEdit->text()); + } + else { + Q_ASSERT( + secMode == CMManagerShim::WlanSecModeWpa || + secMode == CMManagerShim::WlanSecModeWpa2); + + status = WlanWizardUtils::validateWpaKey(mLineEdit->text()); + } + QString errorString = keyStatusToErrorString(status); + + if (errorString.length() == 0 ) { + if (secMode == CMManagerShim::WlanSecModeWep) { + mWizard->setConfiguration(WlanWizardPrivate::ConfKeyWep1, mLineEdit->text()); + mWizard->setConfiguration(WlanWizardPrivate::ConfKeyWep2, mLineEdit->text()); + mWizard->setConfiguration(WlanWizardPrivate::ConfKeyWep3, mLineEdit->text()); + mWizard->setConfiguration(WlanWizardPrivate::ConfKeyWep4, mLineEdit->text()); + mWizard->setConfiguration(WlanWizardPrivate::ConfKeyWepDefault, + CMManagerShim::WepKeyIndex1); + } else { + mWizard->setConfiguration(WlanWizardPrivate::ConfKeyWpa, mLineEdit->text()); + } + pageId = WlanWizardPage::PageProcessSettings; + } + else { + mLabelError->setPlainText(errorString); + } + + removeFromStack = false; + return pageId; +} + +/*! + See WlanWizardPage::showPage() + */ +bool WlanWizardPageKeyQuery::showPage() +{ + // Open virtual keyboard by setting focus to line edit + mLineEdit->setFocus(); + + return true; +} + +/*! + When focus moves into the Key editor and there is visible error text, it + is cleared. + + @param [in] obj Pointer to the object the event was sent to + @param [in] event Pointer to the sent event. + + @return false. do not eat the event. + */ +bool WlanWizardPageKeyQuery::eventFilter(QObject *obj, QEvent *event) +{ + if (obj == mLineEdit && event->type() == QEvent::FocusIn) { + mLabelError->setPlainText(""); + } + return false; +} + +/*! + Maps provided error code to error text. + + @param [in] status status of key validation + + @return An error text in case of error, empty string is returned on + successful case. + */ +QString WlanWizardPageKeyQuery::keyStatusToErrorString( + WlanWizardUtils::KeyStatus status) const +{ + QString errorString; + switch (status) { + case WlanWizardUtils::KeyStatusIllegalCharacters: + errorString = hbTrId("txt_occ_dialog_illegal_characters_in_key_please_c"); + break; + + case WlanWizardUtils::KeyStatusWpaTooShort: + case WlanWizardUtils::KeyStatusWpaTooLong: + errorString = hbTrId("txt_occ_dialog_preshared_key_too_short_at_least"); + break; + + case WlanWizardUtils::KeyStatusWepInvalidLength: + errorString = hbTrId("txt_occ_dialog_key_is_of_incorrect_length_please"); + break; + + case WlanWizardUtils::KeyStatusOk: + default: + Q_ASSERT(WlanWizardUtils::KeyStatusOk == status); + // nothing to do here. + break; + } + return errorString; +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/src/wlanwizardpagenetworkmode.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/src/wlanwizardpagenetworkmode.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,190 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * WLAN Wizard Page: Network mode Selection. + * + */ + +// System includes +#include +#include +#include +#include +#include +#include + +// User includes +#include "wlanwizard_p.h" +#include "wlanwizard.h" +#include "wlanwizardpagenetworkmode.h" +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wlanwizardpagenetworkmodeTraces.h" +#endif + +/*! + * Contructor. Member initialization. + */ +WlanWizardPageNetworkMode::WlanWizardPageNetworkMode( + WlanWizardPrivate* parent) : + WlanWizardPageInternal(parent), + mWidget(NULL), + mList(NULL), + mLabel(NULL), + mLoader(NULL), + mValid(false) +{ +} + +/*! + * Destructor. Loader widget is deleted. + * All document widgets are deleted by wlanwizard_p destructor. + */ +WlanWizardPageNetworkMode::~WlanWizardPageNetworkMode() +{ + delete mLoader; +} + +/*! + * Page initialization. If view is already loaded, does nothing. + */ +HbWidget* WlanWizardPageNetworkMode::initializePage() +{ + OstTrace0( TRACE_NORMAL, WLANWIZARDPAGENETWORKMODE_INITIALIZEPAGE, + "WlanWizardPageNetworkMode::initializePage" ); + + if (mWidget == NULL) { + mLoader = new HbDocumentLoader(mWizard->mainWindow()); + + bool ok; + + mLoader->load(":/docml/occ_add_wlan_02_03.docml", &ok); + Q_ASSERT_X(ok, "WLAN Wizard", "Invalid docml file"); + + loadDocml(mWizard->mainWindow()->orientation()); + + mWidget = qobject_cast (mLoader->findWidget( + "occ_add_wlan_02")); + Q_ASSERT_X(mWidget != NULL, "WlanWizardPageNetworkMode", "View not found"); + + mList = qobject_cast (mLoader->findWidget("list")); + Q_ASSERT_X(mList != NULL, "WlanWizardPageNetworkMode", "List not found"); + + mLabel = qobject_cast (mLoader->findWidget("dialog_6")); + Q_ASSERT_X(mLabel != NULL, "WlanWizardPageNetworkMode", "Label not found"); + + // Connect document loading to main window orientation changes. + ok &= connect(mWizard->mainWindow(), + SIGNAL(orientationChanged(Qt::Orientation)), this, + SLOT(loadDocml(Qt::Orientation))); + + // Connect a function to a radio button selection. + ok &= connect(mList, SIGNAL(itemSelected(int)), this, + SLOT(itemSelected(int))); + + Q_ASSERT_X(ok, "WLAN Wizard", "orientationChanged slot connection failed"); + + mLabel->setPlainText(hbTrId( + "txt_occ_dialog_select_network_mode_and_status")); + + QStringList items; + + addToList(items, hbTrId("txt_occ_dblist_val_infrastructure_public"), + CMManagerShim::Infra, false); + + addToList(items, hbTrId("txt_occ_list_infrastructure_hidden"), + CMManagerShim::Infra, true); + + addToList(items, hbTrId("txt_occ_list_adhoc_1"), CMManagerShim::Adhoc, + false); + + mList->setItems(items); + + } + return mWidget; +} + +/*! + * When moving to next page, write user selections to the wizard and return + * Security mode query page id. + */ +int WlanWizardPageNetworkMode::nextId(bool &removeFromStack) const +{ + removeFromStack = false; + // TODO: wk18: proper code + mWizard->setConfiguration(WlanWizardPrivate::ConfNetworkMode, + mNetworkModes.at(mList->selected())); + + mWizard->setConfiguration(WlanWizardPrivate::ConfHiddenWlan, + mIsHidden.at(mList->selected())); + + return WlanWizardPageInternal::PageNetworkSecurity; +} + +/*! + * Indicates the validity of the network mode page. + * @see WlanWizardPage + */ +bool WlanWizardPageNetworkMode::showPage() +{ + return mValid; +} + +/*! + * Sets the page as valid, if any mode is selected. + * (Initially none is selected.) + */ +void WlanWizardPageNetworkMode::itemSelected(int /* index */) +{ + OstTrace0( TRACE_BORDER, WLANWIZARDPAGENETWORKMODE_ITEMSELECTED, + "WlanWizardPageNetworkMode::itemSelected" ); + + mValid = true; + mWizard->enableNextButton(mValid); +} + +/*! + * Loads the ui layout file with current orientation. + */ +void WlanWizardPageNetworkMode::loadDocml(Qt::Orientation orientation) +{ + OstTrace1( TRACE_NORMAL, WLANWIZARDPAGENETWORKMODE_LOADDOCML, + "WlanWizardPageNetworkMode::loadDocml - Orientation;orientation=%x", + ( TUint )( orientation ) ); + + bool ok; + if (orientation == Qt::Horizontal) { + mLoader->load(":/docml/occ_add_wlan_02_03.docml", "landscape_section", + &ok); + Q_ASSERT_X(ok, "WLAN Wizard", "Landscape section not found"); + } + else { + mLoader->load(":/docml/occ_add_wlan_02_03.docml", "portrait_section", + &ok); + Q_ASSERT_X(ok, "WLAN Wizard", "Portrait section not found"); + } +} + +/*! + * Mode and visibility lists are populated to the same order as the radio + * button list. + */ +void WlanWizardPageNetworkMode::addToList(QStringList &list, + const QString &item, int mode, bool isHidden) +{ + list << item; + mNetworkModes.append(mode); + mIsHidden.append(isHidden); +} + diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/src/wlanwizardpageprocessingsettings.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/src/wlanwizardpageprocessingsettings.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,359 @@ +/* +* 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 "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* WLAN Wizard Page: Processing settings, connection and running ict. +*/ + +// System includes +#include +#include +#include +#include +#include +#include + +// User includes +#include "wlanwizardplugin.h" +#include "wlanqtutils.h" +#include "wlanwizard_p.h" +#include "wlanwizardpageprocessingsettings.h" +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wlanwizardpageprocessingsettingsTraces.h" +#endif + +/*! + \class WlanWizardPageProcessingSettings + \brief Implements Processing settings wizard page. + + In this page + - possible wizard plugin settings are stored + - connection to the wlan ap is established + - ICT (Internet connectivity test) is run + */ + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + + +/*! + Constructor. + + @param [in] parent pointer to private implementation of wizard. + */ +WlanWizardPageProcessingSettings::WlanWizardPageProcessingSettings( + WlanWizardPrivate* parent) : + WlanWizardPageInternal(parent), + mDocLoader(NULL), + mWidget(NULL), + mLabel(NULL), + mNextPageId(WlanWizardPageInternal::PageSummary) +{ + WlanQtUtils* utils = mWizard->wlanQtUtils(); + + bool ok; + ok = connect( + utils, SIGNAL(wlanNetworkOpened(int)), + this, SLOT(wlanNetworkOpened(int))); + Q_ASSERT(ok); + + ok = connect( + utils, SIGNAL(wlanNetworkClosed(int,int)), + this, SLOT(wlanNetworkClosed(int,int))); + Q_ASSERT(ok); + +#ifdef ICT_RESULT_ENUM + ok = connect( + utils, SIGNAL(ictResult(int,WlanLoginIctsResultType)), + this, SLOT(ictResult(int,WlanLoginIctsResultType))); +#else + ok &= connect( + utils, SIGNAL(ictResult(int,bool)), + this, SLOT(ictResult(int,bool))); +#endif + Q_UNUSED(ok); + Q_ASSERT(ok); +} + +/*! + Destructor. + */ +WlanWizardPageProcessingSettings::~WlanWizardPageProcessingSettings() +{ + // signals are automatically disconnected + delete mDocLoader; + + // Wizard framework deletes the visualization (owns mWidget). +} + +/*! + See WlanWizardPage::initializePage() + */ +HbWidget* WlanWizardPageProcessingSettings::initializePage() +{ + if (!mWidget) { + mDocLoader = new HbDocumentLoader(mWizard->mainWindow()); + + bool ok; + mDocLoader->load(":/docml/occ_add_wlan_06.docml", &ok); + Q_ASSERT(ok); + loadDocmlSection(mWizard->mainWindow()->orientation()); + + mWidget = qobject_cast (mDocLoader->findWidget("occ_add_wlan_06")); + Q_ASSERT(mWidget != NULL); + + mLabel = qobject_cast (mDocLoader->findWidget("dialog")); + Q_ASSERT(mLabel != NULL); + + ok = connect( + mWizard->mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)), + this, SLOT(loadDocmlSection(Qt::Orientation))); + Q_ASSERT(ok); + } + + mLabel->setPlainText(hbTrId("txt_occ_dialog_checking_connection_to_1").arg( + mWizard->configuration(WlanWizardPrivate::ConfSsid).toString())); + + return mWidget; +} + +/*! + See WlanWizardPage::nextId() + + @param [out] removeFromStack return value is always true + + @return WlanWizardPageInternal::PageSummary + */ +int WlanWizardPageProcessingSettings::nextId(bool &removeFromStack) const +{ + removeFromStack = true; + return mNextPageId; +} + + +/*! + See WlanWizardPage::showPage() + + @return false. Next button is dimmed when the page is displayed. + */ +bool WlanWizardPageProcessingSettings::showPage() +{ + return false; +} + +/*! + Loads docml at initialization phase and when HbMainWindow sends orientation() + signal. + + @param [in] orientation to be loaded. + */ +void WlanWizardPageProcessingSettings::loadDocmlSection(Qt::Orientation orientation) +{ + bool ok; + // Load the orientation specific section + if (orientation == Qt::Horizontal) { + mDocLoader->load(":/docml/occ_add_wlan_06.docml", "landscape_section", &ok); + Q_ASSERT(ok); + } + else { + Q_ASSERT(orientation == Qt::Vertical); + mDocLoader->load(":/docml/occ_add_wlan_06.docml", "portrait_section", &ok); + Q_ASSERT(ok); + } +} + +/*! + This method is connected to WlanQtUtils::wlanNetworkClosed(int, int) signal. + to get disconnected status events of currently established connection. + + In case of failure, movement to generic error page is triggered. + + @param [in] iapId IAP ID + @param [in] reason Symbian Error code. + */ +void WlanWizardPageProcessingSettings::wlanNetworkClosed(int iapId, int reason) +{ + OstTraceExt2( TRACE_BORDER, + WLANWIZARDPAGEPROCESSINGSETTINGS_WLANNETWORKCLOSED, + "WlanWizardPageProcessingSettings::wlanNetworkClosed;iapId=%d;reason=%d", + iapId, reason ); + + if (iapId != mWizard->configuration(WlanWizardHelper::ConfIapId).toInt()) { + return; + } + + mWizard->setConfiguration(WlanWizardPrivate::ConfIctStatus, false); + mWizard->setConfiguration(WlanWizardPrivate::ConfConnected, false); + + if (mWizard->isCurrentPage(mWidget)) { + QString errorText; + switch (reason) { + case KErrWlanOpenAuthFailed: + case KErrWlanSharedKeyAuthRequired: + case KErrWlanWpaAuthRequired: + case KErrWlanWpaAuthFailed: + case KErrWlan802dot1xAuthFailed: + case KErrWlanIllegalEncryptionKeys: + case KErrWlanPskModeRequired: + case KErrWlanEapModeRequired: + errorText = hbTrId("txt_occ_dialog_authentication_unsuccessful"); + break; + + case KErrWlanIllegalWpaPskKey: + errorText = hbTrId("txt_occ_dialog_incorrect_wpa_preshared_key_pleas"); + break; + + case KErrWlanSharedKeyAuthFailed: + errorText = hbTrId("txt_occ_dialog_incorrect_wep_key_please_check_the"); + break; + + case KErrNone: + // Do nothing, when connection is dropped we don't get any error code + default: + // Get plugin specific localized error text if any + WlanWizardPlugin *plugin = mWizard->wlanWizardPlugin(); + + if (plugin){ + errorText = plugin->errorString(reason); + } + if (errorText.length() == 0) { + errorText = hbTrId("txt_occ_dialog_connection_failed"); + } + break; + } + mNextPageId = WlanWizardPageInternal::PageGenericError; + mWizard->setConfiguration( + WlanWizardHelper::ConfGenericErrorString, errorText); + mWizard->nextPage(); + } + + OstTrace0( + TRACE_BORDER, WLANWIZARDPAGEPROCESSINGSETTINGS_WLANNETWORKCLOSED_DONE, + "WlanWizardPageProcessingSettings::wlanNetworkClosed - Done" ); +} + +/*! + Handles ictResult(int, bool) signal from WlanQtUtils and calls + WlanWizardHelper::nextPage() to trigger movement to next page. + + @param [in] iapId IAP ID + @param [in] reason ICT result, Symbian error code + */ +#ifdef ICT_RESULT_ENUM +void WlanWizardPageProcessingSettings::ictResult(int iapId, WlanLoginIctsResultType reason) +{ + OstTraceExt2( + TRACE_BORDER, + WLANWIZARDPAGEPROCESSINGSETTINGS_ICTRESULT, + "WlanWizardPageProcessingSettings::ictResult;iapId=%d;result=%d", + iapId, reason ); + + if (iapId != mWizard->configuration(WlanWizardHelper::ConfIapId).toInt()) { + Q_ASSERT(false); + return; + } + mWizard->setConfiguration(WlanWizardPrivate::ConfConnected, true); + mWizard->setConfiguration(WlanWizardPrivate::ConfIctStatus, reason); + if(reason == IctsCanceled) { + QString errorText; + // TODO: What error string should be loaded? + mNextPageId = WlanWizardPageInternal::PageGenericError; + mWizard->setConfiguration( + WlanWizardHelper::ConfGenericErrorString, errorText); + } + mWizard->nextPage(); + + OstTrace0( TRACE_BORDER, WLANWIZARDPAGEPROCESSINGSETTINGS_ICTRESULT_DONE, + "WlanWizardPageProcessingSettings::ictResult - Done" ); +} +#else +void WlanWizardPageProcessingSettings::ictResult(int iapId, bool reason) +{ + OstTraceExt2( + TRACE_BORDER, + WLANWIZARDPAGEPROCESSINGSETTINGS_ICTRESULT_1, + "WlanWizardPageProcessingSettings::ictResult;iapId=%d;result=%d", + iapId, reason ); + + if (iapId != mWizard->configuration(WlanWizardHelper::ConfIapId).toInt()) { + Q_ASSERT(false); + return; + } + mWizard->setConfiguration(WlanWizardPrivate::ConfConnected, true); + mWizard->setConfiguration(WlanWizardPrivate::ConfIctStatus, reason); + mWizard->nextPage(); + + OstTrace0( TRACE_BORDER, WLANWIZARDPAGEPROCESSINGSETTINGS_ICTRESULT_DONE_1, + "WlanWizardPageProcessingSettings::ictResult - Done" ); +} +#endif + +/*! + Handles wlanNetworkOpened(int) signal from WlanQtUtils. + + @param [in] iapId IAP ID + */ +void WlanWizardPageProcessingSettings::wlanNetworkOpened(int iapId) +{ + Q_UNUSED(iapId); + OstTrace1( + TRACE_BORDER, + WLANWIZARDPAGEPROCESSINGSETTINGS_WLANNETWORKOPENED, + "WlanWizardPageProcessingSettings::wlanNetworkOpened;iapId=%d", + iapId); +} + +/*! + See WlanWizardPage::requiresStartOperation(). + + Indicates to framework that startOperation() needs to called. + */ +bool WlanWizardPageProcessingSettings::requiresStartOperation() +{ + return true; +} + +/*! + See WlanWizardPage::startOperation(). + + Starts the page operation. + */ +void WlanWizardPageProcessingSettings::startOperation() +{ + if (mWizard->handleIap()) { + mNextPageId = WlanWizardPageInternal::PageSummary; + + // in case wlan connection is already established disconnect it + // note that connectIap() disconnects implicitly connection when + // same IAP is already connected. + WlanQtUtils* utils = mWizard->wlanQtUtils(); + int connectedIapId = utils->activeIap(); + int iapId = mWizard->configuration(WlanWizardHelper::ConfIapId).toInt(); + if (connectedIapId != iapId){ + utils->disconnectIap(connectedIapId); + } + mWizard->wlanQtUtils()->connectIap( iapId, true); + } else { + mNextPageId = WlanWizardPageInternal::PageGenericError; + mWizard->setConfiguration( + WlanWizardHelper::ConfGenericErrorString, + hbTrId("txt_occ_dialog_unable_to_save_settings_please_ret")); + mWizard->nextPage(); + } +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/src/wlanwizardpagescanning.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/src/wlanwizardpagescanning.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,348 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * WLAN Wizard Page: Scan processing. + */ + +// System includes +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// User includes +#include "wlanwizard_p.h" +#include "wlanwizardpagescanning.h" +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wlanwizardpagescanningTraces.h" +#endif + +/*! + * Constructor. Member initialization. + */ +WlanWizardPageScanning::WlanWizardPageScanning(WlanWizardPrivate* parent) : + WlanWizardPageInternal(parent), + mWidget(NULL), + mLabel(NULL), + mBar(NULL), + mLoader(NULL), + mNextPageId(WlanWizardPage::PageNone), + mScanResultsAvailable(false) +{ + WlanQtUtils* utils = mWizard->wlanQtUtils(); + + // Connect normal scan completion signal from wlanQtUtils to result + // handler. Connect here instead of initializePage, since this signal may + // need to be caught event if the window is not active. + bool ok = connect(utils, SIGNAL(wlanScanApReady()), this, + SLOT(wlanScanResultPreCheck())); +} + +/*! + * Destructor. Loader widget is deleted. + * All document widgets are deleted by wlanwizard_p destructor. + */ +WlanWizardPageScanning::~WlanWizardPageScanning() +{ + delete mLoader; +} + +/*! + * Page initialization. If view is already loaded, does nothing. + */ +HbWidget* WlanWizardPageScanning::initializePage() +{ + OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESCANNING_INITIALIZEPAGE, + "WlanWizardPageScanning::initializePage" ); + + // Next page id is reset with each initialization. + mNextPageId = WlanWizardPage::PageNone; + + if (mWidget == NULL) { + + mLoader = new HbDocumentLoader(mWizard->mainWindow()); + + bool ok; + + mLoader->load(":/docml/occ_add_wlan_06.docml", &ok); + Q_ASSERT_X(ok, "WlanWizardPageScanning", "Invalid docml file"); + + // Initialize orientation + loadDocml(mWizard->mainWindow()->orientation()); + + // Load widgets + mWidget = qobject_cast (mLoader->findWidget( + "occ_add_wlan_06")); + Q_ASSERT_X(mWidget != NULL, "WlanWizardPageScanning", "View not found"); + + mLabel = qobject_cast (mLoader->findWidget("dialog")); + Q_ASSERT_X(mLabel != NULL, "WlanWizardPageScanning", + "textLabel not found"); + + mBar = qobject_cast (mLoader->findWidget("progressBar")); + Q_ASSERT_X(mBar != NULL, "WlanWizardPageScanning", + "progressBar not found"); + + WlanQtUtils* utils = mWizard->wlanQtUtils(); + + // Connect orientation signal from the main window to orientation + // loader. + ok &= connect(mWizard->mainWindow(), + SIGNAL(orientationChanged(Qt::Orientation)), this, + SLOT(loadDocml(Qt::Orientation))); + + // Connect direct scan completion signal from wlanQtUtils to result + // handler. + ok &= connect(utils, SIGNAL(wlanScanDirectReady()), this, + SLOT(wlanScanDirectReady())); + + Q_ASSERT(ok); + + } + + mLabel->setPlainText(hbTrId("txt_occ_dialog_searching").arg( + mWizard->configuration(WlanWizardPrivate::ConfSsid).toString())); + + return mWidget; +} + +/*! + * Sends the user to the next page. + */ +int WlanWizardPageScanning::nextId(bool &removeFromStack) const +{ + removeFromStack = true; + + return mNextPageId; +} + +/*! + * Always false. Moving to next page is not done manually. + * @see WlanWizardPage + */ +bool WlanWizardPageScanning::showPage() +{ + return false; +} + +/*! + * Loads the document orientation-specific parameters. + */ +void WlanWizardPageScanning::loadDocml(Qt::Orientation orientation) +{ + OstTrace1( TRACE_NORMAL, WLANWIZARDPAGESCANNING_LOADDOCML, + "WlanWizardPageScanning::loadDocml - orientation ;orientation=%x", + ( TUint )( orientation ) ); + + bool ok; + // Then load the orientation specific section + if (orientation == Qt::Horizontal) { + mLoader->load(":/docml/occ_add_wlan_06.docml", "landscape_section", &ok); + Q_ASSERT(ok); + } else { + Q_ASSERT(orientation == Qt::Vertical); + mLoader->load(":/docml/occ_add_wlan_06.docml", "portrait_section", &ok); + Q_ASSERT(ok); + } +} + +void WlanWizardPageScanning::wlanScanResultPreCheck() +{ + if (!mWidget) { + OstTrace1( TRACE_BORDER, WLANWIZARDPAGESCANNING_WLANSCANRESULTPRECHECK, + "WlanWizardPageScanning::wlanScanResultPreCheck no widget;this=%x", + this ); + + mScanResultsAvailable = true; + } + else { + if (mWizard->isCurrentPage(mWidget)) { + OstTrace0( TRACE_BORDER, + DUP1_WLANWIZARDPAGESCANNING_WLANSCANRESULTPRECHECK, + "WlanWizardPageScanning::wlanScanResultPreCheck go to results"); + + wlanScanApReady(); + } + else { + OstTrace0( TRACE_BORDER, + DUP2_WLANWIZARDPAGESCANNING_WLANSCANRESULTPRECHECK, + "WlanWizardPageScanning::wlanScanResultPreCheck" + " not current widget" ); + + mScanResultsAvailable = true; + } + } +} + +/*! + * Public networks did not reveal matches. Direct scan has been performed to + * find out if the network is hidden but in range. If network is found, proceed + * to next page according to scan results. + * If nothing is found, proceed to manual network + * mode selection page. + */ +void WlanWizardPageScanning::wlanScanDirectReady() +{ + OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESCANNING_WLANSCANDIRECTREADY, + "WlanWizardPageScanning::wlanScanDirectReady" ); + + WlanQtUtils* utils = mWizard->wlanQtUtils(); + + Q_ASSERT(utils); + + QList > wlanApList; + + utils->availableWlanAps(wlanApList); + + qDebug("WlanWizardPageScanning::wlanScanDirectReady - results read"); + + QSharedPointer item; + + qDebug("%d APs found", wlanApList.size()); + if(wlanApList.isEmpty()) { + qDebug("Match not found. Go to manual settings."); + mNextPageId = WlanWizardPageInternal::PageNetworkMode; + } + else { + int strongestSignal = 0; + int strongestIndex = 0; + + for (int i = 0; i < wlanApList.size(); i++) { + // All direct scan results are matches. No need to compare ssids. + // In case there are multiple matches to direct scan, use the + // strongest signal on the result list. + item = wlanApList.at(i); + int str = item->value(WlanQtUtilsAp::ConfIdSignalStrength).toInt(); + if (str > strongestSignal) { + qDebug("Strongest signal %d at %d", str, i); + strongestSignal = str; + strongestIndex = i; + } + } + + item = wlanApList.at(strongestIndex); + qDebug("Select AP at %d", strongestIndex); + mNextPageId = mWizard->getNextPageId( + item->value(WlanQtUtilsAp::ConfIdSsid).toString(), + item->value(WlanQtUtilsAp::ConfIdConnectionMode).toInt(), + item->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(), + item->value(WlanQtUtilsAp::ConfIdWpaPskUse).toBool(), + true, // hidden + item->value(WlanQtUtilsAp::ConfIdWpsSupported).toBool()); + } + + mWizard->nextPage(); + +} + +/*! + * All wlan channels have been scanned for public networks. Now process the + * results. If a network is found which matches the ssid set by the user, + * proceed to next page according to the network attributes. + * If no ssid match is found, proceed to a direct scan. + */ +void WlanWizardPageScanning::wlanScanApReady() +{ + OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESCANNING_WLANSCANAPREADY, + "WlanWizardPageScanning::wlanScanApReady" ); + + WlanQtUtils* utils = mWizard->wlanQtUtils(); + Q_ASSERT(utils); + + QList > wlanApList; + + // Fetch the list of scan results. + utils->availableWlanAps(wlanApList); + + qDebug("WlanWizardPageScanning::wlanScanApReady - results read"); + + QString ssid = + mWizard->configuration(WlanWizardPrivate::ConfSsid).toString(); + qDebug() << "SSID scanned by user " << ssid; + + bool matchFound = false; + int strongestSignal = -1; + int strongestIndex = 0; + QSharedPointer item; + + qDebug("%d APs found", wlanApList.size()); + + for (int i = 0; i < wlanApList.size(); i++) { + // In case there are multiple matches to direct scan, use the + // strongest signal on the result list. + item = wlanApList.at(i); + if (item->value(WlanQtUtilsAp::ConfIdSsid).toString() == ssid) { + qDebug("Match found"); + matchFound = true; + + int str = item->value(WlanQtUtilsAp::ConfIdSignalStrength).toInt(); + if (str > strongestSignal) { + qDebug("Strongest signal %d at %d", str, i); + strongestSignal = str; + strongestIndex = i; + } + } + } + + if (matchFound) { + qDebug("Select AP at %d", strongestIndex); + item = wlanApList.at(strongestIndex); + mNextPageId = mWizard->getNextPageId( + item->value(WlanQtUtilsAp::ConfIdSsid).toString(), + item->value(WlanQtUtilsAp::ConfIdConnectionMode).toInt(), + item->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(), + item->value(WlanQtUtilsAp::ConfIdWpaPskUse).toBool(), + false, // public + item->value(WlanQtUtilsAp::ConfIdWpsSupported).toBool()); + // The ssid indicated by the user was found. Proceed to next page. + mWizard->nextPage(); + } + else { + qDebug("Match not found. Perform direct scan."); + utils->scanWlanDirect(ssid); + } + +} + +/*! + * Overloaded function from WlanWizardPage. Indicates that this window requires + * post-initialization start operations. + */ +bool WlanWizardPageScanning::requiresStartOperation() +{ + return true; +} + +/*! + * Wlan scan is performed as a "post-initialization" which is executed in a + * separate scheduler loop. + */ +void WlanWizardPageScanning::startOperation() +{ + OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESCANNING_STARTOPERATION, + "WlanWizardPageScanning::startOperation - start AP scan if results" + " are available." ); + + if (mScanResultsAvailable) { + mScanResultsAvailable = false; + wlanScanApReady(); + } +} + diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/src/wlanwizardpagesecuritymode.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/src/wlanwizardpagesecuritymode.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,236 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * WLAN Wizard Page: Security mode Selection. + * + */ + +// System includes +#include +#include +#include +#include +#include +#include + +// User includes +#include "wlanwizard_p.h" +#include "wlanwizard.h" +#include "wlanwizardpagesecuritymode.h" +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wlanwizardpagesecuritymodeTraces.h" +#endif + +/*! + * Constructor. Member initialization. + */ +WlanWizardPageSecurityMode::WlanWizardPageSecurityMode( + WlanWizardPrivate* parent) : + WlanWizardPageInternal(parent), + mWidget(NULL), + mList(NULL), + mLabel(NULL), + mLoader(NULL), + mValid(false) +{ +} + +/*! + * Destructor. Loader widget is deleted. + * All document widgets are deleted by wlanwizard_p destructor. + */ +WlanWizardPageSecurityMode::~WlanWizardPageSecurityMode() +{ + delete mLoader; +} + +/*! + * Page initialization. If view is already loaded, does nothing. + */ +HbWidget* WlanWizardPageSecurityMode::initializePage() +{ + OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESECURITYMODE_INITIALIZEPAGE, + "WlanWizardPageSecurityMode::initializePage" ); + + if (mWidget==NULL) { + + mLoader = new HbDocumentLoader(mWizard->mainWindow()); + + bool ok; + + mLoader->load( ":/docml/occ_add_wlan_02_03.docml", &ok ); + Q_ASSERT_X(ok, "WlanWizardPageSecurityMode", "Invalid docml file"); + + // Initialize orientation + loadDocml( mWizard->mainWindow()->orientation() ); + + // Load widgets + mWidget = qobject_cast (mLoader->findWidget("occ_add_wlan_02")); + Q_ASSERT_X(mWidget != NULL, "WlanWizardPageSecurityMode", "View not found"); + + mList = qobject_cast (mLoader->findWidget("list")); + Q_ASSERT_X(mList != NULL, "WlanWizardPageSecurityMode", "List not found"); + + mLabel = qobject_cast (mLoader->findWidget("dialog_6")); + Q_ASSERT_X(mLabel != NULL, "WlanWizardPageSecurityMode", "Label not found"); + + mLabel->setPlainText(hbTrId("txt_occ_dialog_select_network_security_mode")); + + // Create contents to the security mode radio button list. + populateSecModeList(); + + // Connect orientation signal from the main window to orientation + // loader. + ok &= connect( mWizard->mainWindow(), + SIGNAL(orientationChanged(Qt::Orientation)), + this, SLOT(loadDocml(Qt::Orientation))); + + // Connect signal from the radio button list indicating that an item + // has been selected to validation handler. + ok &= connect( mList, SIGNAL(itemSelected(int)), + this, SLOT(itemSelected(int))); + + Q_ASSERT_X(ok, "WlanWizardPageSecurityMode", "slot connection failed"); + + + + } + return mWidget; +} + +/*! + * Indicates the validity of the security mode page. + * @see WlanWizardPage + */ +bool WlanWizardPageSecurityMode::showPage() +{ + return mValid; +} + +/*! + * Sets the page as valid, if any mode is selected. + * (Initially none is selected.) + */ +void WlanWizardPageSecurityMode::itemSelected(int /* index */) +{ + OstTrace0( TRACE_BORDER, WLANWIZARDPAGESECURITYMODE_ITEMSELECTED, + "WlanWizardPageSecurityMode::itemSelected" ); + + mValid = true; + mWizard->enableNextButton(mValid); +} + +/*! + * Evaluates and returns the next page id. + * @see initializePage() + */ +int WlanWizardPageSecurityMode::nextId(bool &removeFromStack) const +{ + removeFromStack = false; + + // The configuration is selected from the mSecModes list, which is ordered + // during the page initialization. + mWizard->setConfiguration( WlanWizardPrivate::ConfSecurityMode, + mSecModes.at( mList->selected() ) ); + + // The configuration is selected from the mUsePsk list, which is ordered + // during the page initialization. + mWizard->setConfiguration( WlanWizardPrivate::ConfUsePsk, + mUsePsk.at( mList->selected() ) ); + + return mPageIds.at( mList->selected() ); +} + +/*! + * Loads the document with given orientation. + */ +void WlanWizardPageSecurityMode::loadDocml(Qt::Orientation orientation) +{ + OstTrace1( TRACE_NORMAL, WLANWIZARDPAGESECURITYMODE_LOADDOCML, + "WlanWizardPageSecurityMode::loadDocml - orientation;orientation=%x", + ( TUint )( orientation ) ); + + bool ok; + if( orientation == Qt::Horizontal ) { + mLoader->load(":/docml/occ_add_wlan_02_03.docml", "landscape_section", &ok); + Q_ASSERT_X(ok, "WlanWizardPageSecurityMode", "Landscape section not found"); + } + else { + mLoader->load(":/docml/occ_add_wlan_02_03.docml", "portrait_section", &ok); + Q_ASSERT_X(ok, "WlanWizardPageSecurityMode", "Portrait section not found"); + } +} + +/*! + * Support function that creates the contents of the security mode list. + */ +void WlanWizardPageSecurityMode::populateSecModeList() +{ + QStringList items; + + mSecModes.clear(); + mPageIds.clear(); + + // Create the radio button list to correspond to correct security mode + // identifiers and page identifiers. + // Populate the list according to network mode selection. + addToList(items, hbTrId("txt_occ_list_open"), + CMManagerShim::WlanSecModeOpen, + WlanWizardPage::PageProcessSettings, + false); + + addToList(items, hbTrId("txt_occ_list_wep_1"), + CMManagerShim::WlanSecModeWep, + WlanWizardPageInternal::PageKeyQuery, + true); + + // In case of Ad-hoc network, exclude wpa, eap and 802.1X modes. + if(mWizard->configuration(WlanWizardPrivate::ConfNetworkMode).toInt() + != CMManagerShim::Adhoc) { + + addToList(items, hbTrId("txt_occ_list_wpa_with_password"), + CMManagerShim::WlanSecModeWpa, + WlanWizardPageInternal::PageKeyQuery, + true); + + // TODO: Fix these codes + addToList(items, hbTrId("txt_occ_list_wpa_with_eap"), + CMManagerShim::WlanSecModeWpa, + WlanWizardPage::PageEapStart, + false); + + addToList(items, hbTrId("txt_occ_list_8021x_1"), + CMManagerShim::WlanSecMode802_1x, + WlanWizardPage::PageEapStart, + false); + } + + mList->setItems(items); +} + +/*! + * Creates lists for security modes and page id:s so that they can be referred + * with radio button widget index. + */ +void WlanWizardPageSecurityMode::addToList(QStringList &list, + const QString &item, int mode, int page, bool psk) +{ + list << item; + mSecModes.append(mode); + mPageIds.append(page); + mUsePsk.append(psk); +} + + diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/src/wlanwizardpagessid.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/src/wlanwizardpagessid.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,236 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * WLAN Wizard Page: SSID Selection. + * + */ + +// System includes +#include +#include +#include +#include +#include +#include +#include + +// User includes +#include "wlanwizardpagessid.h" +#include "wlanwizard_p.h" +#include "wlanwizardutils.h" +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wlanwizardpagessidTraces.h" +#endif + +/*! + * Constructor. Member initialization. + */ +WlanWizardPageSsid::WlanWizardPageSsid(WlanWizardPrivate* parent) : + WlanWizardPageInternal(parent), + mWidget(NULL), + mLabel(NULL), + mSsid(NULL), + mLabelError(NULL), + mLoader(NULL) +{ + +} + +/*! + * Destructor. Loader widget is deleted. + * All document widgets are deleted by wlanwizard_p destructor. + */ +WlanWizardPageSsid::~WlanWizardPageSsid() +{ + delete mLoader; +} + +/*! + * Page initialization. If view is already loaded, does nothing. + */ +HbWidget* WlanWizardPageSsid::initializePage() +{ + OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESSID_INITIALIZEPAGE, + "WlanWizardPageSsid::initializePage" ); + + if (mWidget == NULL) { + bool ok; + + mLoader = new HbDocumentLoader(mWizard->mainWindow()); + + mLoader->load(":/docml/occ_add_wlan_01_04.docml", &ok); + Q_ASSERT_X(ok, "WlanWizardPageSsid", "Invalid docml file"); + + // Load orientation + loadDocml(mWizard->mainWindow()->orientation()); + + // Load widgets + mWidget = qobject_cast (mLoader->findWidget( + "occ_add_wlan_01")); + Q_ASSERT_X(mWidget != NULL, "WlanWizardPageSsid", "View not found"); + + mLabel = qobject_cast (mLoader->findWidget("dialog")); + Q_ASSERT_X(mLabel != NULL, "WlanWizardPageSsid", "dialog not found"); + + mSsid = qobject_cast (mLoader->findWidget("lineEditKey")); + Q_ASSERT_X(mSsid != NULL, "WlanWizardPageSsid", "lineEditKey not found"); + + mLabelError = qobject_cast (mLoader->findWidget( + "labelErrorNote")); + Q_ASSERT_X(mLabelError != NULL, "WlanWizardPageSsid", + "labelErrorNote not found"); + + mLabel->setPlainText(hbTrId( + "txt_occ_dialog_insert_the_name_of_the_new_wlan_net")); + + // Connect orientation signal from the main window to orientation + // loader. + ok &= connect(mWizard->mainWindow(), + SIGNAL(orientationChanged(Qt::Orientation)), this, + SLOT(loadDocml(Qt::Orientation))); + + // Connect text change-signal from input dialog to handler function + ok &= connect(mSsid, SIGNAL(textChanged(const QString &)), this, + SLOT(textChanged(const QString &))); + + Q_ASSERT(ok); + + HbEditorInterface editInterface(mSsid); + editInterface.setInputConstraints(HbEditorConstraintLatinAlphabetOnly); + + + editInterface.setSmileyTheme(HbSmileyTheme()); + //editInterface.setEditorClass(HbInputEditorClassNetworkName); + mSsid->setInputMethodHints( + Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase); + mSsid->setMaxLength(WlanWizardUtils::SsidMaxLength); + mSsid->installEventFilter(this); + } + + // Open virtual keyboard by setting focus to line edit + mSsid->setFocus(); + + return mWidget; +} + +/*! + * Selection of the next page. + */ +int WlanWizardPageSsid::nextId(bool &removeFromStack) const +{ + int pageId = WlanWizardPage::PageNone; + removeFromStack = false; + + WlanWizardUtils::SsidStatus status = WlanWizardUtils::validateSsid( + mSsid->text()); + + if (status != WlanWizardUtils::SsidStatusOk) { + mLabelError->setPlainText(SsidStatusToErrorString(status)); + } + else { + // SSID is stored into configuration + mWizard->setConfiguration(WlanWizardPrivate::ConfSsid, mSsid->text()); + pageId = WlanWizardPageInternal::PageScanning; + } + + return pageId; +} + +/*! + * Load the document with given screen orientation. + */ +void WlanWizardPageSsid::loadDocml(Qt::Orientation orientation) +{ + OstTrace1( TRACE_FLOW, WLANWIZARDPAGESSID_LOADDOCML, + "WlanWizardPageSsid::loadDocml - orientation ;orientation=%x", + ( TUint )( orientation ) ); + + bool ok; + // Then load the orientation specific section + if (orientation == Qt::Horizontal) { + qDebug("Loading landscape section for wlan_01_04"); + mLoader->load(":/docml/occ_add_wlan_01_04.docml", "landscape_section", + &ok); + Q_ASSERT(ok); + } + else { + Q_ASSERT(orientation == Qt::Vertical); + qDebug("Loading portrait section for wlan_01_04"); + mLoader->load(":/docml/occ_add_wlan_01_04.docml", "portrait_section", + &ok); + Q_ASSERT(ok); + } +} + +/*! + * Actions, when user makes changes to the text editor widget. + */ +void WlanWizardPageSsid::textChanged(const QString & /* text */) +{ + OstTrace0( TRACE_FLOW, WLANWIZARDPAGESSID_TEXTCHANGED, + "WlanWizardPageSsid::textChanged in text edit widget" ); + + mWizard->enableNextButton(showPage()); +} + +/*! + * Returns true, if the text editor widget contains any characters. + */ +bool WlanWizardPageSsid::showPage() +{ + // Initiate the scanning of public APs here. + mWizard->wlanQtUtils()->scanWlanAps(); + + return !(mSsid->text().isEmpty()); +} + +/*! + * Filter to catch focus event to the text editor widget. + */ +bool WlanWizardPageSsid::eventFilter(QObject *obj, QEvent *event) +{ + if (obj == mSsid && event->type() == QEvent::FocusIn) { + OstTrace0( TRACE_BORDER, WLANWIZARDPAGESSID_EVENTFILTER, + "WlanWizardPageSsid::eventFilter text edit widget received focus" ); + + mLabelError->setPlainText(""); + } + return false; +} + +/*! + * Conversion function from SsidStatus to plain text. + */ +QString WlanWizardPageSsid::SsidStatusToErrorString( + WlanWizardUtils::SsidStatus status) const +{ + QString errorString; + switch (status) { + case WlanWizardUtils::SsidStatusIllegalCharacters: + errorString = hbTrId( + "txt_occ_dialog_illegal_characters_in_key_please_c"); + break; + case WlanWizardUtils::SsidStatusInvalidLength: + errorString + = hbTrId("txt_occ_dialog_key_is_of_incorrect_length_please"); + break; + case WlanWizardUtils::SsidStatusOk: + default: + Q_ASSERT(WlanWizardUtils::SsidStatusOk == status); + break; + } + return errorString; +} + diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/src/wlanwizardpagesummary.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/src/wlanwizardpagesummary.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,293 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * Wlan Wizard Page: Summary + * + */ + +// System includes +#include +#include +#include +#include +#include +#include + +// User includes +#ifdef ICT_RESULT_ENUM +#include "wlanqtutilscommon.h" +#endif +#include "wlanwizard_p.h" +#include "wlanwizardplugin.h" +#include "wlanwizardsummaryviewitem.h" +#include "wlanwizardpagesummary.h" + +/*! + \class WlanWizardPageSummary + \brief Implements Wizard summary page. + */ + +// External function prototypes + +// Local constants + +//! Path for layout of custom list widget +static const char WlanWizardPageSummaryLayout[] = ":/wizardsummarylayout/"; + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +/*! + Constructor. + + @param [in] parent pointer to private implementation of wizard. + */ +WlanWizardPageSummary::WlanWizardPageSummary(WlanWizardPrivate* parent) : + WlanWizardPageInternal(parent), + mListWidget(NULL) +{ +} + +/*! + Destructor. + */ +WlanWizardPageSummary::~WlanWizardPageSummary() +{ + HbStyleLoader::unregisterFilePath(WlanWizardPageSummaryLayout); + + // Wizard framework deletes the visualization (owns mListWidget). +} + +/*! + See WlanWizardPage::initializePage() + */ +HbWidget* WlanWizardPageSummary::initializePage() +{ + // Note that from summary page it is not possible to step back + // this means that it is not possible that this method is called twice. + Q_ASSERT(!mListWidget); + + loadDocml(); + int row = 0; + + appendToList( + row, + hbTrId("txt_occ_dblist_network_name"), + mWizard->configuration(WlanWizardPrivate::ConfSsid).toString()); + + appendToList( + row, hbTrId("txt_occ_dblist_network_mode"), networkModeText()); + + appendToList( + row, hbTrId("txt_occ_dblist_security_mode"), securityModeText()); + + addDynamicItems(row); + + return qobject_cast(mListWidget); +} + +/*! + See WlanWizardPage::nextId() + + @note this method is never called, because 'Next' toolbar button is not + visible in summary page. + + @param [out] removeFromStack return value is always false + + @return WlanWizardPageInternal::PageNone + */ +int WlanWizardPageSummary::nextId(bool &removeFromStack) const +{ + removeFromStack = false; + return WlanWizardPage::PageNone; +} + +/*! + Loads docml. + */ +void WlanWizardPageSummary::loadDocml() +{ + bool ok; + HbDocumentLoader docLoader(mWizard->mainWindow()); + + docLoader.load(":/docml/occ_add_wlan_05.docml", &ok); + Q_ASSERT(ok); + + mListWidget = qobject_cast(docLoader.findWidget("occ_add_wlan_05")); + Q_ASSERT(mListWidget != NULL); + + // Set own list prototype handler to disable TAP gestures and selections + mListWidget->setItemPrototype( + new WlanWizardSummaryListViewItem(mListWidget)); + + // set the layout name to match the layout name in hblistviewitem.css file + mListWidget->setLayoutName("wlanwizardsummaryitem"); + + // Register the location of hblistviewitem.css and hblistviewitem.widgetml + ok = HbStyleLoader::registerFilePath(WlanWizardPageSummaryLayout); + Q_ASSERT(ok); +} + +/*! + Gets localized network mode from the WlanWizardPrivate::ConfNetworkMode + configuration. + + @return localized network mode text. + */ +QString WlanWizardPageSummary::networkModeText() const +{ + QString ret; + int mode = mWizard->configuration( + WlanWizardPrivate::ConfNetworkMode).toInt(); + + switch (mode) { + case CMManagerShim::Adhoc: + ret = hbTrId("txt_occ_dblist_network_mode_val_adhoc"); + break; + + case CMManagerShim::Infra: + default: + Q_ASSERT(mode == CMManagerShim::Infra); + if (mWizard->configuration(WlanWizardPrivate::ConfHiddenWlan).toBool()) { + ret = hbTrId("txt_occ_dblist_network_mode_val_infrastructure_hi"); + } else { + ret = hbTrId("txt_occ_dblist_network_mode_val_infrastructure_pu"); + } + break; + } + return ret; +} + +/*! + Gets localized security mode from the WlanWizardPrivate::ConfSecurityMode + configuration. + + @return localized security mode text. + */ +QString WlanWizardPageSummary::securityModeText() const +{ + QString ret; + int mode = mWizard->configuration(WlanWizardPrivate::ConfSecurityMode).toInt(); + switch (mode) { + case CMManagerShim::WlanSecMode802_1x: + ret = hbTrId("txt_occ_dblist_security_mode_val_8021x"); + break; + + case CMManagerShim::WlanSecModeWep: + ret = hbTrId("txt_occ_dblist_security_mode_val_wep"); + break; + + case CMManagerShim::WlanSecModeWpa: + if (mWizard->configuration(WlanWizardPrivate::ConfUsePsk).toBool()) { + ret = hbTrId("txt_occ_dblist_security_mode_val_wpawpa2psk"); + } else { + ret = hbTrId("txt_occ_dblist_security_mode_val_wpawpa2_with_eap"); + } + break; + + case CMManagerShim::WlanSecModeWpa2: + if (mWizard->configuration(WlanWizardPrivate::ConfUsePsk).toBool()) { + ret = hbTrId("txt_occ_dblist_security_mode_val_wpa2_with_passwor"); + } else { + ret = hbTrId("txt_occ_dblist_security_mode_val_wpa2_with_eap"); + } + break; + + case CMManagerShim::WlanSecModeOpen: + default: + Q_ASSERT(mode == CMManagerShim::WlanSecModeOpen); + ret = hbTrId("txt_occ_dblist_security_mode_val_open"); + break; + } + return ret; +} + +/*! + Adds dynamic content to the view. + + @param [in,out] row row to where insert happens. + */ +void WlanWizardPageSummary::addDynamicItems(int &row) +{ + if (mWizard->isEapEnabled()) { + appendToListPluginInfo(WlanWizardPlugin::SummaryEapOuterType, row); + appendToListPluginInfo(WlanWizardPlugin::SummaryEapInnerType, row); + appendToListPluginInfo(WlanWizardPlugin::SummaryEapFastProvisioningMode, row); + } + + // TODO: Hotspot: no need to show destination.. + QString value; +#ifdef ICT_RESULT_ENUM + switch (mWizard->configuration(WlanWizardPrivate::ConfIctStatus).toInt()) { + case IctsPassed: + value = hbTrId("txt_occ_dblist_destination_val_internet"); + appendToList(row, hbTrId("txt_occ_dblist_destination"), value); + break; + case IctsHotspotPassed: + // Add nothing to list. + break; + case IctsCanceled: + // TODO: Next page: gereric error page. movement should be done from processsettings page not here. + break; + case IctsFailed: + default: + value = hbTrId("txt_occ_dblist_destination_val_uncategorized"); + appendToList(row, hbTrId("txt_occ_dblist_destination"), value); + } +#else + if (mWizard->configuration(WlanWizardPrivate::ConfIctStatus).toBool()) { + value = hbTrId("txt_occ_dblist_destination_val_internet"); + } else { + value = hbTrId("txt_occ_dblist_destination_val_uncategorized"); + } + appendToList(row, hbTrId("txt_occ_dblist_destination"), value); +#endif +} + +/*! + Appends new item to the end of the summary list + + @param [in,out] row number to where the item is inserted + @param [in] title title of the item + @param [in] value value of the item + */ +void WlanWizardPageSummary::appendToList( + int &row, + const QString title, + const QString value) +{ + HbListWidgetItem *item = new HbListWidgetItem(); + item->setText(title); + item->setSecondaryText(value); + mListWidget->insertItem(row++, item); +} + +/*! + Appends new item to the end of the summary list + + @param [in] id Plugin summary id + @param [in,out] row number to where the item is inserted + */ +void WlanWizardPageSummary::appendToListPluginInfo( + WlanWizardPlugin::Summary id, int &row ) +{ + QString title; + QString value; + WlanWizardPlugin *plugin = mWizard->wlanWizardPlugin(); + Q_ASSERT(plugin); + if (plugin->summary(id, title, value)) { + appendToList(row, title, value ); + } +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/src/wlanwizardsummaryviewitem.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/src/wlanwizardsummaryviewitem.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,82 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * Wlan Wizard Page: Summary: List view item + * + */ + +// System includes + +// User includes + +#include "wlanwizardsummaryviewitem.h" + +/*! + \class WlanWizardSummaryListViewItem + \brief Implements custom List view for Summary page. + + HbListWidget does not support directly views where selection is disabled. + + This implementation removes required operations to disable list selection. + */ + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// + +/*! + Constructor. + + @param [in] parent parent class + */ +WlanWizardSummaryListViewItem::WlanWizardSummaryListViewItem( + QGraphicsItem* parent) : + HbListViewItem(parent) +{ +} + +/*! + Destructor. + */ +WlanWizardSummaryListViewItem::~WlanWizardSummaryListViewItem() +{ +} + +/*! + See HbListViewItem::updateChildItems(). + + Disables selection. + */ +void WlanWizardSummaryListViewItem::updateChildItems() +{ + HbListViewItem::updateChildItems(); + + ungrabGesture(Qt::TapGesture); + + GraphicsItemFlags itemFlags = flags(); + itemFlags &= ~QGraphicsItem::ItemIsFocusable; + setFlags(itemFlags); +} + +/*! + See HbListViewItem::createItem(). + */ +HbAbstractViewItem* WlanWizardSummaryListViewItem::createItem() +{ + return new WlanWizardSummaryListViewItem(*this); +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/src/wlanwizardutils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/src/wlanwizardutils.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,262 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * WLAN Wizard Utilities + * + */ + +// System includes +#include +#include +#include + +// User includes +#include "wlanwizardutils.h" +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "wlanwizardutilsTraces.h" +#endif + +/*! + \class WlanWizardUtils wlanwizardutils.cpp + \brief Utilities for WLAN key validations. + +*/ +/*! + \enum WlanWizardUtils::KeyStatus + This enum defines the validation results. + + \var WlanWizardUtils::KeyStatusOk + Key is valid. + + \var WlanWizardUtils::KeyStatusIllegalCharacters + Key contains illegal characters. + + \var WlanWizardUtils::KeyStatusWpaTooShort + WPA key is too short. Minimum allowed length is 8. See + WlanWizardUtils::validateWpaKey(). + + \var WlanWizardUtils::KeyStatusWpaTooLong + WPA key is too long. Minimum allowed length is 64 for hex key and 63 for + ascii key. See WlanWizardUtils::validateWpaKey(). + + \var WlanWizardUtils::KeyStatusWepInvalidLength + WEP key length is not valid. Valid keys are + - hex: 10 or 26 characters + - ascii: 5 or 13 characters. See WlanWizardUtils::validateWpaKey(). + + \var WlanWizardUtils::SsidMinLength + Minumum acceptable length for SSID. + + \var WlanWizardUtils::SsidMaxLength + Maximum acceptable length for SSID. + + \var WlanWizardUtils::WpaMinLength + Minumum acceptable length for WPA key. + + \var WlanWizardUtils::WpaMaxLength + Maximum acceptable length for WPA key. + + \var WlanWizardUtils::WepHex64BitMaxLength + Length of WEP key: format hex 64-bits. + + \var WlanWizardUtils::WepHex128BitMaxLength + Length of WEP key: format hex 128-bits. + + \var WlanWizardUtils::WepAscii64BitMaxLength + Length of WEP key: format ascii 64-bits. + + \var WlanWizardUtils::WepAscii128BitMaxLength + Length of WEP key: format ascii 128-bits. + +*/ + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + + +/*! + Process WPA key validation. A passphrase can contain from 8 to 63 ASCII + characters where each character MUST have a decimal encoding in the range of + 32 to 126, inclusive. + + A preshared key is stored as 64 character hex string. + + @param [in] key PSK to be validated + + @return Following values are possible + - KeyStatusOk + - KeyStatusIllegalCharacters + - KeyStatusWpaTooShort + - KeyStatusWpaTooLong + */ +WlanWizardUtils::KeyStatus WlanWizardUtils::validateWpaKey(const QString &key) +{ +#ifdef OST_TRACE_COMPILER_IN_USE + TPtrC tmp(key.utf16(),key.length() ); + OstTraceExt1( TRACE_NORMAL, WLANWIZARDUTILS_VALIDATEWPAKEY, + "WlanWizardUtils::validateWpaKey;key=%S", tmp ); +#endif + + int length = key.length(); + KeyStatus ret = KeyStatusOk; + + if (length < WpaMinLength) { + ret = KeyStatusWpaTooShort; + } else if (length > WpaMaxLength) { + ret = KeyStatusWpaTooLong; + } else if (length == WpaMaxLength) { + ret = isHex(key); + } else { + ret = isAscii(key); + } + + OstTrace1( + TRACE_NORMAL, WLANWIZARDUTILS_VALIDATEWPAKEY_RETURN, + "WlanWizardUtils::validateWpaKey - Return;ret=%{KeyStatus}", ret ); + + return ret; +} + +/*! + Process WEP key validation. Following keys are allowed: + + HEX: + - 64 bit: allowed key length = 10 + - 128 bit: allowed key length = 26 + + ASCII: + - 64 bit: allowed key length = 5 + - 128 bit: allowed key length = 13 + + @param [in] key WEP Key to be validated + + @return Following values are possible + - KeyStatusOk + - KeyStatusIllegalCharacters + - KeyStatusWepInvalidLength + */ +WlanWizardUtils::KeyStatus WlanWizardUtils::validateWepKey(const QString &key) +{ +#ifdef OST_TRACE_COMPILER_IN_USE + TPtrC tmp(key.utf16(),key.length() ); + OstTraceExt1( TRACE_NORMAL, WLANWIZARDUTILS_VALIDATEWEPKEY, + "WlanWizardUtils::validateWepKey;key=%S", tmp ); +#endif + + int length = key.length(); + KeyStatus ret = KeyStatusOk; + + if (length == WepHex64BitMaxLength || length == WepHex128BitMaxLength) { + ret = isHex(key); + } else if (length == WepAscii64BitMaxLength || length == WepAscii128BitMaxLength) { + ret = isAscii(key); + } else { + ret = KeyStatusWepInvalidLength; + } + + OstTrace1( + TRACE_NORMAL, WLANWIZARDUTILS_VALIDATEWEPKEY_RETURN, + "WlanWizardUtils::validateWepKey - Return;ret=%{KeyStatus}", ret ); + + return ret; +} + +/*! + Process Ascii validation. Allowed characters are from 32 to 126. + + @param [in] key to be validated. + + @return Following values are possible + - KeyStatusOk + - KeyStatusIllegalCharacters + */ +WlanWizardUtils::KeyStatus WlanWizardUtils::isAscii(const QString &key) +{ + static const QChar ch32(32); // First visible ascii character + static const QChar ch126(126); // Last visible ascii character + + const QChar *data = key.data(); + while (!data->isNull()) { + if ((*data) < ch32 || (*data) > ch126) { + return KeyStatusIllegalCharacters; + } + ++data; + } + return KeyStatusOk; +} + +/*! + Process Hex validation. Allowed characters are + - from 0 to 9 + - from a to f + - from A to F + + @param [in] key to be validated. + + @return Following values are possible + - KeyStatusOk + - KeyStatusIllegalCharacters + */ +WlanWizardUtils::KeyStatus WlanWizardUtils::isHex(const QString &key) +{ + static const QChar ch_A(65); // Character: A + static const QChar ch_F(70); // Character: F + static const QChar ch_a(97); // Character: a + static const QChar ch_f(102);// Character: f + + const QChar *data = key.data(); + while (!data->isNull()) { + if (data->isDigit() || + (*data) >= ch_a && (*data) <= ch_f || + (*data) >= ch_A && (*data) <= ch_F) { + ++data; + } else { + return KeyStatusIllegalCharacters; + } + } + return KeyStatusOk; +} + +/*! + Process SSID validation. + + @param [in] ssid to be validated. + + @return Following values are possible + - SsidStatusOk + - SsidStatusInvalidLength + */ +WlanWizardUtils::SsidStatus WlanWizardUtils::validateSsid(const QString &ssid) +{ + TPtrC tmp(ssid.utf16(), ssid.length() ); + OstTraceExt1( TRACE_NORMAL, WLANWIZARDUTILS_VALIDATESSID, + "WlanWizardUtils::validateSsid;ssid=%S", tmp ); + + SsidStatus ret = SsidStatusOk; + + int len = ssid.length(); + if (len < SsidMinLength || len > SsidMaxLength) { + ret = SsidStatusInvalidLength; + } + OstTrace1( + TRACE_NORMAL, WLANWIZARDUTILS_VALIDATESSID_RETURN, + "WlanWizardUtils::validateSsid - Return;ret=%{SsidStatus}", ret ); + return ret; +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/t_wlanwizard/run_wst.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/t_wlanwizard/run_wst.bat Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,151 @@ +::============================================================================= +:: Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +:: All rights reserved. +:: This component and the accompanying materials are made available +:: 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". +:: +:: Initial Contributors: +:: Nokia Corporation - initial contribution. +:: +:: Contributors: +:: +:: Description: +:: +::============================================================================= + +:: Script(s) uses following environment settings: +:: - CD +:: - DATE +:: - TIME +:: - TEMP + + +::----------------------------------------------------------------------------- +:: Do the preparations: +:: - Don't show the commands +:: - Use local parameters -- don't pollute the global one +:: - Dim the lights for time of script execution +:: - Store the current working directory +::----------------------------------------------------------------------------- + +@echo off +:: echo *** RUN_WST: START: +setlocal +color 08 +pushd . +if not exist run_wst.bat goto INVALID_DIR + + +::----------------------------------------------------------------------------- +:: Set the local variables +::----------------------------------------------------------------------------- + +::echo *** RUN_WST: SET VARIABLES: +set wst_root_dir=%cd% +set wst_log_dir=%wst_root_dir%\wst_log +set wst_report_dir=%wst_root_dir%\wst_report +set log_file=%wst_log_dir%\wst_log.txt +set build_script=%wst_root_dir%\wst_script\wst_make.bat + +::----------------------------------------------------------------------------- +:: Check that script exists +::----------------------------------------------------------------------------- + +::echo *** RUN_WST: SOME CHECKS: +if not exist %build_script% goto INVALID_DIR +:: Create output directory if it does not exist +if not exist %wst_log_dir% mkdir %wst_log_dir% +if not exist %wst_report_dir% mkdir %wst_report_dir% +:: Create log file +echo *** WST_LOG: BEGIN *** > %log_file% + + +::----------------------------------------------------------------------------- +:: Check parameters +::----------------------------------------------------------------------------- + +set command=ERROR +if [%1]==[] set command=CLEAN_OLD_FILES COMPILE_TEST_CASES RUN_TEST_CASES GENERATE_REPORTS SHOW_RESULTS +if [%1]==[CLEAN_OLD] set command=CLEAN_OLD_FILES +if [%1]==[CASES] set command=COMPILE_TEST_CASES +if [%1]==[RUN] set command=RUN_TEST_CASES +if [%1]==[REPORTS] set command=GENERATE_REPORTS +if [%1]==[RESULTS] set command=SHOW_RESULTS +if [%1]==[BROWSE] set command=START_BROWSER +if [%1]==[/?] goto HELP +if [%1]==[HELP] goto HELP +if [%1]==[/h] goto HELP +if [%1]==[-h] goto HELP + +::----------------------------------------------------------------------------- +:PARSE_COMMANDS +::----------------------------------------------------------------------------- + +:: echo *** RUN_WST: COMMAND: %command% +:: echo *** RUN_WST: CALL SCRIPT: +for %%i IN ( %command% ) DO ( + call %build_script% %wst_root_dir% wst_log.txt %%i + for /f "tokens=3 delims= " %%x in ('find /C " Error " %log_file%') do ( + if not [%%x]==[0] goto ERROR + ) +) + +goto THE_END + + +::----------------------------------------------------------------------------- +:INVALID_DIR +::----------------------------------------------------------------------------- + +echo *** RUN_WST: INVALID DIR: +echo *** Test script sub-script not found! +echo *** Please be sure to run the script in same directory, +echo *** i.e. .\run_wst.bat , and NOT .\wst\run_wst.bat + +goto THE_END + + +::----------------------------------------------------------------------------- +:ERROR +::----------------------------------------------------------------------------- + +echo *** RUN_WST: ERROR: +color 48 +echo Error in compilation: +findstr /C:" Error " < %log_file% +echo. +Echo Quitting WST. + +goto THE_END + + +::----------------------------------------------------------------------------- +:HELP +::----------------------------------------------------------------------------- + +echo *** RUN_WST: HELP: +echo Run Wlan Qt Utilities Workstation Testing +echo. +echo RUN_WST [param] +echo. +echo param +echo [none] - Do all, from CLEAN_OLD to RESULTS +echo. +echo CLEAN_OLD - Clean metrics and other generated files +echo CASES - Build only Tester components +echo RUN - Run Tester +echo REPORTS - Generate reports +echo RESULTS - Show results +echo BROWSE - Start browser +echo. + + +::----------------------------------------------------------------------------- +:THE_END +::----------------------------------------------------------------------------- + +echo *** RUN_WST: Completed: +color +popd diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/t_wlanwizard/stubs/context_wlanqtutils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/t_wlanwizard/stubs/context_wlanqtutils.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,102 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +*/ + + +#include "context_wlanqtutils.h" +#include "wlanqtutils.h" +#include "wlanqtutilsap.h" + +WlanQtUtilsContext::WlanQtUtilsContext(WlanQtUtils *utils ) +: mUtils(utils) +{ + + +} + +WlanQtUtilsContext::~WlanQtUtilsContext() +{ + +} + +void WlanQtUtilsContext::setScanWlanApsResult( + QList > result ) +{ + mUtils->mScanWlanAps = result; +} + +void WlanQtUtilsContext::setScanWlanDirectResult( QString ssid, + QList > result ) +{ + mUtils->mScanWlanDirectSsid = ssid; + mUtils->mScanWlanDirect = result; +} + +void WlanQtUtilsContext::setCreateWlanIapResult(int iapId) +{ + mUtils->mCreateWlanIapReturn = iapId; +} + +void WlanQtUtilsContext::setUpdateWlanIapResult(bool returnValue) +{ + mUtils->mUpdateWlanIapReturn = returnValue; +} + +void WlanQtUtilsContext::setConnectionSuccessed(bool value) +{ + mUtils->mConnectionSuccess = value; +} + +void WlanQtUtilsContext::setSignalWlanNetworkOpened(int iapId) +{ + mUtils->mWlanNetworkOpenedIapId = iapId; +} + +void WlanQtUtilsContext::setSignalWlanNetworkClosed(int iapId, int reason) +{ + mUtils->mWlanNetworkClosedIapId = iapId; + mUtils->mWlanNetworkClosedReason = (bool)reason; +} +#ifdef ICT_RESULT_ENUM +void WlanQtUtilsContext::setSignalIctResult(int iapId, WlanLoginIctsResultType result) +#else +void WlanQtUtilsContext::setSignalIctResult(int iapId, bool result) +#endif +{ + mUtils->mIctResultIapId = iapId; + mUtils->mIctResultResults = result; +} + +QStringList WlanQtUtilsContext::calledMethods() +{ + QStringList methods = mUtils->mCalledMethods; + mUtils->mCalledMethods.clear(); + return methods; +} + +bool WlanQtUtilsContext::verifyWlanIapSettings(WlanQtUtilsAp &ref) +{ + bool ret = true; + if (!mUtils->mWlanAp){ + qWarning("WlanQtUtilsContext::verifyWlanIapSettings: iap not created"); + ret = false; + } + + if (!(*(mUtils->mWlanAp) == ref)){ + qWarning("WlanQtUtilsContext::verifyWlanIapSettings: settings does not match"); + ret = false; + } + return ret; +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/t_wlanwizard/stubs/context_wlanqtutils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/t_wlanwizard/stubs/context_wlanqtutils.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +*/ + +#ifndef CONTROL_WLANQTUTILS_H +#define CONTROL_WLANQTUTILS_H + +#include +#include + +#include "wlanqtutilscommon.h" + +class WlanQtUtils; +class WlanQtUtilsWlanIap; +class WlanQtUtilsAp; + +class Q_DECL_EXPORT WlanQtUtilsContext: public QObject +{ + Q_OBJECT + +public: + WlanQtUtilsContext(WlanQtUtils *utils ); + ~WlanQtUtilsContext(); + +public: + void setScanWlanApsResult( QList > result ); + + void setScanWlanDirectResult( QString ssid, + QList > result ); + + void setCreateWlanIapResult(int iapId); + + void setUpdateWlanIapResult(bool returnValue); + + void setConnectionSuccessed(bool value); + + void setSignalWlanNetworkOpened(int iapId); + + void setSignalWlanNetworkClosed(int iapId, int reason); + +#ifdef ICT_RESULT_ENUM + void setSignalIctResult(int iapId, WlanLoginIctsResultType result); +#else + void setSignalIctResult(int iapId, bool result); +#endif + + QStringList calledMethods(); + + bool verifyWlanIapSettings(WlanQtUtilsAp &ref); + +private: + WlanQtUtils* mUtils; +}; + +#endif /* CONTROL_WLANQTUTILS_H */ + +// End of File diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/t_wlanwizard/stubs/stub_wlanqtutils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/t_wlanwizard/stubs/stub_wlanqtutils.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * 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". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + */ + +#include "wlanqtutilsap.h" +#include "wlanqtutils.h" +#include + +WlanQtUtils::WlanQtUtils() : mWlanAp(NULL) +{ + mWlanNetworkActiveIapId = -1; + mCalledMethods.append("WlanQtUtils"); +} + +WlanQtUtils::~WlanQtUtils() +{ + mCalledMethods.append("~WlanQtUtils"); + delete mWlanAp; +} + +void WlanQtUtils::availableWlanAps(QList > &wlanApList) +{ + wlanApList = *mScanResult; + mCalledMethods.append("availableWlanAps"); +} + +int WlanQtUtils::createIap(const WlanQtUtilsAp * wlanAp) +{ + mCalledMethods.append("createIap"); + delete mWlanAp; + mWlanAp = new WlanQtUtilsAp(*wlanAp); + return mCreateWlanIapReturn; +} + +bool WlanQtUtils::updateIap(int iapId, const WlanQtUtilsAp * wlanAp) +{ + mCalledMethods.append("updateIap"); + qDebug("updateWlanIap iapId = %d", iapId); + qDebug("mCreateWlanIapReturn = %d", mCreateWlanIapReturn); + delete mWlanAp; + mWlanAp = new WlanQtUtilsAp(*wlanAp); + QCOMPARE(iapId, mCreateWlanIapReturn); + return mUpdateWlanIapReturn; +} + +void WlanQtUtils::deleteIap(int iapId) +{ + mCalledMethods.append("deleteIap"); + QCOMPARE(iapId, mCreateWlanIapReturn); +} + +int WlanQtUtils::connectedWlanId() +{ + mCalledMethods.append("connectedWlanId"); + return mCreateWlanIapReturn; +} + +void WlanQtUtils::connectIap(int iapId, bool runIct) +{ + qDebug("connectIap iapId = %d", iapId); + qDebug("mCreateWlanIapReturn = %d", mCreateWlanIapReturn); + mCalledMethods.append("connectIap"); + QCOMPARE(iapId, mCreateWlanIapReturn); + QCOMPARE(runIct, true); + + if (mConnectionSuccess) { + mWlanNetworkActiveIapId = iapId; + emit wlanNetworkOpened(mWlanNetworkOpenedIapId); + emit ictResult(mIctResultIapId, mIctResultResults); + } else { + emit wlanNetworkClosed( + mWlanNetworkClosedIapId, + mWlanNetworkClosedReason ); + } +} + +void WlanQtUtils::disconnectIap(int iapId) +{ + qDebug("disconnectIap iapId = %d", iapId); + qDebug("mCreateWlanIapReturn = %d", mCreateWlanIapReturn); + mCalledMethods.append("disconnectIap"); + QCOMPARE(iapId, mCreateWlanIapReturn); +} + +int WlanQtUtils::activeIap() +{ + mCalledMethods.append("activeIap"); + return mCreateWlanIapReturn; +} + +void WlanQtUtils::scanWlanAps() +{ + mCalledMethods.append("scanWlanAps"); + mScanResult = &mScanWlanAps; + + emit wlanScanApReady(); +} + +void WlanQtUtils::scanWlanDirect(const QString &ssid) +{ + mCalledMethods.append("scanWlanDirect"); + QCOMPARE(ssid, mScanWlanDirectSsid); + mScanResult = &mScanWlanDirect; + + emit wlanScanDirectReady(); +} + +void WlanQtUtils::stopWlanScan() +{ + mCalledMethods.append("stopWlanScan"); +} + diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/t_wlanwizard/stubs/stub_wlanqtutilsap.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/t_wlanwizard/stubs/stub_wlanqtutilsap.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * 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". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * This is the source file for WlanQtUtilsAp class. + */ + +#include +#include +#include +#include +#include "wlanqtutilscommon.h" +#include "wlanqtutilsap.h" + +class WlanQtUtilsApPrivate +{ + friend class WlanQtUtilsAp; + +private: + QHash mConfigurations; +}; + +WlanQtUtilsAp::WlanQtUtilsAp() : + d_ptr(new WlanQtUtilsApPrivate()) +{ +} + +WlanQtUtilsAp::WlanQtUtilsAp(const WlanQtUtilsAp &ref) : + d_ptr(new WlanQtUtilsApPrivate()) +{ + d_ptr->mConfigurations = ref.d_ptr->mConfigurations; +} + +WlanQtUtilsAp::~WlanQtUtilsAp() +{ + d_ptr->mConfigurations.clear(); + delete d_ptr; +} + +QVariant WlanQtUtilsAp::value(int identifier) const +{ + return d_ptr->mConfigurations[identifier]; +} + +void WlanQtUtilsAp::setValue(int identifier, QVariant value) +{ + d_ptr->mConfigurations[identifier] = value; +} + +bool WlanQtUtilsAp::operator==(const WlanQtUtilsAp & rhs ) const +{ + bool ret = true; + if (d_ptr->mConfigurations.size() != rhs.d_ptr->mConfigurations.size()) { + qWarning("WlanQtUtilsAp::operator==(): size: expect %d, actual %d ", + d_ptr->mConfigurations.size(), + rhs.d_ptr->mConfigurations.size() ); + ret = false; + } + QHashIterator i(d_ptr->mConfigurations); + + while (i.hasNext()) { + i.next(); + if (!rhs.d_ptr->mConfigurations.contains(i.key())){ + qWarning("WlanQtUtilsAp::operator==(): key not found: %d", i.key()); + ret = false; + + } + if (i.value() != rhs.d_ptr->mConfigurations[i.key()]){ + qWarning("WlanQtUtilsAp::operator==(): values not match"); + qDebug() << "Expect: " << i.value(); + qDebug() << "Actual: " << i.value(); + ret = false; + } + } + return ret; +} + + diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/t_wlanwizard/stubs/stubs.pri --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/t_wlanwizard/stubs/stubs.pri Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,30 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# 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". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# +# Description: +# Stubs for Wlan wizard testing +# + +DEFINES += BUILD_WLANQTUTILITIES_DLL + +HEADERS += \ + stubs/wlanqtutils.h \ + stubs/wlanqtutilscommon.h \ + stubs/wlanqtutilsap.h \ + stubs/context_wlanqtutils.h + +SOURCES += \ + stubs/stub_wlanqtutils.cpp \ + stubs/stub_wlanqtutilsap.cpp \ + stubs/context_wlanqtutils.cpp diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/t_wlanwizard/stubs/wlanqtutils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/t_wlanwizard/stubs/wlanqtutils.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,110 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +*/ + +#ifndef STUB_WLANQTUTILS_H +#define STUB_WLANQTUTILS_H + +#include +#include +#include +#include + +#include "wlanqtutilscommon.h" +#include "wlanqtutilsap.h" + +class WlanQtUtilsIap; +class WlanQtUtilsWlanIap; + +class WLANQTUTILITIESDLL_EXPORT WlanQtUtils : public QObject +{ + Q_OBJECT + friend class WlanQtUtilsContext; +public: + //! "None" IAP ID value (e.g. for "not found" cases) + static const int IapIdNone = -1; + +public: + WlanQtUtils(); + + ~WlanQtUtils(); + + void availableWlanAps( QList > &wlanApList); + + int createIap(const WlanQtUtilsAp *wlanAp); + + bool updateIap(int iapId, const WlanQtUtilsAp *wlanAp); + + void deleteIap(int iapId); + + void connectIap(int iapId, bool runIct = false); + + int connectedWlanId(); + + void disconnectIap(int iapId); + + int activeIap(); + + void scanWlanAps(); + + void scanWlanDirect(const QString &ssid); + + void stopWlanScan(); + +signals: + + void wlanScanApReady(); + + void wlanScanDirectReady(); + + void wlanNetworkOpened(int iapId); + + void wlanNetworkClosed(int iapId, int reason); + +#ifdef ICT_RESULT_ENUM + void ictResult(int iapId, WlanLoginIctsResultType result); +#else + void ictResult(int iapId, bool result); +#endif + +private: // Return values for all methods. + QList > mScanWlanAps; + QList > mScanWlanDirect; + QList > *mScanResult; + QString mScanWlanDirectSsid; + int mCreateWlanIapReturn; + bool mUpdateWlanIapReturn; + + int mWlanNetworkOpenedIapId; + int mWlanNetworkActiveIapId; + int mWlanNetworkClosedIapId; + bool mWlanNetworkClosedReason; + + int mIctResultIapId; +#ifdef ICT_RESULT_ENUM + WlanLoginIctsResultType mIctResultResults; +#else + bool mIctResultResults; +#endif + bool mConnectionSuccess; + + QStringList mCalledMethods; + + WlanQtUtilsAp *mWlanAp; +}; + +#endif /* WLANQTUTILS_H */ + +// End of File diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/t_wlanwizard/stubs/wlanqtutilsap.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/t_wlanwizard/stubs/wlanqtutilsap.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,124 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* This is the header file for WlanQtUtilsWlanAp class. +*/ + +#ifndef STUB_WLANQTUTILSWLANAP_H +#define STUB_WLANQTUTILSWLANAP_H + +#include +#include +#include +#include "cmmanagerdefines_shim.h" + +class QString; +class WlanQtUtilsApPrivate; + +/** + * This class represents WLAN access point (AP). + */ +class WlanQtUtilsAp : public QObject +{ +public: + /*! + * Scan Results: + * - ConfIdSsid + * - ConfIdBssid + * - ConfIdSignalStrength + * - ConfIdConnectionMode + * - ConfIdSecurityMode + * - ConfIdWpaPskUse + * - ConfIdWpsSupported + * + * IAP creation and updates: + * Mandatory for all security modes: + * - ConfIdSsid + * - ConfIdConnectionMode + * - ConfIdSecurityMode + * - ConfIdHidden + * + * Open: No extra configurations. + * 802.1x: No extra configurations. + * + * WEP: + * - ConfIdWepKey1 + * - ConfIdWepKey2 + * - ConfIdWepKey3 + * - ConfIdWepKey4 + * - ConfIdWepDefaultIndex + * + * WPA/WPA2: + * - ConfIdWpaPskUse + * - ConfIdWpaPsk + * + */ + enum ConfId{ + /// int: IAP ID, -1 for invalid IAP (WlanQtUtilsInvalidIapId) + ConfIdIapId, + /// QString: WLAN Network Name (SSID) + ConfIdSsid, + /// QString: Basic Service Set Identifier + ConfIdBssid, + /// int: signal strength in RSSI (dBm) + ConfIdSignalStrength, + /// int: (CMManagerShim::WlanNetMode) + ConfIdConnectionMode, + /// int: (CMManagerShim::WlanSecMode) + ConfIdSecurityMode, + /// bool: true - WPA PSK, false - WPA EAP + ConfIdWpaPskUse, + /// QString: Pre-Shared Key for WPA + /// Length: 8-63 - Ascii key + /// Length: 64 - Hex key + ConfIdWpaPsk, + /// QString: WEP Key for index 1: + /// HEX: + /// - 64 bit: allowed key length = 10 + /// - 128 bit: allowed key length = 26 + /// + /// ASCII: + /// - 64 bit: allowed key length = 5 + /// - 128 bit: allowed key length = 13 + ConfIdWepKey1, + /// QString: WEP Key for index 2 + ConfIdWepKey2, + /// QString: WEP Key for index 3 + ConfIdWepKey3, + /// QString: WEP Key for index 4 + ConfIdWepKey4, + /// int: (CMManagerShim::WlanWepKeyIndex): Default WEP Key index + ConfIdWepDefaultIndex, + /// bool: Is WLAN Hidden: true - hidden, false - not hidden. + ConfIdHidden, + /// bool: true - Wifi Protected setup is supported, false - not + ConfIdWpsSupported, + }; + +public: + WlanQtUtilsAp(); + WlanQtUtilsAp(const WlanQtUtilsAp &ref); + ~WlanQtUtilsAp(); + QVariant value(int identifier) const; + void setValue(int identifier, QVariant value ); + bool operator==(const WlanQtUtilsAp & rhs ) const; + +private: + WlanQtUtilsApPrivate *d_ptr; + +}; + +Q_DECLARE_METATYPE(WlanQtUtilsAp) + +#endif /* WLANQTUTILSWLANIAP_H */ diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/t_wlanwizard/stubs/wlanqtutilscommon.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/t_wlanwizard/stubs/wlanqtutilscommon.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef STUB_WLANQTUTILSCOMMON_H +#define STUB_WLANQTUTILSCOMMON_H +/* +#ifdef BUILD_WLAN_QT_UTILS_STUBS +#define WLANQTUTILITIESDLL_EXPORT Q_DECL_EXPORT +#else +#define WLANQTUTILITIESDLL_EXPORT Q_DECL_IMPORT +#endif +*/ +#ifdef BUILD_WLANQTUTILITIES_DLL +#define WLANQTUTILITIESDLL_EXPORT Q_DECL_EXPORT +#else +#define WLANQTUTILITIESDLL_EXPORT Q_DECL_IMPORT +#endif +// Maximum length of WLAN SSID (limit also for number of characters for user input) +static const int KMaxSsidLen = 32; +// Maximum length of WEP key +static const int KMaxWEPKeyLen = 64; +// Maximum length of WPA key +static const int KMaxWPAKeyLen = 256; + +#ifdef ICT_RESULT_ENUM +enum WlanLoginIctsResultType { + IctsPassed, // Icts is passed + IctsHotspotPassed, // Icts and Hotspot authentication are passed + IctsCanceled, // User has canceled operation + IctsFailed +}; // Icts or/and Hotspot authentication are failed +#endif + + +/** + * Bearer type. + */ +enum WlanQtUtilsBearerType { + WlanQtUtilsBearerTypeNone = 0, ///< None of the bearer types. + WlanQtUtilsBearerTypeCellular , ///< Cellular (2G, 3G, 3.5G) bearer type. + WlanQtUtilsBearerTypeWlan ///< WLAN bearer type. +}; + +/** + * Connection status. + */ +enum WlanQtUtilsConnectionStatus { + WlanQtUtilsConnectionStatusNone = 0, ///< None of the connection statuses. + WlanQtUtilsConnectionStatusConnecting, ///< Connecting. + WlanQtUtilsConnectionStatusConnected, ///< Connected. + WlanQtUtilsConnectionStatusDisconnected ///< Disconnected. +}; + +/** + * Signal strength category boundaries in dB (absolute value). + * Smaller value means better signal. + */ +// TODO: WLAN signal level values valid are copied from 08wk41 Sniffer. OK? +// (WINS emulator gives just 0 which is equal to "Absolute max"...) +enum +{ + WlanQtUtilsWlanSignalStrengthAbsoluteMax = 0, ///< Absolute maximum signal strength. + WlanQtUtilsWlanSignalStrengthMax = 60, ///< Maximum signal strength. + WlanQtUtilsWlanSignalStrengthGood = 74, ///< Good signal strength. + WlanQtUtilsWlanSignalStrengthLow = 87, ///< signal strength. + WlanQtUtilsWlanSignalStrengthMin = 100, ///< Minimum signal strength. + WlanQtUtilsWlanSignalUnavailable = 9999, ///< Signal is unavailable. +}; + +/** WLAN signal is unknown. */ +const int WlanQtUtilsWlanSignalUnknown = 1000000; + +/** WLAN transmit power is unknown. */ +const unsigned WlanQtUtilsWlanTransmitPowerUnknown = 0xFFFFFFFF; + +#endif // WLANQTUTILSCOMMON_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/t_wlanwizard/t_wlanwizard.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/t_wlanwizard/t_wlanwizard.pro Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,93 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# 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". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +include(stubs/stubs.pri) +include(ut/ut.pri) + +QT += testlib +CONFIG += hb qtestlib + +TEMPLATE = app +TARGET = t_wlanwizard + +DEPENDPATH += . +MOC_DIR = _moc +RCC_DIR = _resources + +VERSION = 0.0.1 + +DEFINES += BUILD_WLAN_WIZARD_DLL +DEFINES += WLAN_WIZARD_RND + +RESOURCES += ../resources/resource.qrc + +INCLUDEPATH += \ + stubs \ + $$MW_LAYER_SYSTEMINCLUDE \ + $$OS_LAYER_SYSTEMINCLUDE + +# OST trace system requires traces directory to be in USERINCLUDES +MMP_RULES += "USERINCLUDE ../traces" + +# WLAN WIZARD HEADERS +HEADERS += \ + ../inc/wlanwizard.h \ + ../inc/wlanwizard_p.h \ + ../inc/wlanwizardpage.h \ + ../inc/wlanwizardhelper.h \ + ../inc/wlanwizardutils.h \ + ../inc/wlanwizardpageinternal.h \ + ../inc/wlanwizardpagekeyquery.h \ + ../inc/wlanwizardpageprocessingsettings.h \ + ../inc/wlanwizardpagesummary.h \ + ../inc/wlanwizardsummaryviewitem.h \ + ../inc/wlanwizardpagegenericerror.h \ + ../inc/wlanwizardpagenetworkmode.h \ + ../inc/wlanwizardpagescanning.h \ + ../inc/wlanwizardpagesecuritymode.h \ + ../inc/wlanwizardpagessid.h + +# WLAN WIZARD SOURCES +SOURCES += ../src/wlanwizard.cpp \ + ../src/wlanwizard_p.cpp \ + ../src/wlanwizardutils.cpp \ + ../src/wlanwizardpageinternal.cpp \ + ../src/wlanwizardpagekeyquery.cpp \ + ../src/wlanwizardpageprocessingsettings.cpp \ + ../src/wlanwizardpagesummary.cpp \ + ../src/wlanwizardsummaryviewitem.cpp \ + ../src/wlanwizardpagegenericerror.cpp \ + ../src/wlanwizardpagenetworkmode.cpp \ + ../src/wlanwizardpagescanning.cpp \ + ../src/wlanwizardpagesecuritymode.cpp \ + ../src/wlanwizardpagessid.cpp + +symbian: { + TARGET.CAPABILITY = ALL -TCB +} + +ict_result_enum_used: { + message(*** ict result enumerated instead of boolean.) + DEFINES+=ICT_RESULT_ENUM +} + +coverage_test: { + message(*** Coverage test mode build - no OST traces.) + #NO_OST_TRACES flag is set +} +else { + message(*** Normal Symbian-mode build.) +} \ No newline at end of file diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/t_wlanwizard/ut/hbautotest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/t_wlanwizard/ut/hbautotest.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,835 @@ +/* +* 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 "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "hbautotest.h" +#include +#include + + +const qreal STEP = 4; //How many pixels to drag before sending an event + +//Init static members +bool HbAutoTest::pointerPressed = false; +QPointF HbAutoTest::pressPoint = QPointF(); + +void HbAutoTest::mouseMove (HbAutoTestMainWindow *window, HbWidget *widget, QPointF pos, int delay) +{ + if (delay!=-1) { + QTest::qWait(delay); + } + QPointF targetPoint=QPointF(); + if (pos==QPointF()) { + targetPoint = middlePointOfWidget(widget); + } else { + targetPoint = widget->mapToScene(pos); + } + if (pointerPressed) { + //Now we should drag an item + drag(window, targetPoint); + HbAutoTestMouseEvent me ( + QEvent::MouseMove, + targetPoint.toPoint(), + window->viewport()->mapToGlobal(targetPoint.toPoint()), + Qt::NoButton, + Qt::NoButton, + Qt::NoModifier); + QSpontaneKeyEvent::setSpontaneous(&me); + qApp->notify((window->viewport()), &me); + QCoreApplication::sendPostedEvents(); + QTest::qWait(1); + } else { + HbAutoTestMouseEvent me ( + QEvent::MouseMove, + targetPoint.toPoint(), + window->viewport()->mapToGlobal(targetPoint.toPoint()), + Qt::NoButton, + Qt::NoButton, + Qt::NoModifier); + QSpontaneKeyEvent::setSpontaneous(&me); + qApp->notify((window->viewport()), &me); + QCoreApplication::sendPostedEvents(); + QTest::qWait(1); + + } + QTest::qWait(1); + QTest::qWait(1); +} + +void HbAutoTest::mousePress (HbAutoTestMainWindow *window, HbWidget *widget, QPointF pos, int delay) +{ + if (delay!=-1) { + QTest::qWait(delay); + } + pointerPressed=true; + QPointF targetPoint=QPointF(); + if (pos==QPointF()) { + targetPoint = middlePointOfWidget(widget); + } else { + targetPoint = widget->mapToScene(pos); + } + QCursor::setPos(window->mapToGlobal(targetPoint.toPoint())); + + pressPoint=targetPoint; + + HbAutoTestMouseEvent me ( + QEvent::MouseButtonPress, + targetPoint.toPoint(), + window->viewport()->mapToGlobal(targetPoint.toPoint()), + Qt::LeftButton, + Qt::LeftButton, + Qt::NoModifier); + + QSpontaneKeyEvent::setSpontaneous(&me); + qApp->notify((window->viewport()), &me); + QCoreApplication::sendPostedEvents(); + QCoreApplication::sendPostedEvents(); + QTest::qWait(1); +} + +void HbAutoTest::mouseRelease (HbAutoTestMainWindow *window, HbWidget *widget, QPointF pos, int delay) +{ + if (delay!=-1) { + QTest::qWait(delay); + } + pointerPressed=false; + QPointF targetPoint=QPointF(); + if (pos==QPointF()) { + targetPoint = middlePointOfWidget(widget); + } else { + targetPoint = widget->mapToScene(pos); + } + QCursor::setPos(window->mapToGlobal(targetPoint.toPoint())); + pressPoint=QPointF(); + HbAutoTestMouseEvent me ( + QEvent::MouseButtonRelease, + targetPoint.toPoint(), + window->viewport()->mapToGlobal(targetPoint.toPoint()), + Qt::LeftButton, + Qt::NoButton, + Qt::NoModifier); + + QSpontaneKeyEvent::setSpontaneous(&me); + qApp->notify((window->viewport()), &me); + QCoreApplication::sendPostedEvents(); + + QTest::qWait(1); + QTest::qWait(1); +} + +void HbAutoTest::mouseClick (HbAutoTestMainWindow *window, const HbWidget *widget, QPointF pos, int delay) +{ + if (delay!=-1) { + QTest::qWait(delay); + } + QPointF targetPoint=QPointF(); + if (pos==QPointF()) { + targetPoint = middlePointOfWidget(widget); + } else { + targetPoint = widget->mapToScene(pos); + } + + QCursor::setPos(window->mapToGlobal(targetPoint.toPoint())); + + HbAutoTestMouseEvent me ( + QEvent::MouseButtonPress, + targetPoint.toPoint(), + window->viewport()->mapToGlobal(targetPoint.toPoint()), + Qt::LeftButton, + Qt::LeftButton, + Qt::NoModifier); + QSpontaneKeyEvent::setSpontaneous(&me); + qApp->notify((window->viewport()), &me); + QCoreApplication::sendPostedEvents(); + //QTime currentTime = QTime::currentTime(); + //qDebug() << currentTime.toString("hh:mm:ss.zzz") << ": Left button down"; + QTest::qWait(1); + + if (delay!=-1) { + QTest::qWait(delay); + } + HbAutoTestMouseEvent me2 ( + QEvent::MouseButtonRelease, + targetPoint.toPoint(), + window->viewport()->mapToGlobal(targetPoint.toPoint()), + Qt::LeftButton, + Qt::NoButton, + Qt::NoModifier); + + QSpontaneKeyEvent::setSpontaneous(&me2); + qApp->notify((window->viewport()), &me2); + QCoreApplication::sendPostedEvents(); + //currentTime = QTime::currentTime(); + //qDebug() << currentTime.toString("hh:mm:ss.zzz") << ": Left button up"; + + QTest::qWait(1); + QTest::qWait(1); +} + +QPointF HbAutoTest::middlePointOfWidget( const HbWidget* widget) +{ + QRectF widgetRect = widget->rect(); + QRectF widgetSceneRect = widget->mapRectToScene(widgetRect); + qreal middleX = ((widgetSceneRect.right() - widgetSceneRect.left())/2)+widgetSceneRect.left(); + qreal middleY = ((widgetSceneRect.bottom() - widgetSceneRect.top())/2)+widgetSceneRect.top(); + return QPointF(middleX,middleY); +} + + + +void HbAutoTest::drag(HbAutoTestMainWindow *window, QPointF targetPoint) +{ + qreal tempX = targetPoint.x() - pressPoint.x(); + qreal tempY = targetPoint.y() - pressPoint.y(); + qreal totalTrip = sqrt ((tempX * tempX) + (tempY * tempY)); + + int numberOfSteps = qRound(totalTrip / STEP); + HbAutoTestMouseEvent me ( + QEvent::MouseMove, + targetPoint.toPoint(), + window->viewport()->mapToGlobal(targetPoint.toPoint()), + Qt::NoButton , + Qt::LeftButton, + Qt::NoModifier); + + QPointF nextPanPoint=pressPoint; + for (int i=1; imapToGlobal(nextPanPoint.toPoint())); + + me = HbAutoTestMouseEvent (QEvent::MouseMove, + nextPanPoint.toPoint(), + window->viewport()->mapToGlobal(nextPanPoint.toPoint()), + Qt::NoButton, + Qt::LeftButton, + Qt::NoModifier); + + QSpontaneKeyEvent::setSpontaneous(&me); + qApp->notify((window->viewport()), &me); + QCoreApplication::sendPostedEvents(); + } + + QCursor::setPos(window->mapToGlobal(targetPoint.toPoint())); + + //One more (or the only one) step to the target + me = HbAutoTestMouseEvent (QEvent::MouseMove, + targetPoint.toPoint(), + window->viewport()->mapToGlobal(targetPoint.toPoint()), + Qt::NoButton, + Qt::LeftButton, + Qt::NoModifier); + QSpontaneKeyEvent::setSpontaneous(&me); + qApp->notify((window->viewport()), &me); + QCoreApplication::sendPostedEvents(); +} + + +void HbAutoTest::simulateEvent(QWidget *widget, bool press, int code, + Qt::KeyboardModifiers modifier, QString text, bool repeat, int delay) + { + Q_ASSERT_X(dynamic_cast(( widget) ) != 0, "HbAutoTest", "Always use with HbAutoTestMainWindow"); + extern int Q_TESTLIB_EXPORT defaultKeyDelay(); + + if (delay == -1 || delay < 10) // defaultKeyDelay()) + delay = 10; //defaultKeyDelay(); + if(delay > 0) + QTest::qWait(delay); +// Q_UNUSED(delay); +// QTest::qWait(10); //TODO: Remove this and reveal above out-commented code + + HbAutoTestKeyEvent a(press ? QEvent::KeyPress : QEvent::KeyRelease, code, modifier, text, repeat); + QSpontaneKeyEvent::setSpontaneous(&a); + if (!qApp->notify(widget, &a)) + QTest::qWarn("Keyboard event not accepted by receiving widget"); + } + +void HbAutoTest::sendKeyEvent(QTest::KeyAction action, QWidget *widget, Qt::Key code, + QString text, Qt::KeyboardModifiers modifier, int delay) + { + QTEST_ASSERT(qApp); + + if (!widget) + widget = QWidget::keyboardGrabber(); + if (!widget) { + if (QWidget *apw = QApplication::activePopupWidget()) + widget = apw->focusWidget() ? apw->focusWidget() : apw; + else + widget = QApplication::focusWidget(); + } + if (!widget) + widget = QApplication::activeWindow(); + + QTEST_ASSERT(widget); + + if (action == QTest::Click) { + QPointer ptr(widget); + sendKeyEvent(QTest::Press, widget, code, text, modifier, delay); + if (!ptr) { + // if we send key-events to embedded widgets, they might be destroyed + // when the user presses Return + return; + } + sendKeyEvent(QTest::Release, widget, code, text, modifier, delay); + return; + } + + bool repeat = false; + + if (action == QTest::Press) { + if (modifier & Qt::ShiftModifier) + simulateEvent(widget, true, Qt::Key_Shift, 0, QString(), false, delay); + + if (modifier & Qt::ControlModifier) + simulateEvent(widget, true, Qt::Key_Control, modifier & Qt::ShiftModifier, QString(), false, delay); + + if (modifier & Qt::AltModifier) + simulateEvent(widget, true, Qt::Key_Alt, + modifier & (Qt::ShiftModifier | Qt::ControlModifier), QString(), false, delay); + if (modifier & Qt::MetaModifier) + simulateEvent(widget, true, Qt::Key_Meta, modifier & (Qt::ShiftModifier + | Qt::ControlModifier | Qt::AltModifier), QString(), false, delay); + simulateEvent(widget, true, code, modifier, text, repeat, delay); + } else if (action == QTest::Release) { + simulateEvent(widget, false, code, modifier, text, repeat, delay); + + if (modifier & Qt::MetaModifier) + simulateEvent(widget, false, Qt::Key_Meta, modifier, QString(), false, delay); + if (modifier & Qt::AltModifier) + simulateEvent(widget, false, Qt::Key_Alt, modifier & + (Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier), QString(), false, delay); + + if (modifier & Qt::ControlModifier) + simulateEvent(widget, false, Qt::Key_Control, + modifier & (Qt::ShiftModifier | Qt::ControlModifier), QString(), false, delay); + + if (modifier & Qt::ShiftModifier) + simulateEvent(widget, false, Qt::Key_Shift, modifier & Qt::ShiftModifier, QString(), false, delay); + } + } + +void HbAutoTest::sendKeyEvent(QTest::KeyAction action, QWidget *widget, Qt::Key code, + char ascii, Qt::KeyboardModifiers modifier, int delay) + { + Q_ASSERT_X(dynamic_cast(( widget) ) != 0, "HbAutoTest", "Always use with HbAutoTestMainWindow"); + QString text; + if (ascii) + text = QString(QChar::fromLatin1(ascii)); + sendKeyEvent(action, widget, code, text, modifier, delay); + } + +void HbAutoTest::keyEvent(QTest::KeyAction action, QWidget *widget, char ascii, + Qt::KeyboardModifiers modifier, int delay) + { + Q_ASSERT_X(dynamic_cast(( widget) ) != 0, "HbAutoTest", "Always use with HbAutoTestMainWindow"); + sendKeyEvent(action, widget, asciiToKey(ascii), ascii, modifier, delay); + } + +void HbAutoTest::keyEvent(QTest::KeyAction action, QWidget *widget, Qt::Key key, + Qt::KeyboardModifiers modifier, int delay) + { + Q_ASSERT_X(dynamic_cast(( widget) ) != 0, "HbAutoTest", "Always use with HbAutoTestMainWindow"); + sendKeyEvent(action, widget, key, keyToAscii(key), modifier, delay); + } + +void HbAutoTest::keyClicks(QWidget *widget, const QString &sequence, + Qt::KeyboardModifiers modifier, int delay) + { + Q_ASSERT_X(dynamic_cast(( widget) ) != 0, "HbAutoTest", "Always use with HbAutoTestMainWindow"); + for (int i=0; i < sequence.length(); i++) + keyEvent(QTest::Click, widget, sequence.at(i).toLatin1(), modifier, delay); + } + +void HbAutoTest::keyPress(QWidget *widget, char key, Qt::KeyboardModifiers modifier, int delay) + { + Q_ASSERT_X(dynamic_cast(( widget) ) != 0, "HbAutoTest", "Always use with HbAutoTestMainWindow"); + keyEvent(QTest::Press, widget, key, modifier, delay); + } + +void HbAutoTest::keyRelease(QWidget *widget, char key, Qt::KeyboardModifiers modifier, int delay) + { + Q_ASSERT_X(dynamic_cast(( widget) ) != 0, "HbAutoTest", "Always use with HbAutoTestMainWindow"); + keyEvent(QTest::Release, widget, key, modifier, delay); + } + +void HbAutoTest::keyClick(QWidget *widget, char key, Qt::KeyboardModifiers modifier, int delay) + { + Q_ASSERT_X(dynamic_cast(( widget) ) != 0, "HbAutoTest", "Always use with HbAutoTestMainWindow"); + keyEvent(QTest::Click, widget, key, modifier, delay); + } + +void HbAutoTest::keyPress(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier, int delay) + { + Q_ASSERT_X(dynamic_cast(( widget) ) != 0, "HbAutoTest", "Always use with HbAutoTestMainWindow"); + keyEvent(QTest::Press, widget, key, modifier, delay); + } + +void HbAutoTest::keyRelease(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier, int delay) + { + Q_ASSERT_X(dynamic_cast(( widget) ) != 0, "HbAutoTest", "Always use with HbAutoTestMainWindow"); + keyEvent(QTest::Release, widget, key, modifier, delay); } + +void HbAutoTest::keyClick(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier, int delay) + { + Q_ASSERT_X(dynamic_cast(( widget) ) != 0, "HbAutoTest", "Always use with HbAutoTestMainWindow"); + keyEvent(QTest::Click, widget, key, modifier, delay); + } + +Qt::Key HbAutoTest::asciiToKey(char ascii) +{ + switch ((unsigned char)ascii) { + case 0x08: return Qt::Key_Backspace; + case 0x09: return Qt::Key_Tab; + case 0x0b: return Qt::Key_Backtab; + case 0x0d: return Qt::Key_Return; + case 0x1b: return Qt::Key_Escape; + case 0x20: return Qt::Key_Space; + case 0x21: return Qt::Key_Exclam; + case 0x22: return Qt::Key_QuoteDbl; + case 0x23: return Qt::Key_NumberSign; + case 0x24: return Qt::Key_Dollar; + case 0x25: return Qt::Key_Percent; + case 0x26: return Qt::Key_Ampersand; + case 0x27: return Qt::Key_Apostrophe; + case 0x28: return Qt::Key_ParenLeft; + case 0x29: return Qt::Key_ParenRight; + case 0x2a: return Qt::Key_Asterisk; + case 0x2b: return Qt::Key_Plus; + case 0x2c: return Qt::Key_Comma; + case 0x2d: return Qt::Key_Minus; + case 0x2e: return Qt::Key_Period; + case 0x2f: return Qt::Key_Slash; + case 0x30: return Qt::Key_0; + case 0x31: return Qt::Key_1; + case 0x32: return Qt::Key_2; + case 0x33: return Qt::Key_3; + case 0x34: return Qt::Key_4; + case 0x35: return Qt::Key_5; + case 0x36: return Qt::Key_6; + case 0x37: return Qt::Key_7; + case 0x38: return Qt::Key_8; + case 0x39: return Qt::Key_9; + case 0x3a: return Qt::Key_Colon; + case 0x3b: return Qt::Key_Semicolon; + case 0x3c: return Qt::Key_Less; + case 0x3d: return Qt::Key_Equal; + case 0x3e: return Qt::Key_Greater; + case 0x3f: return Qt::Key_Question; + case 0x40: return Qt::Key_At; + case 0x41: return Qt::Key_A; + case 0x42: return Qt::Key_B; + case 0x43: return Qt::Key_C; + case 0x44: return Qt::Key_D; + case 0x45: return Qt::Key_E; + case 0x46: return Qt::Key_F; + case 0x47: return Qt::Key_G; + case 0x48: return Qt::Key_H; + case 0x49: return Qt::Key_I; + case 0x4a: return Qt::Key_J; + case 0x4b: return Qt::Key_K; + case 0x4c: return Qt::Key_L; + case 0x4d: return Qt::Key_M; + case 0x4e: return Qt::Key_N; + case 0x4f: return Qt::Key_O; + case 0x50: return Qt::Key_P; + case 0x51: return Qt::Key_Q; + case 0x52: return Qt::Key_R; + case 0x53: return Qt::Key_S; + case 0x54: return Qt::Key_T; + case 0x55: return Qt::Key_U; + case 0x56: return Qt::Key_V; + case 0x57: return Qt::Key_W; + case 0x58: return Qt::Key_X; + case 0x59: return Qt::Key_Y; + case 0x5a: return Qt::Key_Z; + case 0x5b: return Qt::Key_BracketLeft; + case 0x5c: return Qt::Key_Backslash; + case 0x5d: return Qt::Key_BracketRight; + case 0x5e: return Qt::Key_AsciiCircum; + case 0x5f: return Qt::Key_Underscore; + case 0x60: return Qt::Key_QuoteLeft; + case 0x61: return Qt::Key_A; + case 0x62: return Qt::Key_B; + case 0x63: return Qt::Key_C; + case 0x64: return Qt::Key_D; + case 0x65: return Qt::Key_E; + case 0x66: return Qt::Key_F; + case 0x67: return Qt::Key_G; + case 0x68: return Qt::Key_H; + case 0x69: return Qt::Key_I; + case 0x6a: return Qt::Key_J; + case 0x6b: return Qt::Key_K; + case 0x6c: return Qt::Key_L; + case 0x6d: return Qt::Key_M; + case 0x6e: return Qt::Key_N; + case 0x6f: return Qt::Key_O; + case 0x70: return Qt::Key_P; + case 0x71: return Qt::Key_Q; + case 0x72: return Qt::Key_R; + case 0x73: return Qt::Key_S; + case 0x74: return Qt::Key_T; + case 0x75: return Qt::Key_U; + case 0x76: return Qt::Key_V; + case 0x77: return Qt::Key_W; + case 0x78: return Qt::Key_X; + case 0x79: return Qt::Key_Y; + case 0x7a: return Qt::Key_Z; + case 0x7b: return Qt::Key_BraceLeft; + case 0x7c: return Qt::Key_Bar; + case 0x7d: return Qt::Key_BraceRight; + case 0x7e: return Qt::Key_AsciiTilde; + + // Latin 1 codes adapted from X: keysymdef.h,v 1.21 94/08/28 16:17:06 + case 0xa0: return Qt::Key_nobreakspace; + case 0xa1: return Qt::Key_exclamdown; + case 0xa2: return Qt::Key_cent; + case 0xa3: return Qt::Key_sterling; + case 0xa4: return Qt::Key_currency; + case 0xa5: return Qt::Key_yen; + case 0xa6: return Qt::Key_brokenbar; + case 0xa7: return Qt::Key_section; + case 0xa8: return Qt::Key_diaeresis; + case 0xa9: return Qt::Key_copyright; + case 0xaa: return Qt::Key_ordfeminine; + case 0xab: return Qt::Key_guillemotleft; + case 0xac: return Qt::Key_notsign; + case 0xad: return Qt::Key_hyphen; + case 0xae: return Qt::Key_registered; + case 0xaf: return Qt::Key_macron; + case 0xb0: return Qt::Key_degree; + case 0xb1: return Qt::Key_plusminus; + case 0xb2: return Qt::Key_twosuperior; + case 0xb3: return Qt::Key_threesuperior; + case 0xb4: return Qt::Key_acute; + case 0xb5: return Qt::Key_mu; + case 0xb6: return Qt::Key_paragraph; + case 0xb7: return Qt::Key_periodcentered; + case 0xb8: return Qt::Key_cedilla; + case 0xb9: return Qt::Key_onesuperior; + case 0xba: return Qt::Key_masculine; + case 0xbb: return Qt::Key_guillemotright; + case 0xbc: return Qt::Key_onequarter; + case 0xbd: return Qt::Key_onehalf; + case 0xbe: return Qt::Key_threequarters; + case 0xbf: return Qt::Key_questiondown; + case 0xc0: return Qt::Key_Agrave; + case 0xc1: return Qt::Key_Aacute; + case 0xc2: return Qt::Key_Acircumflex; + case 0xc3: return Qt::Key_Atilde; + case 0xc4: return Qt::Key_Adiaeresis; + case 0xc5: return Qt::Key_Aring; + case 0xc6: return Qt::Key_AE; + case 0xc7: return Qt::Key_Ccedilla; + case 0xc8: return Qt::Key_Egrave; + case 0xc9: return Qt::Key_Eacute; + case 0xca: return Qt::Key_Ecircumflex; + case 0xcb: return Qt::Key_Ediaeresis; + case 0xcc: return Qt::Key_Igrave; + case 0xcd: return Qt::Key_Iacute; + case 0xce: return Qt::Key_Icircumflex; + case 0xcf: return Qt::Key_Idiaeresis; + case 0xd0: return Qt::Key_ETH; + case 0xd1: return Qt::Key_Ntilde; + case 0xd2: return Qt::Key_Ograve; + case 0xd3: return Qt::Key_Oacute; + case 0xd4: return Qt::Key_Ocircumflex; + case 0xd5: return Qt::Key_Otilde; + case 0xd6: return Qt::Key_Odiaeresis; + case 0xd7: return Qt::Key_multiply; + case 0xd8: return Qt::Key_Ooblique; + case 0xd9: return Qt::Key_Ugrave; + case 0xda: return Qt::Key_Uacute; + case 0xdb: return Qt::Key_Ucircumflex; + case 0xdc: return Qt::Key_Udiaeresis; + case 0xdd: return Qt::Key_Yacute; + case 0xde: return Qt::Key_THORN; + case 0xdf: return Qt::Key_ssharp; + case 0xe5: return Qt::Key_Aring; + case 0xe6: return Qt::Key_AE; + case 0xf7: return Qt::Key_division; + case 0xf8: return Qt::Key_Ooblique; + case 0xff: return Qt::Key_ydiaeresis; + default: QTEST_ASSERT(false); return Qt::Key(0); + } +} + +char HbAutoTest::keyToAscii(Qt::Key key) +{ + switch (key) { + case Qt::Key_Backspace: return 0x8; //BS + case Qt::Key_Tab: return 0x09; // HT + case Qt::Key_Backtab: return 0x0b; // VT + case Qt::Key_Enter: + case Qt::Key_Return: return 0x0d; // CR + case Qt::Key_Escape: return 0x1b; // ESC + case Qt::Key_Space: return 0x20; // 7 bit printable ASCII + case Qt::Key_Exclam: return 0x21; + case Qt::Key_QuoteDbl: return 0x22; + case Qt::Key_NumberSign: return 0x23; + case Qt::Key_Dollar: return 0x24; + case Qt::Key_Percent: return 0x25; + case Qt::Key_Ampersand: return 0x26; + case Qt::Key_Apostrophe: return 0x27; + case Qt::Key_ParenLeft: return 0x28; + case Qt::Key_ParenRight: return 0x29; + case Qt::Key_Asterisk: return 0x2a; + case Qt::Key_Plus: return 0x2b; + case Qt::Key_Comma: return 0x2c; + case Qt::Key_Minus: return 0x2d; + case Qt::Key_Period: return 0x2e; + case Qt::Key_Slash: return 0x2f; + case Qt::Key_0: return 0x30; + case Qt::Key_1: return 0x31; + case Qt::Key_2: return 0x32; + case Qt::Key_3: return 0x33; + case Qt::Key_4: return 0x34; + case Qt::Key_5: return 0x35; + case Qt::Key_6: return 0x36; + case Qt::Key_7: return 0x37; + case Qt::Key_8: return 0x38; + case Qt::Key_9: return 0x39; + case Qt::Key_Colon: return 0x3a; + case Qt::Key_Semicolon: return 0x3b; + case Qt::Key_Less: return 0x3c; + case Qt::Key_Equal: return 0x3d; + case Qt::Key_Greater: return 0x3e; + case Qt::Key_Question: return 0x3f; + case Qt::Key_At: return 0x40; + case Qt::Key_A: return 0x61; // 0x41 == 'A', 0x61 == 'a' + case Qt::Key_B: return 0x62; + case Qt::Key_C: return 0x63; + case Qt::Key_D: return 0x64; + case Qt::Key_E: return 0x65; + case Qt::Key_F: return 0x66; + case Qt::Key_G: return 0x67; + case Qt::Key_H: return 0x68; + case Qt::Key_I: return 0x69; + case Qt::Key_J: return 0x6a; + case Qt::Key_K: return 0x6b; + case Qt::Key_L: return 0x6c; + case Qt::Key_M: return 0x6d; + case Qt::Key_N: return 0x6e; + case Qt::Key_O: return 0x6f; + case Qt::Key_P: return 0x70; + case Qt::Key_Q: return 0x71; + case Qt::Key_R: return 0x72; + case Qt::Key_S: return 0x73; + case Qt::Key_T: return 0x74; + case Qt::Key_U: return 0x75; + case Qt::Key_V: return 0x76; + case Qt::Key_W: return 0x77; + case Qt::Key_X: return 0x78; + case Qt::Key_Y: return 0x79; + case Qt::Key_Z: return 0x7a; + case Qt::Key_BracketLeft: return 0x5b; + case Qt::Key_Backslash: return 0x5c; + case Qt::Key_BracketRight: return 0x5d; + case Qt::Key_AsciiCircum: return 0x5e; + case Qt::Key_Underscore: return 0x5f; + case Qt::Key_QuoteLeft: return 0x60; + + case Qt::Key_BraceLeft: return 0x7b; + case Qt::Key_Bar: return 0x7c; + case Qt::Key_BraceRight: return 0x7d; + case Qt::Key_AsciiTilde: return 0x7e; + + case Qt::Key_Delete: return 0; + case Qt::Key_Insert: return 0; // = 0x1006, + case Qt::Key_Pause: return 0; // = 0x1008, + case Qt::Key_Print: return 0; // = 0x1009, + case Qt::Key_SysReq: return 0; // = 0x100a, + + case Qt::Key_Clear: return 0; // = 0x100b, + + case Qt::Key_Home: return 0; // = 0x1010, // cursor movement + case Qt::Key_End: return 0; // = 0x1011, + case Qt::Key_Left: return 0; // = 0x1012, + case Qt::Key_Up: return 0; // = 0x1013, + case Qt::Key_Right: return 0; // = 0x1014, + case Qt::Key_Down: return 0; // = 0x1015, + case Qt::Key_PageUp: return 0; // = 0x1016, + case Qt::Key_PageDown: return 0; // = 0x1017, + case Qt::Key_Shift: return 0; // = 0x1020, // modifiers + case Qt::Key_Control: return 0; // = 0x1021, + case Qt::Key_Meta: return 0; // = 0x1022, + case Qt::Key_Alt: return 0; // = 0x1023, + case Qt::Key_CapsLock: return 0; // = 0x1024, + case Qt::Key_NumLock: return 0; // = 0x1025, + case Qt::Key_ScrollLock: return 0; // = 0x1026, + case Qt::Key_F1: return 0; // = 0x1030, // function keys + case Qt::Key_F2: return 0; // = 0x1031, + case Qt::Key_F3: return 0; // = 0x1032, + case Qt::Key_F4: return 0; // = 0x1033, + case Qt::Key_F5: return 0; // = 0x1034, + case Qt::Key_F6: return 0; // = 0x1035, + case Qt::Key_F7: return 0; // = 0x1036, + case Qt::Key_F8: return 0; // = 0x1037, + case Qt::Key_F9: return 0; // = 0x1038, + case Qt::Key_F10: return 0; // = 0x1039, + case Qt::Key_F11: return 0; // = 0x103a, + case Qt::Key_F12: return 0; // = 0x103b, + case Qt::Key_F13: return 0; // = 0x103c, + case Qt::Key_F14: return 0; // = 0x103d, + case Qt::Key_F15: return 0; // = 0x103e, + case Qt::Key_F16: return 0; // = 0x103f, + case Qt::Key_F17: return 0; // = 0x1040, + case Qt::Key_F18: return 0; // = 0x1041, + case Qt::Key_F19: return 0; // = 0x1042, + case Qt::Key_F20: return 0; // = 0x1043, + case Qt::Key_F21: return 0; // = 0x1044, + case Qt::Key_F22: return 0; // = 0x1045, + case Qt::Key_F23: return 0; // = 0x1046, + case Qt::Key_F24: return 0; // = 0x1047, + case Qt::Key_F25: return 0; // = 0x1048, // F25 .. F35 only on X11 + case Qt::Key_F26: return 0; // = 0x1049, + case Qt::Key_F27: return 0; // = 0x104a, + case Qt::Key_F28: return 0; // = 0x104b, + case Qt::Key_F29: return 0; // = 0x104c, + case Qt::Key_F30: return 0; // = 0x104d, + case Qt::Key_F31: return 0; // = 0x104e, + case Qt::Key_F32: return 0; // = 0x104f, + case Qt::Key_F33: return 0; // = 0x1050, + case Qt::Key_F34: return 0; // = 0x1051, + case Qt::Key_F35: return 0; // = 0x1052, + case Qt::Key_Super_L: return 0; // = 0x1053, // extra keys + case Qt::Key_Super_R: return 0; // = 0x1054, + case Qt::Key_Menu: return 0; // = 0x1055, + case Qt::Key_Hyper_L: return 0; // = 0x1056, + case Qt::Key_Hyper_R: return 0; // = 0x1057, + case Qt::Key_Help: return 0; // = 0x1058, + case Qt::Key_Direction_L: return 0; // = 0x1059, + case Qt::Key_Direction_R: return 0; // = 0x1060, + + // Latin 1 codes adapted from X: keysymdef.h,v 1.21 94/08/28 16:17:06 + case Qt::Key_nobreakspace: return char(0xa0); + case Qt::Key_exclamdown: return char(0xa1); + case Qt::Key_cent: return char(0xa2); + case Qt::Key_sterling: return char(0xa3); + case Qt::Key_currency: return char(0xa4); + case Qt::Key_yen: return char(0xa5); + case Qt::Key_brokenbar: return char(0xa6); + case Qt::Key_section: return char(0xa7); + case Qt::Key_diaeresis: return char(0xa8); + case Qt::Key_copyright: return char(0xa9); + case Qt::Key_ordfeminine: return char(0xaa); + case Qt::Key_guillemotleft: return char(0xab); // left angle quotation mar + case Qt::Key_notsign: return char(0xac); + case Qt::Key_hyphen: return char(0xad); + case Qt::Key_registered: return char(0xae); + case Qt::Key_macron: return char(0xaf); + case Qt::Key_degree: return char(0xb0); + case Qt::Key_plusminus: return char(0xb1); + case Qt::Key_twosuperior: return char(0xb2); + case Qt::Key_threesuperior: return char(0xb3); + case Qt::Key_acute: return char(0xb4); + case Qt::Key_mu: return char(0xb5); + case Qt::Key_paragraph: return char(0xb6); + case Qt::Key_periodcentered: return char(0xb7); + case Qt::Key_cedilla: return char(0xb8); + case Qt::Key_onesuperior: return char(0xb9); + case Qt::Key_masculine: return char(0xba); + case Qt::Key_guillemotright: return char(0xbb); // right angle quotation mar + case Qt::Key_onequarter: return char(0xbc); + case Qt::Key_onehalf: return char(0xbd); + case Qt::Key_threequarters: return char(0xbe); + case Qt::Key_questiondown: return char(0xbf); + case Qt::Key_Agrave: return char(0xc0); + case Qt::Key_Aacute: return char(0xc1); + case Qt::Key_Acircumflex: return char(0xc2); + case Qt::Key_Atilde: return char(0xc3); + case Qt::Key_Adiaeresis: return char(0xc4); + case Qt::Key_Aring: return char(0xe5); + case Qt::Key_AE: return char(0xe6); + case Qt::Key_Ccedilla: return char(0xc7); + case Qt::Key_Egrave: return char(0xc8); + case Qt::Key_Eacute: return char(0xc9); + case Qt::Key_Ecircumflex: return char(0xca); + case Qt::Key_Ediaeresis: return char(0xcb); + case Qt::Key_Igrave: return char(0xcc); + case Qt::Key_Iacute: return char(0xcd); + case Qt::Key_Icircumflex: return char(0xce); + case Qt::Key_Idiaeresis: return char(0xcf); + case Qt::Key_ETH: return char(0xd0); + case Qt::Key_Ntilde: return char(0xd1); + case Qt::Key_Ograve: return char(0xd2); + case Qt::Key_Oacute: return char(0xd3); + case Qt::Key_Ocircumflex: return char(0xd4); + case Qt::Key_Otilde: return char(0xd5); + case Qt::Key_Odiaeresis: return char(0xd6); + case Qt::Key_multiply: return char(0xd7); + case Qt::Key_Ooblique: return char(0xf8); + case Qt::Key_Ugrave: return char(0xd9); + case Qt::Key_Uacute: return char(0xda); + case Qt::Key_Ucircumflex: return char(0xdb); + case Qt::Key_Udiaeresis: return char(0xdc); + case Qt::Key_Yacute: return char(0xdd); + case Qt::Key_THORN: return char(0xde); + case Qt::Key_ssharp: return char(0xdf); + case Qt::Key_division: return char(0xf7); + case Qt::Key_ydiaeresis: return char(0xff); + + // multimedia/internet keys - ignored by default - see QKeyEvent c'tor + + case Qt::Key_Back : return 0; // = 0x1061, + case Qt::Key_Forward : return 0; // = 0x1062, + case Qt::Key_Stop : return 0; // = 0x1063, + case Qt::Key_Refresh : return 0; // = 0x1064, + + case Qt::Key_VolumeDown: return 0; // = 0x1070, + case Qt::Key_VolumeMute : return 0; // = 0x1071, + case Qt::Key_VolumeUp: return 0; // = 0x1072, + case Qt::Key_BassBoost: return 0; // = 0x1073, + case Qt::Key_BassUp: return 0; // = 0x1074, + case Qt::Key_BassDown: return 0; // = 0x1075, + case Qt::Key_TrebleUp: return 0; // = 0x1076, + case Qt::Key_TrebleDown: return 0; // = 0x1077, + + case Qt::Key_MediaPlay : return 0; // = 0x1080, + case Qt::Key_MediaStop : return 0; // = 0x1081, + case Qt::Key_MediaPrevious : return 0; // = 0x1082, + case Qt::Key_MediaNext : return 0; // = 0x1083, + case Qt::Key_MediaRecord: return 0; // = 0x1084, + + case Qt::Key_HomePage : return 0; // = 0x1090, + case Qt::Key_Favorites : return 0; // = 0x1091, + case Qt::Key_Search : return 0; // = 0x1092, + case Qt::Key_Standby: return 0; // = 0x1093, + case Qt::Key_OpenUrl: return 0; // = 0x1094, + + case Qt::Key_LaunchMail : return 0; // = 0x10a0, + case Qt::Key_LaunchMedia: return 0; // = 0x10a1, + case Qt::Key_Launch0 : return 0; // = 0x10a2, + case Qt::Key_Launch1 : return 0; // = 0x10a3, + case Qt::Key_Launch2 : return 0; // = 0x10a4, + case Qt::Key_Launch3 : return 0; // = 0x10a5, + case Qt::Key_Launch4 : return 0; // = 0x10a6, + case Qt::Key_Launch5 : return 0; // = 0x10a7, + case Qt::Key_Launch6 : return 0; // = 0x10a8, + case Qt::Key_Launch7 : return 0; // = 0x10a9, + case Qt::Key_Launch8 : return 0; // = 0x10aa, + case Qt::Key_Launch9 : return 0; // = 0x10ab, + case Qt::Key_LaunchA : return 0; // = 0x10ac, + case Qt::Key_LaunchB : return 0; // = 0x10ad, + case Qt::Key_LaunchC : return 0; // = 0x10ae, + case Qt::Key_LaunchD : return 0; // = 0x10af, + case Qt::Key_LaunchE : return 0; // = 0x10b0, + case Qt::Key_LaunchF : return 0; // = 0x10b1, + + default: QTEST_ASSERT(false); return 0; + } +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/t_wlanwizard/ut/hbautotest.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/t_wlanwizard/ut/hbautotest.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,279 @@ +/* +* 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 "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef HBAUTOTEST_H +#define HBAUTOTEST_H + +#include +#include +#include + +class HbMainWindow; +class HbWidget; +class HbAutoTestMainWindow; +class HbAutoTest; +class HbAutoTestMouseEvent; +/* +INSTRUCTIONS: +The class HbAutoTest is meant to be used with Orbit applications auto testing instead of GUI testing APIs of QTestLib. + +The functions of this class is to used similarily to the related QTestLib functions. + +Use HbAutoTestMainWindow (defined below) instead of HbMainWindow to enble filtering. +Filterin filters out UI events that are not sent by function defined in HbAutoTest class. + +*/ + +class HbAutoTestMouseEvent : public QMouseEvent +{ +public: + HbAutoTestMouseEvent(Type type, const QPoint & pos, const QPoint & globalPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers ) + : QMouseEvent(type,pos,globalPos,button,buttons,modifiers){} +}; + +class HbAutoTestKeyEvent : public QKeyEvent +{ +public: + HbAutoTestKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text = QString(), + bool autorep = false, ushort count = 1 ) + : QKeyEvent(type, key, modifiers, text, autorep, count){} +}; + +class HbAutoTest +{ +public: + + static void mouseMove (HbAutoTestMainWindow *window, HbWidget *widget, QPointF pos = QPointF(), int delay = -1 ); + static void mousePress (HbAutoTestMainWindow *window, HbWidget *widget, QPointF pos = QPointF(), int delay = -1); + static void mouseRelease (HbAutoTestMainWindow *window, HbWidget *widget, QPointF pos = QPointF(), int delay = -1); + static void mouseClick (HbAutoTestMainWindow *window, const HbWidget *widget, QPointF pos = QPointF(), int delay = -1); + +private: + static void drag(HbAutoTestMainWindow *window, QPointF targetPoint); + static QPointF middlePointOfWidget( const HbWidget* widget); + + static bool pointerPressed; + static QPointF pressPoint; + +//Key event Part: copy-pasted from QTestLib and modified to support HbAutoTestKeyEvent to enable filtering. +//see HbAutoTestMainWindow below. +public: + + static Qt::Key asciiToKey(char ascii); + static char keyToAscii(Qt::Key key); + + static void simulateEvent(QWidget *widget, bool press, int code, + Qt::KeyboardModifiers modifier, QString text, bool repeat, int delay=-1); + + static void sendKeyEvent(QTest::KeyAction action, QWidget *widget, Qt::Key code, + QString text, Qt::KeyboardModifiers modifier, int delay=-1); + + static void sendKeyEvent(QTest::KeyAction action, QWidget *widget, Qt::Key code, + char ascii, Qt::KeyboardModifiers modifier, int delay=-1); + + static void keyEvent(QTest::KeyAction action, QWidget *widget, char ascii, + Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1); + + static void keyEvent(QTest::KeyAction action, QWidget *widget, Qt::Key key, + Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1); + + static void keyClicks(QWidget *widget, const QString &sequence, + Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1); + + static void keyPress(QWidget *widget, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1); + + static void keyRelease(QWidget *widget, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1); + + static void keyClick(QWidget *widget, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1); + + static void keyPress(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1); + + static void keyRelease(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1); + + static void keyClick(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1); +}; + +class HbTestEvent +{ +public: + virtual void simulate(QWidget *w) = 0; + virtual HbTestEvent *clone() const = 0; + + virtual ~HbTestEvent() {} +}; + +class HbTestKeyEvent: public HbTestEvent +{ +public: + inline HbTestKeyEvent(QTest::KeyAction action, Qt::Key key, Qt::KeyboardModifiers modifiers, int delay) + : _action(action), _delay(delay), _modifiers(modifiers), _ascii(0), _key(key) {} + inline HbTestKeyEvent(QTest::KeyAction action, char ascii, Qt::KeyboardModifiers modifiers, int delay) + : _action(action), _delay(delay), _modifiers(modifiers), + _ascii(ascii), _key(Qt::Key_unknown) {} + inline HbTestEvent *clone() const { return new HbTestKeyEvent(*this); } + + inline void simulate(QWidget *w) + { + if (_ascii == 0) + HbAutoTest::keyEvent(_action, w, _key, _modifiers, _delay); + else + HbAutoTest::keyEvent(_action, w, _ascii, _modifiers, _delay); + } + +protected: + QTest::KeyAction _action; + int _delay; + Qt::KeyboardModifiers _modifiers; + char _ascii; + Qt::Key _key; +}; + +class HbTestKeyClicksEvent: public HbTestEvent +{ +public: + inline HbTestKeyClicksEvent(const QString &keys, Qt::KeyboardModifiers modifiers, int delay) + : _keys(keys), _modifiers(modifiers), _delay(delay) {} + inline HbTestEvent *clone() const { return new HbTestKeyClicksEvent(*this); } + + inline void simulate(QWidget *w) + { + HbAutoTest::keyClicks(w, _keys, _modifiers, _delay); + } + +private: + QString _keys; + Qt::KeyboardModifiers _modifiers; + int _delay; +}; + +class HbTestDelayEvent: public HbTestEvent +{ +public: + inline HbTestDelayEvent(int msecs): _delay(msecs) {} + inline HbTestEvent *clone() const { return new HbTestDelayEvent(*this); } + + inline void simulate(QWidget * /*w*/) { QTest::qWait(_delay); } + +private: + int _delay; +}; + +class HbTestEventList: public QList +{ +public: + inline HbTestEventList() {} + inline HbTestEventList(const HbTestEventList &other): QList() + { for (int i = 0; i < other.count(); ++i) append(other.at(i)->clone()); } + inline ~HbTestEventList() + { clear(); } + inline void clear() + { qDeleteAll(*this); QList::clear(); } + + inline void addKeyClick(Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) + { addKeyEvent(QTest::Click, qtKey, modifiers, msecs); } + inline void addKeyPress(Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) + { addKeyEvent(QTest::Press, qtKey, modifiers, msecs); } + inline void addKeyRelease(Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) + { addKeyEvent(QTest::Release, qtKey, modifiers, msecs); } + inline void addKeyEvent(QTest::KeyAction action, Qt::Key qtKey, + Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) + { append(new HbTestKeyEvent(action, qtKey, modifiers, msecs)); } + + inline void addKeyClick(char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) + { addKeyEvent(QTest::Click, ascii, modifiers, msecs); } + inline void addKeyPress(char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) + { addKeyEvent(QTest::Press, ascii, modifiers, msecs); } + inline void addKeyRelease(char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) + { addKeyEvent(QTest::Release, ascii, modifiers, msecs); } + inline void addKeyClicks(const QString &keys, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) + { append(new HbTestKeyClicksEvent(keys, modifiers, msecs)); } + inline void addKeyEvent(QTest::KeyAction action, char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) + { append(new HbTestKeyEvent(action, ascii, modifiers, msecs)); } + + inline void addDelay(int msecs) + { append(new HbTestDelayEvent(msecs)); } + + inline void simulate(QWidget *w) + { + for (int i = 0; i < count(); ++i) + at(i)->simulate(w); + } +}; + +class HbAutoTestMainWindow : public HbMainWindow +{ +public: + HbAutoTestMainWindow() : HbMainWindow() {} + + void mousePressEvent(QMouseEvent *event) + { + qDebug( + "HbAutoTestMainWindow::mousePressEvent: x(%d) y(%d)", + event->x(), + event->y()); + if ( dynamic_cast(event) ) { + HbMainWindow::mousePressEvent(event); + } else { + ;//Do nothing + } + } + + void mouseMoveEvent(QMouseEvent *event) + { + if ( dynamic_cast(event) ) { + HbMainWindow::mouseMoveEvent(event); + } else { + ;//Do nothing + } + } + + void mouseReleaseEvent(QMouseEvent *event) + { + if ( dynamic_cast(event) ) { + HbMainWindow::mouseReleaseEvent(event); + } else { + ;//Do nothing + } + } + + void keyPressEvent(QKeyEvent *event) + { + if ( dynamic_cast(event) ) { + HbMainWindow::keyPressEvent(event); + } else { + ;//Do nothing + } + } + void keyReleaseEvent(QKeyEvent *event) + { + if ( dynamic_cast(event) ) { + HbMainWindow::keyReleaseEvent(event); + } else { + ;//Do nothing + } + } + + void mouseDoubleClickEvent(QMouseEvent *event) + { + Q_UNUSED(event); + //Just ignore, not supported in Orbit + } +}; + + +Q_DECLARE_METATYPE(HbTestEventList) +#endif //HBAUTOTEST_H diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/t_wlanwizard/ut/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/t_wlanwizard/ut/main.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * 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". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + */ + +// System includes +#include +#include +#include +#include +#include + +// User includes +#include "testwlanwizardui.h" +#include "testwlanwizard.h" +#include "hbautotest.h" + +// ======== LOCAL FUNCTIONS ======== +int main(int argc, char *argv[]) +{ + qDebug("TestWlanWizardUI main start"); + HbApplication app(argc, argv); + app.setApplicationName("TestWlanWizardUI"); + + char *pass[3]; + pass[0] = argv[0]; + pass[1] = "-o"; + pass[2] = "c:\\data\\TestWlanWizard.txt"; + TestWlanWizard tcUtilities; + int res = QTest::qExec(&tcUtilities, 3, pass); + + pass[2] = "c:\\data\\TestWlanWizardUi.txt"; + TestWlanWizardUi tc; + res = QTest::qExec(&tc, 3, pass); + + qDebug("TestWlanWizardUI main exit"); + return res; +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/t_wlanwizard/ut/testwlanwizard.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/t_wlanwizard/ut/testwlanwizard.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,319 @@ +/* + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * 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". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * This is the source file for testing Wlan Wizard library. + */ + +// System includes +#include +#include + +// User includes +#include "testwlanwizard.h" +#include "wlanwizardutils.h" + +// External function prototypes + +// Local constants + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------- +// FRAMEWORK FUNCTIONS +// --------------------------------------------------------- + +/** + * This function will be called before the first test function is executed. + */ +void TestWlanWizard::initTestCase() +{ + +} + +/** + * This function will be called after the last test function was executed. + */ +void TestWlanWizard::cleanupTestCase() +{ +} + +/** + * This function will be called before each test function is executed. + */ +void TestWlanWizard::init() +{ + +} + +/** + * This function will be called after each test function is executed. + */ +void TestWlanWizard::cleanup() +{ + +} + +// --------------------------------------------------------- +// TEST CASES +// --------------------------------------------------------- + + +void TestWlanWizard::testWepHex64Valid() +{ + QString key("a0cd9fACDF"); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusOk); +} + +void TestWlanWizard::testWepHex128Valid() +{ + QString key("ABCDEFabcdef0123456789AAAA"); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusOk); +} + +void TestWlanWizard::testWepHexInvalidCharacters() +{ + QString key("wlanwizard"); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); +} + +void TestWlanWizard::testWepAscii64Valid() +{ + QString key("testi"); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusOk); +} + +void TestWlanWizard::testWepAscii128Valid() +{ + QString key("wlanwizardjee"); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusOk); +} + +void TestWlanWizard::testWepAsciiInvalidCharacters() +{ + QString key("wlanwizardje"); + key.append(QChar(31)); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); +} + +void TestWlanWizard::testWepLength9Invalid() +{ + QString key("123456789"); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusWepInvalidLength); +} + +void TestWlanWizard::testWepLength11Invalid() +{ + QString key("12345678901"); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusWepInvalidLength); +} + +void TestWlanWizard::testWepLength25Invalid() +{ + QString key("1234567890123456789012345"); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusWepInvalidLength); +} + +void TestWlanWizard::testWepLength27Invalid() +{ + QString key("123456789012345678901234567"); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusWepInvalidLength); +} + +void TestWlanWizard::testWepLength4Invalid() +{ + QString key("1234"); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusWepInvalidLength); +} + +void TestWlanWizard::testWepLength6Invalid() +{ + QString key("123456"); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusWepInvalidLength); +} + +void TestWlanWizard::testWepLength12Invalid() +{ + QString key("123456789012"); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusWepInvalidLength); +} + +void TestWlanWizard::testWepLength14Invalid() +{ + QString key("12345678901234"); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusWepInvalidLength); +} + +// ---------------------------------------------------------------------------- +// WPA test cases +// ---------------------------------------------------------------------------- +void TestWlanWizard::testWpaHexValid() +{ + QString key("1234567890123456789012345678abcdefabcdefabcdefABCDEFABCDEFABCDEF"); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWpaKey(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusOk); +} + +void TestWlanWizard::testWpaHexInvalidCharacters() +{ + QString key("abcdefabcdefabcdefABCDEFABCDEFABCDEF123456789012345678901234567G"); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWpaKey(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); +} +void TestWlanWizard::testWpaAsciiLength8Valid() +{ + QString key("ictsucks"); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWpaKey(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusOk); +} + +void TestWlanWizard::testWpaAsciiLength63Valid() +{ + QString key("zxcvbnm,.-asdfghjkl'qwertyuiop1234567890qwertyuiopzxcvbnm,.-123"); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWpaKey(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusOk); +} + +void TestWlanWizard::testWpaAsciiLength64Invalid() +{ + QString key("zxcvbnm,.-asdfghjkl'qwertyuiop1234567890qwertyuiopzxcvbnm,.-1234"); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWpaKey(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); +} + +void TestWlanWizard::testWpaAsciiInvalidCharacters() +{ + QString key("wizardrules"); + key.append(QChar(127)); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWpaKey(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); +} + +void TestWlanWizard::testWpaLength7Invalid() +{ + QString key("wizards"); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWpaKey(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusWpaTooShort); +} + +void TestWlanWizard::testWpaLength65Invalid() +{ + QString key("zxcvbnm,.-asdfghjkl'qwertyuiop1234567890qwertyuiopzxcvbnm,.-12345"); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWpaKey(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusWpaTooLong); +} + + +// ---------------------------------------------------------------------------- +// ASCII test cases +// ---------------------------------------------------------------------------- +void TestWlanWizard::testAsciiValidCharacters() +{ + QString key; + for (int i = 32 ; i <= 126 ; i++){ + key.append(QChar(i)); + } + WlanWizardUtils::KeyStatus status = WlanWizardUtils::isAscii(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusOk); +} + +void TestWlanWizard::testAsciiInvalidCharactersLower() +{ + QString key("wizardrules"); + key.append(QChar(31)); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::isAscii(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); +} + +void TestWlanWizard::testAsciiInvalidCharactersUpper() +{ + QString key("wizardrules"); + key.append(QChar(127)); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::isAscii(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); +} + + +// ---------------------------------------------------------------------------- +// HEX test cases +// ---------------------------------------------------------------------------- +void TestWlanWizard::testHexValidCharacters() +{ + QString key("abcdefABCDEF1234567890"); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::isHex(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusOk); +} + +void TestWlanWizard::testHexInvalidCharactersDigitLower() +{ + QString key("afAF09"); + key.append(QChar(47)); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::isHex(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); +} + +void TestWlanWizard::testHexInvalidCharactersDigitUpper() +{ + QString key("abc"); + key.append(QChar(58)); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::isHex(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); +} + +void TestWlanWizard::testHexInvalidCharacters_a_Lower() +{ + QString key("abc"); + key.append(QChar(96)); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::isHex(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); +} + +void TestWlanWizard::testHexInvalidCharacters_f_Upper() +{ + QString key("abc"); + key.append(QChar(103)); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::isHex(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); +} + +void TestWlanWizard::testHexInvalidCharacters_A_Lower() +{ + QString key("abc"); + key.append(QChar(64)); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::isHex(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); +} + +void TestWlanWizard::testHexInvalidCharacters_F_Upper() +{ + QString key("abc"); + key.append(QChar(71)); + WlanWizardUtils::KeyStatus status = WlanWizardUtils::isHex(key); + QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/t_wlanwizard/ut/testwlanwizard.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/t_wlanwizard/ut/testwlanwizard.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* 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". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* This is the header file for testing Wlan Qt Utilities library. +*/ + +#ifndef TESTWLANWIZARD_H_ +#define TESTWLANWIZARD_H_ + +// System includes +#include + +// User includes + +// Forward declarations +class QSignalSpy; +class WlanQtUtils; + +// External data types + +// Constants + +class TestWlanWizard: public QObject +{ + Q_OBJECT + +private slots: + + // Functions from QTest framework. + void initTestCase(); + void cleanupTestCase(); + void init(); + void cleanup(); + + // WEP test cases + void testWepHex64Valid(); + void testWepHex128Valid(); + void testWepHexInvalidCharacters(); + + void testWepAscii64Valid(); + void testWepAscii128Valid(); + void testWepAsciiInvalidCharacters(); + void testWepLength9Invalid(); + void testWepLength11Invalid(); + void testWepLength25Invalid(); + void testWepLength27Invalid(); + void testWepLength4Invalid(); + void testWepLength6Invalid(); + void testWepLength12Invalid(); + void testWepLength14Invalid(); + + // WPA test cases + void testWpaHexValid(); + void testWpaHexInvalidCharacters(); + void testWpaAsciiLength8Valid(); + void testWpaAsciiLength63Valid(); + void testWpaAsciiLength64Invalid(); + void testWpaAsciiInvalidCharacters(); + void testWpaLength7Invalid(); + void testWpaLength65Invalid(); + + // ASCII test cases + void testAsciiValidCharacters(); + void testAsciiInvalidCharactersLower(); + void testAsciiInvalidCharactersUpper(); + + // HEX test cases + void testHexValidCharacters(); + void testHexInvalidCharactersDigitLower(); + void testHexInvalidCharactersDigitUpper(); + void testHexInvalidCharacters_a_Lower(); + void testHexInvalidCharacters_f_Upper(); + void testHexInvalidCharacters_A_Lower(); + void testHexInvalidCharacters_F_Upper(); + +private: + +}; + +#endif /* TESTWLANWIZARD_H_ */ + diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/t_wlanwizard/ut/testwlanwizardui.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/t_wlanwizard/ut/testwlanwizardui.cpp Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,1729 @@ +/* + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * 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". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + */ + +// System includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// User includes +#include "testwlanwizardui.h" +#include "testwlanwizardui_conf.h" +#include "hbautotest.h" +#include "wlanwizard.h" +#include "wlanwizard_p.h" +#include "wlanwizardpagessid.h" +#include "context_wlanqtutils.h" +#include "wlanqtutils.h" +#include "wlanqtutilsap.h" + +// External function prototypes + +// Local constants + +class TestRadioButtonList: public HbRadioButtonList +{ +public: + void emitActivated(const QModelIndex &modelIndex) + { HbRadioButtonList::emitActivated(modelIndex); } +}; + +// ======== LOCAL FUNCTIONS ======== + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------- +// FRAMEWORK FUNCTIONS +// --------------------------------------------------------- + +ContextWlanApList::ContextWlanApList() +{ + +} + +ContextWlanApList::~ContextWlanApList() +{ + clear(); +} + +void ContextWlanApList::Add(QString name, int netMode, int secMode, bool wpaPskInUse, + bool wpsSupported, int signalStrength) +{ + QSharedPointer temp = QSharedPointer(new WlanQtUtilsAp()); + temp->setValue(WlanQtUtilsAp::ConfIdSsid, name); + temp->setValue(WlanQtUtilsAp::ConfIdConnectionMode, netMode); + temp->setValue(WlanQtUtilsAp::ConfIdSecurityMode, secMode); + temp->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, wpaPskInUse); + temp->setValue(WlanQtUtilsAp::ConfIdWpsSupported, wpsSupported); + temp->setValue(WlanQtUtilsAp::ConfIdSignalStrength, signalStrength); + + mList.append(temp); +} + +void ContextWlanApList::clear() +{ + mList.clear(); +} + +/** + * This function will be called before the first test function is executed. + */ +void TestWlanWizardUi::initTestCase() +{ + qDebug("TestWlanWizardUi::initTestCase"); + + mMainWindow = new HbAutoTestMainWindow; + + mView = new TestView(); + + mMainWindow->addView(mView); + mMainWindow->setCurrentView(mView); + mMainWindow->installEventFilter(this); + mMainWindow->show(); + + QTest::qWait(1); + while (!mEvent) { + QTest::qWait(WaitTimeForUi); + } + mEvent = false; + + mApList = new ContextWlanApList(); + +} + +/** + * This function will be called after the last test function was executed. + */ +void TestWlanWizardUi::cleanupTestCase() +{ + qDebug("TestWlanWizardUi::cleanupTestCase"); + + qDebug("delete mApList"); + delete mApList; + mApList = NULL; + + qDebug("delete mMainWindow"); + mMainWindow->deleteLater(); + + qDebug("TestWlanWizardUi::cleanupTestCase exit"); +} + +/** + * This function will be called before each test function is executed. + */ +void TestWlanWizardUi::init() +{ + qDebug("TestWlanWizardUi::init()"); + + mView->createWizard(); + mWlanQtUtilsContext = new WlanQtUtilsContext(mView->mWizard->d_ptr->mWlanQtUtils.data()); +} + +/** + * This function will be called after each test function is executed. + */ +void TestWlanWizardUi::cleanup() +{ + qDebug("TestWlanWizardUi::cleanup()"); + + delete mWlanQtUtilsContext; + mView->deleteWizard(); + mApList->clear(); + QTest::qWait(1); +} + +// --------------------------------------------------------- +// TEST CASES +// --------------------------------------------------------- + + +void TestWlanWizardUi::tcStartWizard() +{ + qDebug("Start mView"); +} + +/*! + * + */ +void TestWlanWizardUi::tc01() +{ +#ifdef tc01_enabled + + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false); + + mWlanQtUtilsContext->setScanWlanDirectResult("huuhaa3421", mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", ""), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), false ); +#endif +} + +/*! + * + */ +void TestWlanWizardUi::tc02() +{ +#ifdef tc02_enabled + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false); + + mWlanQtUtilsContext->setScanWlanDirectResult("12345678901234567890123456789012", mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "1234567890123456789012345678901234567890"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + QCOMPARE( verifyActionButtons(ButtonEnabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); +#endif +} + +/*! + * + */ +void TestWlanWizardUi::tc03() +{ +#ifdef tc03_enabled + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false); + + mWlanQtUtilsContext->setScanWlanApsResult(mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + QCOMPARE( verifyActionButtons(ButtonEnabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); + QCOMPARE( verifyActionButtons(ButtonDisabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true ); + // Currently against the spec in http://wikis.in.nokia.com/pub/UXD/101ConnectionManager/occ_logical_flows_and_wireframes.pdf + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonHidden, ButtonEnabled), true ); + + QCOMPARE( mouseClickCancel(), true ); + + QTest::qWait(WaitTimeForUi); + +#endif +} + +/*! + * + */ +void TestWlanWizardUi::tc04() +{ +#ifdef tc04_enabled + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false); + + mWlanQtUtilsContext->setScanWlanApsResult(mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + QCOMPARE( verifyActionButtons(ButtonEnabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + + // Click previous button and next again + QCOMPARE( mouseClickPrevious(), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonEnabled, ButtonHidden), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); + QCOMPARE( verifyActionButtons(ButtonDisabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true ); + // Currently against the spec in http://wikis.in.nokia.com/pub/UXD/101ConnectionManager/occ_logical_flows_and_wireframes.pdf + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonHidden, ButtonEnabled), true ); + QCOMPARE( mouseClickFinish(), true ); +#endif +} + +/*! + * + */ +void TestWlanWizardUi::tc05() +{ +#ifdef tc05_enabled + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false); + + mWlanQtUtilsContext->setScanWlanDirectResult("huuhaa3421", mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + QCOMPARE( verifyActionButtons(ButtonEnabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); + QCOMPARE( verifyActionButtons(ButtonDisabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true ); + // Currently against the spec in http://wikis.in.nokia.com/pub/UXD/101ConnectionManager/occ_logical_flows_and_wireframes.pdf + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonHidden, ButtonEnabled), true ); + QCOMPARE( mouseClickFinish(), true ); +#endif +} + +/*! + * + */ +void TestWlanWizardUi::tc06() +{ +#ifdef tc06_enabled + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false); + + mWlanQtUtilsContext->setScanWlanApsResult(mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + QCOMPARE( verifyActionButtons(ButtonEnabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); + QCOMPARE( verifyActionButtons(ButtonDisabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true ); + // Currently against the spec in http://wikis.in.nokia.com/pub/UXD/101ConnectionManager/occ_logical_flows_and_wireframes.pdf + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonHidden, ButtonEnabled), true ); + QCOMPARE( mouseClickFinish(), true ); +#endif +} + +/*! + * Stop verifying buttons for views that have been already verified. + */ +void TestWlanWizardUi::tc07() +{ +#ifdef tc07_enabled + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWep, false, false); + + mWlanQtUtilsContext->setScanWlanApsResult(mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + + // Key query short pwd + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageKeyQuery), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "password"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( verifyDialogText("labelErrorNote", hbTrId("txt_occ_dialog_key_is_of_incorrect_length_please")), true ); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + + // Key query success + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( verifyDialogText("labelErrorNote", ""), true ); + QCOMPARE( insertTextToObject("lineEditKey", "12345"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true ); + QCOMPARE( mouseClickFinish(), true ); + +#endif +} + +/*! + * + */ +void TestWlanWizardUi::tc08() +{ +#ifdef tc08_enabled + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWep, false, false); + + mWlanQtUtilsContext->setScanWlanApsResult(mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageKeyQuery), true ); + QCOMPARE( mouseClickPrevious(), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageKeyQuery), true ); + +#endif +} + +/*! + * + */ +void TestWlanWizardUi::tc09() +{ +#ifdef tc09_enabled + + mWlanQtUtilsContext->setScanWlanDirectResult("huuhaa3421", mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageNetworkMode), true ); + QCOMPARE( verifyActionButtons(ButtonEnabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickPrevious(), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( mouseClickNext(), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageNetworkMode), true ); + QCOMPARE( selectRadioButton( "list", 0 ), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( verifyActionButtons(ButtonEnabled, ButtonEnabled, ButtonEnabled, ButtonHidden), true ); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageNetworkSecurity), true ); + QCOMPARE( verifyActionButtons(ButtonEnabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickPrevious(), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageNetworkMode), true ); + QCOMPARE( mouseClickNext(), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageNetworkSecurity), true ); + QCOMPARE( selectRadioButton( "list", 0 ), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( verifyActionButtons(ButtonEnabled, ButtonEnabled, ButtonEnabled, ButtonHidden), true ); + QCOMPARE( mouseClickNext(), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonHidden, ButtonEnabled), true ); + QCOMPARE( mouseClickFinish(), true ); +#endif +} + +/*! + * + */ +void TestWlanWizardUi::tc10() +{ +#ifdef tc10_enabled + mMainWindow->setOrientation(Qt::Horizontal, false); + QTest::qWait(WaitTimeForUi); + + mWlanQtUtilsContext->setScanWlanDirectResult("huuhaa3421", mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageNetworkMode), true ); + QCOMPARE( mouseClickPrevious(), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( mouseClickNext(), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageNetworkMode), true ); + QCOMPARE( selectRadioButton( "list", 0 ), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageNetworkSecurity), true ); + QCOMPARE( mouseClickPrevious(), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageNetworkMode), true ); + QCOMPARE( mouseClickNext(), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageNetworkSecurity), true ); + QCOMPARE( selectRadioButton( "list", 0 ), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true ); + QCOMPARE( mouseClickFinish(), true ); +#endif +} + +/*! + * + */ +void TestWlanWizardUi::tc11() +{ +#ifdef tc11_enabled + mMainWindow->setOrientation(Qt::Horizontal, false); + QTest::qWait(WaitTimeForUi); + + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWep, false, false); + + mWlanQtUtilsContext->setScanWlanApsResult(mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + + // Key query short pwd + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageKeyQuery), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "password"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( verifyDialogText("labelErrorNote", hbTrId("txt_occ_dialog_key_is_of_incorrect_length_please")), true ); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + + // Key query success + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "12345"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true ); + QCOMPARE( mouseClickFinish(), true ); +#endif +} + +/*! + * + */ +void TestWlanWizardUi::tc12() +{ +#ifdef tc12_enabled + + mView->mWizard->setParameters("huuhaa3421", + CMManagerShim::Infra, + CMManagerShim::WlanSecModeWep, + false, false, false); + + mView->showWizard(); + + mMainWindow->setOrientation(Qt::Horizontal, false); + QTest::qWait(WaitTimeForUi); + + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + QTest::qWait(4000); + +#endif +} + +/* + * + */ +void TestWlanWizardUi::tc13() +{ +#ifdef tc13_enabled + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWep, false, false); + + mWlanQtUtilsContext->setScanWlanApsResult(mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageKeyQuery), true ); + + QCOMPARE( insertTextToObject("lineEditKey", "passworddd"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( verifyDialogText("labelErrorNote", hbTrId("txt_occ_dialog_illegal_characters_in_key_please_c")), true ); + QTest::qWait(WaitTimeForUi); + +#endif +} + +void TestWlanWizardUi::tc14() +{ +#ifdef tc14_enabled + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWpa, true, false); + + mWlanQtUtilsContext->setScanWlanApsResult(mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + QTest::qWait(2000); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageKeyQuery), true ); + + QCOMPARE( insertTextToObject("lineEditKey", "1234"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( verifyDialogText("labelErrorNote", hbTrId("txt_occ_dialog_preshared_key_too_short_at_least")), true ); + QTest::qWait(WaitTimeForUi); +#endif +} + +/* + * wpa psk + */ +void TestWlanWizardUi::tc15() +{ +#ifdef tc15_enabled + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWpa, true, false); + + mWlanQtUtilsContext->setScanWlanApsResult(mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + QTest::qWait(2000); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageKeyQuery), true ); + + QCOMPARE( insertTextToObject("lineEditKey", "1234567890"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true ); + QCOMPARE( mouseClickFinish(), true ); +#endif +} + +/* + * no wpa psk + */ +void TestWlanWizardUi::tc16() +{ +#ifdef tc16_enabled + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWpa, false, false); + + mWlanQtUtilsContext->setScanWlanApsResult(mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true ); + QCOMPARE( mouseClickFinish(), true ); +#endif +} + +/* + * wpa2 psk + */ +void TestWlanWizardUi::tc17() +{ +#ifdef tc17_enabled + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWpa2, true, false); + + mWlanQtUtilsContext->setScanWlanApsResult(mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + QTest::qWait(2000); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageKeyQuery), true ); + + QCOMPARE( insertTextToObject("lineEditKey", "1234567890"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true ); + QCOMPARE( mouseClickFinish(), true ); +#endif +} + +/* + * wpa2 no psk + */ +void TestWlanWizardUi::tc18() +{ +#ifdef tc18_enabled + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWpa2, false, false); + + mWlanQtUtilsContext->setScanWlanApsResult(mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true ); + QCOMPARE( mouseClickFinish(), true ); +#endif +} + +/* + * wpa2 no psk + */ +void TestWlanWizardUi::tc19() +{ +#ifdef tc19_enabled + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWpa2, false, false); + + mWlanQtUtilsContext->setScanWlanApsResult(mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(0, false); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(false); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 20, 500), false ); +#endif +} + +/* + * Wlan network closed -> generic error + */ +void TestWlanWizardUi::tc20() +{ +#ifdef tc20_enabled + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWpa2, false, false); + + mWlanQtUtilsContext->setScanWlanApsResult(mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkClosed(100, 1); + mWlanQtUtilsContext->setConnectionSuccessed(false); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageGenericError, 10, 500), true ); + +#endif +} + +/* + * adhoc no psk + */ +void TestWlanWizardUi::tc21() +{ +#ifdef tc21_enabled + mApList->Add("huuhaa3421", CMManagerShim::Adhoc, CMManagerShim::WlanSecModeOpen, false, false); + + mWlanQtUtilsContext->setScanWlanApsResult(mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true ); + +#endif +} + +/* + * 802_1x + */ +void TestWlanWizardUi::tc22() +{ +#ifdef tc22_enabled + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecMode802_1x, false, false); + + mWlanQtUtilsContext->setScanWlanApsResult(mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true ); +#endif +} + +/* + * Wapi + */ +void TestWlanWizardUi::tc23() +{ +#ifdef tc23_enabled + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWapi, false, false); + + mWlanQtUtilsContext->setScanWlanApsResult(mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true ); +#endif +} + +/* + * Multiple AP scan match results + */ +void TestWlanWizardUi::tc24() +{ +#ifdef tc24_enabled + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWpa, false, false, 100); + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false, 400); + mApList->Add("foobar", CMManagerShim::Infra, CMManagerShim::WlanSecModeWep, false, false, 300); + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false, 200); + + mWlanQtUtilsContext->setScanWlanApsResult(mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true ); +#endif +} + +/* + * Multiple Direct scan match results + */ +void TestWlanWizardUi::tc25() +{ +#ifdef tc25_enabled + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWpa, false, false, 100); + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false, 400); + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWep, false, false, 300); + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false, 200); + + mWlanQtUtilsContext->setScanWlanDirectResult("huuhaa3421", mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true ); +#endif +} + +/*! + * Connect to open: + * - verifies IAP settings + * - ICT success + * - Finish button pressed + */ +void TestWlanWizardUi::tc_connect_to_open_success() +{ +#ifdef tc_connect_to_open_success_enabled + tc_connect_success( + "tc_connect_to_open_success", + CMManagerShim::Infra, + CMManagerShim::WlanSecModeOpen, + false, + "" ); +#endif +} + +/*! + * Connect to open + */ +void TestWlanWizardUi::tc_connect_to_open_success_hidden() +{ +#ifdef tc_connect_to_open_success_hidden_enabled + tc_connect_success( + "tc_connect_to_open_success_hidden", + CMManagerShim::Infra, + CMManagerShim::WlanSecModeOpen, + true, + "" ); +#endif +} + +/*! + * Connect to open + */ +void TestWlanWizardUi::tc_connect_to_open_success_adhoc() +{ +#ifdef tc_connect_to_open_success_adhoc_enabled + tc_connect_success( + "tc_connect_to_open_success_adhoc", + CMManagerShim::Adhoc, + CMManagerShim::WlanSecModeOpen, + true, + "" ); +#endif +} + +/*! + * Connect to open + */ +void TestWlanWizardUi::tc_connect_to_wep_success() +{ +#ifdef tc_connect_to_wep_success_enabled + tc_connect_success( + "tc_connect_to_wep_success", + CMManagerShim::Adhoc, + CMManagerShim::WlanSecModeWep, + true, + "abcde" ); +#endif +} + + +/*! + * Connect to open + */ +void TestWlanWizardUi::tc_connect_to_wpa_psk_success() +{ +#ifdef tc_connect_to_wpa_psk_success_enabled + tc_connect_success( + "tc_connect_to_wpa_psk_success", + CMManagerShim::Infra, + CMManagerShim::WlanSecModeWpa, + false, + "password" ); +#endif +} +/*! + * Connect to open + */ +void TestWlanWizardUi::tc_connect_to_wpa2_psk_success() +{ +#ifdef tc_connect_to_wpa2_psk_success_enabled + tc_connect_success( + "tc_connect_to_wpa2_psk_success", + CMManagerShim::Adhoc, + CMManagerShim::WlanSecModeWpa2, + false, + "password" ); +#endif +} + + +/*! + * Connect to open: + * - Opens + * - ICT success + * - Cancel pressed in summary page + */ +void TestWlanWizardUi::tc_connect_to_open_success_cancel() +{ +#ifdef tc_connect_to_open_success_cancel_enabled + + mWlanQtUtilsContext->setCreateWlanIapResult(3); + mWlanQtUtilsContext->setConnectionSuccessed(true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(3); + mWlanQtUtilsContext->setSignalIctResult(3, true); + + mView->mWizard->setParameters( + "tc_connect_to_open_success_cancel", + CMManagerShim::Infra, + CMManagerShim::WlanSecModeOpen, + false, false, false); + + mView->showWizard(); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true ); + QTest::qWait(WaitTimeForUi); + + // Ignore previous calls + mWlanQtUtilsContext->calledMethods(); + + QCOMPARE( mouseClickCancel(), true ); + + QStringList calledMethods; + calledMethods + << "disconnectIap" + << "deleteIap"; + + QCOMPARE(mWlanQtUtilsContext->calledMethods(), calledMethods); + QCOMPARE( mView->verifyStatus(TestView::WizardStatusSignalCancelled), true); +#endif +} + +/*! + * Helpper test case for testing success case with compinations of provided + * parameters. + */ +void TestWlanWizardUi::tc_connect_success( + const QString &ssid, + int networkMode, + int securityMode, + bool hidden, + QString key) +{ + + mWlanQtUtilsContext->setCreateWlanIapResult(2); + mWlanQtUtilsContext->setConnectionSuccessed(true); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(2); + mWlanQtUtilsContext->setSignalIctResult(2, true); + + mView->mWizard->setParameters( + ssid, + networkMode, + securityMode, + true, + hidden, + false); + + WlanQtUtilsAp ap; + ap.setValue(WlanQtUtilsAp::ConfIdConnectionMode, networkMode); + ap.setValue(WlanQtUtilsAp::ConfIdSecurityMode, securityMode); + ap.setValue(WlanQtUtilsAp::ConfIdSsid, ssid); + ap.setValue(WlanQtUtilsAp::ConfIdHidden, hidden); + + QStringList calledMethods; + calledMethods << "WlanQtUtils"; + QCOMPARE(mWlanQtUtilsContext->calledMethods(), calledMethods); + + mView->showWizard(); + if (securityMode == CMManagerShim::WlanSecModeWep || + securityMode == CMManagerShim::WlanSecModeWpa || + securityMode == CMManagerShim::WlanSecModeWpa2) { + // Key query short pwd + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageKeyQuery), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonEnabled, ButtonHidden), true ); + QTest::qWait(WaitTimeForUi); + + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(WaitTimeForUi); + + if (securityMode == CMManagerShim::WlanSecModeWep) { + ap.setValue(WlanQtUtilsAp::ConfIdWepKey1, key ); + ap.setValue(WlanQtUtilsAp::ConfIdWepKey2, key ); + ap.setValue(WlanQtUtilsAp::ConfIdWepKey3, key ); + ap.setValue(WlanQtUtilsAp::ConfIdWepKey4, key ); + ap.setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, CMManagerShim::WepKeyIndex1); + QCOMPARE( insertTextToObject("lineEditKey", "abcde"), true ); + } + else { + QCOMPARE( insertTextToObject("lineEditKey", "password"), true ); + ap.setValue(WlanQtUtilsAp::ConfIdWpaPsk, key ); + ap.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true ); + } + QCOMPARE( mouseClickObject("dialog"), true ); + + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); + QCOMPARE( verifyActionButtons(ButtonDisabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + QTest::qWait(WaitTimeForUi); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonHidden, ButtonEnabled), true ); + QTest::qWait(WaitTimeForUi); + } + else { + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); + + QTest::qWait(WaitTimeForUi); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true ); + QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonHidden, ButtonEnabled), true ); + QTest::qWait(WaitTimeForUi); + } + + calledMethods.clear(); + calledMethods + << "createIap" + << "activeIap" + << "connectIap"; + QCOMPARE( mWlanQtUtilsContext->calledMethods(), calledMethods); + + QCOMPARE( mWlanQtUtilsContext->verifyWlanIapSettings(ap), true); + + QTest::qWait(WaitTimeForUi); + QCOMPARE( mouseClickFinish(), true ); + QCOMPARE( mView->verifyStatus(TestView::WizardStatusSignalFinished, 2), true); +} + +/* + * Ict Result enumerator used. Hotspot. + */ +void TestWlanWizardUi::tc26() +{ +#ifdef tc26_enabled + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWpa, false, false, 100); + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false, 400); + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWep, false, false, 300); + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false, 200); + + mWlanQtUtilsContext->setScanWlanDirectResult("huuhaa3421", mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, IctsHotspotPassed); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(1000); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(1000); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(1000); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true ); + QTest::qWait(5000); +#endif +} + +/* + * Ict Result enumerator used. Ict canceled. + */ +void TestWlanWizardUi::tc27() +{ +#ifdef tc27_enabled + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWpa, false, false, 100); + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false, 400); + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWep, false, false, 300); + mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false, 200); + + mWlanQtUtilsContext->setScanWlanDirectResult("huuhaa3421", mApList->List()); + mWlanQtUtilsContext->setCreateWlanIapResult(100); + mWlanQtUtilsContext->setSignalIctResult(100, IctsCanceled); + mWlanQtUtilsContext->setSignalWlanNetworkOpened(100); + mWlanQtUtilsContext->setConnectionSuccessed(true); + + QCOMPARE( mouseClickObject("lineEditKey"), true ); + QTest::qWait(1000); + QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true ); + QTest::qWait(1000); + QCOMPARE( mouseClickObject("dialog"), true ); + QTest::qWait(1000); + QCOMPARE( mouseClickNext(), true ); + + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true ); + QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageGenericError, 10, 500), true ); + QTest::qWait(5000); +#endif +} + +/*! + * Filter to catch focus event to the text editor widget. + */ +bool TestWlanWizardUi::eventFilter(QObject *obj, QEvent *event) +{ + if (obj == mMainWindow && event->type() == QEvent::Show) { + mMainWindow->removeEventFilter(this); + mEvent = true; + } + return false; +} + +QGraphicsWidget* TestWlanWizardUi::findChildItem(const QString &itemName, QGraphicsWidget *widget) +{ + QList list = widget->childItems(); + for (int i = 0; i < list.size(); i++) { + QGraphicsWidget* item = (QGraphicsWidget*) list[i]; + if (item->objectName() == itemName) { + return item; + } + else if ((item = findChildItem(itemName, item))) { + return item; + } + } + return 0; +} + +bool TestWlanWizardUi::verifyCurrentPage(int pageId, int retries, int wait_ms) +{ + for (int i = 0; i < retries; i++) { + QTest::qWait(wait_ms); + + WlanWizardPrivate *pPrivate = mView->mWizard->d_ptr; + HbWidget* current = qobject_cast (pPrivate->mStackedWidget->currentWidget()); + WlanWizardPage *page = pPrivate->mPageMapper[current]; + + // TODO: verify title in this method + + if (page == pPrivate->mPages[pageId]) { + switch(pageId) { + case WlanWizardPageInternal::PageEapStart: + return true; + case WlanWizardPageInternal::PageGenericError: + return true; + case WlanWizardPageInternal::PageKeyQuery: + // TODO: add parameter SSID, FAILS without it + return true; // verifyDialogText("dialog", hbTrId("txt_occ_dialog_enter_key_for_1")); + case WlanWizardPageInternal::PageNetworkMode: + return verifyDialogText("dialog_6", hbTrId("txt_occ_dialog_select_network_mode_and_status")); + case WlanWizardPageInternal::PageNetworkSecurity: + return verifyDialogText("dialog_6", hbTrId("txt_occ_dialog_select_network_security_mode")); + case WlanWizardPageInternal::PageProcessSettings: + // TODO: add parameter SSID, FAILS without it + return true; // verifyDialogText("dialog", hbTrId("txt_occ_dialog_checking_connection_to_1")); + case WlanWizardPageInternal::PageScanning: + return true; // verifyDialogText("dialog", hbTrId("TODO_1")); + case WlanWizardPageInternal::PageSsid: + return verifyDialogText("dialog", hbTrId("txt_occ_dialog_insert_the_name_of_the_new_wlan_net")); + case WlanWizardPageInternal::PageSummary: + if (pPrivate->mTitle->plainText() != hbTrId("txt_occ_title_wlan_setup_wizard_summary")){ + qWarning("TestWlanWizardUi::verifyCurrentPage: Invalid title"); + return false; + } + return true; + case WlanWizardPageInternal::PageWpsStart: + return true; + default: + return true; + } + } + } + qWarning("verifyCurrentPage: expected: %d", pageId); + return false; +} + +bool TestWlanWizardUi::verifyDialogText(const QString objName, const QString text) +{ + HbWidget* current = qobject_cast ( + mView->mWizard->d_ptr->mStackedWidget->currentWidget()); + HbLabel* widget = (HbLabel*) findChildItem(objName, current); + + if (widget) { + if(widget->plainText() == text) { + return true; + } + else { + qWarning("verifyDialogText: not match"); + qDebug() << "expect: " << text; + qDebug() << "actual: " << widget->plainText(); + } + } else { + qWarning("verifyDialogText: object not found"); + } + + return false; +} + +bool TestWlanWizardUi::verifyActionButtons(ButtonStatus prevStatus, + ButtonStatus cancelStatus, + ButtonStatus nextStatus, + ButtonStatus finishStatus) +{ + WlanWizardPrivate *pPrivate = mView->mWizard->d_ptr; + ButtonStatus prevReally = ButtonHidden; + ButtonStatus cancelReally = ButtonHidden; + ButtonStatus nextReally = ButtonHidden; + ButtonStatus finishReally = ButtonHidden; + + if(pPrivate->mActionPrevious->isVisible()) { + if(pPrivate->mActionPrevious->isEnabled()) { + prevReally = ButtonEnabled; + } else { + prevReally = ButtonDisabled; + } + } + + if(pPrivate->mActionCancel->isVisible()) { + if(pPrivate->mActionCancel->isEnabled()) { + cancelReally = ButtonEnabled; + } else { + cancelReally = ButtonDisabled; + } + } + + if(pPrivate->mActionNext->isVisible()) { + if(pPrivate->mActionNext->isEnabled()) { + nextReally = ButtonEnabled; + } else { + nextReally = ButtonDisabled; + } + } + + if(pPrivate->mActionFinish->isVisible()) { + if(pPrivate->mActionFinish->isEnabled()) { + finishReally = ButtonEnabled; + } else { + finishReally = ButtonDisabled; + } + } + bool ret = true; + if (prevReally != prevStatus){ + qWarning("Previous Button: really: %d, status: %d", prevReally, prevStatus); + ret = false; + } + if (cancelReally != cancelStatus){ + qWarning("Cancel Button: really: %d, status: %d", cancelReally, cancelStatus); + ret = false; + } + if (nextReally != nextStatus){ + qWarning("Next Button: really: %d, status: %d", nextReally, nextStatus); + ret = false; + } + if (finishReally != finishStatus){ + qWarning("Finish Button: really: %d, status: %d", finishReally, finishStatus); + ret = false; + } + + return ret; +} + +bool TestWlanWizardUi::mouseClickObject(const QString objName) +{ + HbWidget* current = qobject_cast ( + mView->mWizard->d_ptr->mStackedWidget->currentWidget()); + HbWidget* widget = (HbWidget*) findChildItem(objName, current); + + if (widget) { + HbAutoTest::mouseClick(mMainWindow, widget); + widget->clearFocus(); + widget->setFocus(); + return true; + } + qWarning("mouseClickObject: object not found"); + + return false; +} + +bool TestWlanWizardUi::insertTextToObject(const QString objName, const QString text) +{ + HbWidget* current = qobject_cast ( + mView->mWizard->d_ptr->mStackedWidget->currentWidget()); + HbWidget* widget = (HbWidget*) findChildItem(objName, current); + + if (widget) { + for (int i = 0; i < text.size(); i++) { + HbAutoTest::keyPress(mMainWindow, text.at(i).toAscii(), 0, 10); + QTest::qWait(20); + } + return true; + } + qWarning("insertTextToObject: object not found"); + return false; +} + +bool TestWlanWizardUi::selectRadioButton(const QString objName, int index) +{ + HbWidget* current = qobject_cast ( + mView->mWizard->d_ptr->mStackedWidget->currentWidget()); + TestRadioButtonList* widget = (TestRadioButtonList*) findChildItem(objName, current); + + if (widget) { + widget->setSelected(index); + widget->emitActivated(widget->currentIndex()); + return true; + } + return false; +} + +bool TestWlanWizardUi::mouseClickNext() +{ + if (mView->mWizard->d_ptr->mActionNext->isEnabled()) { + mView->mWizard->d_ptr->mActionNext->activate(QAction::Trigger); + return true; + } + qWarning("Next button not enabled"); + return false; +} + +bool TestWlanWizardUi::mouseClickPrevious() +{ + if (mView->mWizard->d_ptr->mActionPrevious->isEnabled()) { + mView->mWizard->d_ptr->mActionPrevious->activate(QAction::Trigger); + return true; + } + qWarning("Previous button not enabled"); + return false; +} + +bool TestWlanWizardUi::mouseClickCancel() +{ + if (mView->mWizard->d_ptr->mActionCancel->isEnabled()) { + mView->mWizard->d_ptr->mActionCancel->activate(QAction::Trigger); + return true; + } + qWarning("Cancel button not enabled"); + return false; +} + +bool TestWlanWizardUi::mouseClickFinish() +{ + if (mView->mWizard->d_ptr->mActionFinish->isEnabled()) { + mView->mWizard->d_ptr->mActionFinish->activate(QAction::Trigger); + return true; + } + qWarning("Finish button not enabled"); + return false; +} + +TestView::TestView() : mWizard(NULL) +{ + qDebug("TestView::TestView()"); +} + +TestView::~TestView() +{ + qDebug("TestView::~TestView()"); +} + +void TestView::createWizard() +{ + qDebug("TestView::createWizard"); + Q_ASSERT(mWizard == NULL); + mWizard = new WlanWizard(mainWindow()); + bool ok; + ok = connect( + mWizard, SIGNAL(finished(int, bool)), + this, SLOT(finished(int, bool)), + Qt::QueuedConnection); + Q_ASSERT(ok); + + ok = connect( + mWizard, SIGNAL(cancelled()), + this, SLOT(cancelled()), + Qt::QueuedConnection); + Q_ASSERT(ok); + + mWizardStatus = WizardStatusSignalNone; + mConnectedIapId = -100; +} + +void TestView::showWizard() +{ + qDebug("TestView::showWizard()"); + Q_ASSERT(mWizard); + mWizard->show(); +} + +void TestView::deleteWizard() +{ + qDebug("TestView::deleteWizard"); + + Q_ASSERT(mWizard != NULL); + QTest::qWait(10); + QTest::qWait(10); + QMetaObject::invokeMethod(mWizard, "deleteLater", Qt::QueuedConnection); + QTest::qWait(10); + mWizard = NULL; +} + +void TestView::finished(int iapId, bool connected) +{ + qDebug("TestView::complete(), iap id: %d, connected: %d", iapId, connected); + + if (mWizardStatus != WizardStatusSignalNone) { + qWarning("TestView::finished: multiple signals received"); + mWizardStatus = WizardStatusSignalUndefined; + } else { + mWizardStatus = WizardStatusSignalFinished; + mConnectedIapId = iapId; + } +} + +void TestView::cancelled() +{ + qDebug("TestView::cancelled()"); + if (mWizardStatus != WizardStatusSignalNone) { + qWarning("TestView::cancelled: multiple signals received"); + mWizardStatus = WizardStatusSignalUndefined; + } else { + mWizardStatus = WizardStatusSignalCancelled; + } +} + +bool TestView::verifyStatus(WizardStatusSignal status, int iapId ) +{ + // Since connections to cancelled and finished signals are queued + // we need to use qWait() here. + QTest::qWait(100); + bool ret = true; + if (status != mWizardStatus){ + qWarning("TestView::verifyStatus, status: expected: %d, actual: %d", status, mWizardStatus); + ret = false; + } + if (status == WizardStatusSignalFinished) { + if (iapId != mConnectedIapId) { + qWarning("TestView::verifyStatus, iapid: expected: %d, actual: %d", iapId, mConnectedIapId); + ret = false; + } + } + return ret; +} diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/t_wlanwizard/ut/testwlanwizardui.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/t_wlanwizard/ut/testwlanwizardui.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * 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". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + */ + +#ifndef TESTWLANWIZARDRNDUI_H_ +#define TESTWLANWIZARDRNDUI_H_ + +#include +#include +#include + +class QGraphicsItem; +class HbAutoTestMainWindow; +class WlanWizard; +class WlanQtUtilsContext; +class WlanQtUtils; +class WlanQtUtilsAp; +class QString; + +class ContextWlanApList +{ +public: + ContextWlanApList(); + ~ContextWlanApList(); + + void Add(QString name, + int netMode, + int secMode, + bool wpaPskInUse, + bool wpsSupported, + int signalStrength = 0); + + void clear(); + + const QList > &List() { return mList; } +private: + QList > mList; +}; + +class TestView: public HbView +{ +Q_OBJECT + +public: + enum WizardStatusSignal{ + WizardStatusSignalNone, + WizardStatusSignalFinished, + WizardStatusSignalCancelled, + WizardStatusSignalUndefined, + }; + +public: + TestView(); + virtual ~TestView(); + + void createWizard(); + void showWizard(); + + bool verifyStatus(WizardStatusSignal status, int iapId = -100); + +private slots: + void finished(int iapId, bool connected); + void cancelled(); + +public: + void deleteWizard(); + +public: + WlanWizard *mWizard; + +private: + WizardStatusSignal mWizardStatus; + int mConnectedIapId; +}; + + +class TestWlanWizardUi: public QObject +{ +Q_OBJECT + +public slots: + // Test framework functions + void initTestCase(); + void cleanupTestCase(); + void init(); + void cleanup(); + +private slots: + // Test cases + void tcStartWizard(); + void tc01(); + void tc02(); + void tc03(); + void tc04(); + void tc05(); + void tc06(); + void tc07(); + void tc08(); + void tc09(); + void tc10(); + void tc11(); + void tc12(); + void tc13(); + void tc14(); + void tc15(); + void tc16(); + void tc17(); + void tc18(); + void tc19(); + void tc20(); + void tc21(); + void tc22(); + void tc23(); + void tc24(); + void tc25(); + void tc26(); + void tc27(); + void tc_connect_to_open_success(); + void tc_connect_to_open_success_hidden(); + void tc_connect_to_open_success_adhoc(); + void tc_connect_to_wep_success(); + void tc_connect_to_wpa_psk_success(); + void tc_connect_to_wpa2_psk_success(); + void tc_connect_to_open_success_cancel(); + +protected: + + enum ButtonStatus { + ButtonHidden, + ButtonDisabled, + ButtonEnabled + }; + /*! + * Reimplements QObject function that is invoked on any event. This + * function handles only a focus event to mSsid edit field. + * @param obj contains the object, where the event originates from. + * @param event contains the event id. + */ + bool eventFilter(QObject *obj, QEvent *event); + + QGraphicsWidget* findChildItem(const QString &itemName, QGraphicsWidget *widget); + + bool verifyCurrentPage(int pageId, int retries = 10, int wait_ms = 200); + bool verifyDialogText(const QString objName, const QString text); + bool verifyActionButtonVisibility(bool prevVisible, bool cancelVisible, + bool nextVisible, bool finishVisible); + bool verifyActionButtons(ButtonStatus prevStatus, ButtonStatus cancelStatus, + ButtonStatus nextStatus, ButtonStatus finishStatus); + bool mouseClickObject(const QString objName); + bool insertTextToObject(const QString objName, const QString text); + bool selectRadioButton(const QString objName, int index); + + bool mouseClickNext(); + bool mouseClickPrevious(); + bool mouseClickCancel(); + bool mouseClickFinish(); + +private: + +private: + void tc_connect_success( + const QString &ssid, + int networkMode, + int securityMode, + bool hidden, + QString key); + + bool mEvent; + + // Test data + TestView *mView; + HbAutoTestMainWindow *mMainWindow; + + WlanQtUtilsContext *mWlanQtUtilsContext; + + ContextWlanApList *mApList; + + bool mNoCleanup; + +}; + +#endif /* TESTWLANWIZARDRNDUI_H_ */ diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/t_wlanwizard/ut/testwlanwizardui_conf.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/t_wlanwizard/ut/testwlanwizardui_conf.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * 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". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + */ + +// System includes + +// User includes + +// External function prototypes + +// Local constants + +//! 1sec +#define WaitTimeForUi 1000 + +/* +#define tc01_enabled +#define tc02_enabled +#define tc03_enabled +#define tc04_enabled +#define tc05_enabled +#define tc06_enabled +#define tc07_enabled +#define tc08_enabled +#define tc09_enabled +#define tc10_enabled +#define tc11_enabled +#define tc12_enabled +#define tc13_enabled +#define tc14_enabled +#define tc15_enabled +#define tc16_enabled +#define tc17_enabled +#define tc18_enabled +#define tc19_enabled +#define tc20_enabled +#define tc21_enabled +#define tc22_enabled +#define tc23_enabled +#define tc24_enabled +#define tc25_enabled +// test cases covering "ict_result_enum_used" build configuration +#define tc26_enabled +#define tc27_enabled + +#define tc_connect_to_open_success_enabled +#define tc_connect_to_open_success_hidden_enabled; +#define tc_connect_to_open_success_adhoc_enabled; +*/ +#define tc_connect_to_wep_success_enabled; +#define tc_connect_to_wpa_psk_success_enabled; +#define tc_connect_to_wpa2_psk_success_enabled; +#define tc_connect_to_open_success_cancel_enabled diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/t_wlanwizard/ut/ut.pri --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/t_wlanwizard/ut/ut.pri Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,29 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# 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". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# +# Description: +# UT for Wlan wizard testing +# + +HEADERS += \ + ut/hbautotest.h \ + ut/testwlanwizard.h \ + ut/testwlanwizardui.h \ + ut/testwlanwizardui_conf.h + +SOURCES += \ + ut/main.cpp \ + ut/hbautotest.cpp \ + ut/testwlanwizardui.cpp \ + ut/testwlanwizard.cpp \ No newline at end of file diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/t_wlanwizard/wst_script/wst_make.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/t_wlanwizard/wst_script/wst_make.bat Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,183 @@ +::============================================================================= +:: Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +:: All rights reserved. +:: This component and the accompanying materials are made available +:: 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". +:: +:: Initial Contributors: +:: Nokia Corporation - initial contribution. +:: +:: Contributors: +:: +:: Description: +:: +::============================================================================= +:: +:: Following commands are implemented: +:: - CLEAN_OLD_FILES +:: - RUN_TEST_CASES +:: - GENERATE_REPORTS +:: - SHOW_RESULTS +:: - START_BROWSER +::============================================================================= + +::----------------------------------------------------------------------------- +:: Do the preparations: +:: - Don't show the commands +:: - Use local parameters -- don't pollute the global one +::----------------------------------------------------------------------------- +@echo off + +::echo *** WST_MAKE: START: +setlocal + +::----------------------------------------------------------------------------- +:: Check input +:: +:: Parameters that are required: +:: 1) wst_root_dir +:: 2) log_file_name +:: 3) the command +::----------------------------------------------------------------------------- + +:: (1) +if not exist %1 goto ERROR +if [%1]==[] goto ERROR +set wst_root_dir=%1 +set wst_log_dir=%1\wst_log +set wst_report_dir=%1\wst_report +set wlanwizard_root_dir=%1\.. +set wlanwizard_test_dir=%1\ + +:: (2) +if [%2]==[] goto ERROR +set log_file_name=%2 +set log_file=%wst_log_dir%\%log_file_name% +if not exist %log_file% goto ERROR +echo *** DATE AND TIME: %date%, %time% >> %log_file% +::echo *** WST_MAKE: INFO: WLAN Wizard root dir: %wlanwizard_root_dir% +::echo *** WST_MAKE: INFO: WLAN Wizard test dir: %wlanwizard_test_dir% +::echo *** WST_MAKE: INFO: WST log dir: %wst_log_dir% +::echo *** WST_MAKE: INFO: WST log file: %log_file% + +:: (3) +if [%3]==[] goto ERROR +goto %3 + +:: Error if label not found. +goto ERROR + +::----------------------------------------------------------------------------- +:CLEAN_OLD_FILES +::----------------------------------------------------------------------------- + +echo *** WST_MAKE: CLEAN_OLD_FILES: +echo *** WST_LOG: CLEAN_OLD_FILES >> %log_file% + +move %wst_log_dir%\%log_file_name% %wst_root_dir% +del /F /S /Q %wst_log_dir%\* +del /F /S /Q %wst_report_dir%\* +rmdir /S /Q %wst_log_dir%\CMTHTML +rmdir /S /Q %wst_log_dir%\CTCHTML +move %wst_root_dir%\%log_file_name% %wst_log_dir% +del \epoc32\winscw\c\data\wlanwizard_qtext_log.txt + +goto THE_END + +::----------------------------------------------------------------------------- +:COMPILE_TEST_CASES +::----------------------------------------------------------------------------- + +echo *** WST_MAKE: COMPILE_TEST_CASES: +echo *** WST_LOG: COMPILE_TEST_CASES >> %log_file% + +cd %wlanwizard_test_dir% +call sbs reallyclean >> %log_file% 2>&1 +call make distclean >> %log_file% 2>&1 +call qmake "CONFIG += coverage_test debug" >> %log_file% 2>&1 +call sbs -c winscw_udeb >> %log_file% 2>&1 +:: Call CTC instrumentation script. Source directories hard coded, because NO_EXCLUDE does not like % characters... +call ctcwrap -C EXCLUDE=* -C NO_EXCLUDE+..\src\*.cpp -2comp -n %wst_log_dir%\MON.sym -i d -v sbs -c winscw_udeb >> %log_file% 2>&1 + +goto THE_END + +::----------------------------------------------------------------------------- +:RUN_TEST_CASES +::----------------------------------------------------------------------------- + +echo *** WST_MAKE: RUN_TEST_CASES: +echo *** WST_LOG: RUN_TEST_CASES >> %log_file% + +call \epoc32\release\winscw\udeb\t_wlanwizard.exe -o c:\data\wlanwizard_qtext_log.txt + +goto THE_END + +::----------------------------------------------------------------------------- +:GENERATE_REPORTS +::----------------------------------------------------------------------------- + +echo *** WST_MAKE: GENERATE_REPORTS: +echo *** WST_LOG: GENERATE_REPORTS >> %log_file% + +cd %wst_log_dir% + +call ctcpost -p %wst_log_dir%\ctc_coverage.txt +call ctc2html -nsb -i %wst_log_dir%\ctc_coverage.txt + +call dir /s /b %wlanwizard_root_dir%\src\*.cpp > %wst_log_dir%\raw_filelist.txt + +call findstr /I /V "moc_" %wst_log_dir%\raw_filelist.txt > %wst_log_dir%\filelist.txt +call cmt -f %wst_log_dir%\filelist.txt -o cmt_metrics.txt >> %log_file% +call cmt2html -nsb -i cmt_metrics.txt + +:: Clean up temp files +call del %wst_log_dir%\*filelist.txt + +echo *** WST_MAKE: COPY LOGS: +call copy %TEMP%\epocwind.out %wst_log_dir%\epocwind.txt + +goto THE_END + +::----------------------------------------------------------------------------- +:SHOW_RESULTS +::----------------------------------------------------------------------------- + +echo *** WST_MAKE: SHOW_RESULTS: +echo *** WST_LOG: SHOW_RESULTS >> %log_file% +echo *** Module tests: +call findstr /C:"Totals: " \epoc32\winscw\c\data\wlanwizard_qtext_log.txt +echo *** Coverage: +call findstr /C:"Number of " %wst_log_dir%\ctc_coverage.txt +call findstr /C:"TER " %wst_log_dir%\ctc_coverage.txt + +goto THE_END + +::----------------------------------------------------------------------------- +:START_BROWSER +::----------------------------------------------------------------------------- + +echo *** WST_MAKE: START_BROWSER: +echo *** WST_LOG: START_BROWSER >> %log_file% +echo. +echo Starting up browser to show the results + +start %wst_root_dir%\wst_report\coverage.html + +goto THE_END + +::----------------------------------------------------------------------------- +:ERROR +::----------------------------------------------------------------------------- + +echo *** WST_MAKE: ERROR: +endlocal +echo wst_make *** Error (unknown parameter) >> %log_file% + +goto THE_END + +::----------------------------------------------------------------------------- +:THE_END +::----------------------------------------------------------------------------- +:: echo *** WST_MAKE: END: diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/traces/OstTraceDefinitions.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/traces/OstTraceDefinitions.h Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,21 @@ +/* + * 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 "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * OST Trace definition file for WLAN Wizard + */ + +#ifndef __OSTTRACEDEFINITIONS_H__ +#define __OSTTRACEDEFINITIONS_H__ +#include +#endif diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/traces/trace.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/traces/trace.properties Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,54 @@ + + + + ConfSsid + ConfNetworkMode + ConfSecurityMode + ConfKeyWpa + ConfKeyWep1 + ConfKeyWep2 + ConfKeyWep3 + ConfKeyWep4 + ConfKeyWepDefault + ConfIctStatus + ConfIapId + ConfConnected + ConfHiddenWlan + ConfUsePsk + ConfProcessSessings + ConfGenericErrorString + + + PageNone + PageProcessSettings + PageGenericError + PageSsid + PageScanning + PageNetworkSecurity + PageKeyQuery + PageNetworkMode + PageSummary + EapPageOuterType + EapPageCertificateCa + EapPageCertificateUser + EapPageIdentity + EapPageInnerTypePeap + EapPageInnerTypeEapTtls + EapPageNewPacStorePassword + EapPagePromptPacStorePassword + EapPageUsernamePassword + + + KeyStatusOk + KeyStatusIllegalCharacters + KeyStatusWpaTooShort + KeyStatusWpaTooLong + KeyStatusWepInvalidLength + + + SsidStatusOk + SsidStatusIllegalCharacters + SsidStatusInvalidLength + + + diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/wlanwizard.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/wlanwizard.pro Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,117 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# 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". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# +# Description: +# WLAN Settings Wizard +# + +TEMPLATE = lib +TARGET = wlanwizard + +DEFINES += BUILD_WLAN_WIZARD_DLL + +VERSION = 0.0.1 + +CONFIG += hb + +MOC_DIR = build +RCC_DIR = build + +RESOURCES += resources/resource.qrc + +TRANSLATIONS = wlanwizard.ts + +HEADERS += \ + inc/wlanwizard.h \ + inc/wlanwizard_p.h \ + inc/wlanwizardhelper.h \ + inc/wlanwizardpage.h \ + inc/wlanwizardpagegenericerror.h \ + inc/wlanwizardpageinternal.h \ + inc/wlanwizardpagekeyquery.h \ + inc/wlanwizardpageprocessingsettings.h \ + inc/wlanwizardpagesummary.h \ + inc/wlanwizardsummaryviewitem.h \ + inc/wlanwizardutils.h + +SOURCES += src/wlanwizard.cpp \ + src/wlanwizard_p.cpp \ + src/wlanwizardpagegenericerror.cpp \ + src/wlanwizardpageinternal.cpp \ + src/wlanwizardpagekeyquery.cpp \ + src/wlanwizardpageprocessingsettings.cpp \ + src/wlanwizardpagesummary.cpp \ + src/wlanwizardsummaryviewitem.cpp \ + src/wlanwizardutils.cpp + +LIBS += -lwlanqtutilities + +symbian { + INCLUDEPATH += \ + inc \ + ..\inc \ + + TARGET.UID3 = 0x2002C39A + TARGET.CAPABILITY = CAP_GENERAL_DLL + TARGET.EPOCALLOWDLLDATA = 1 + + # Localition of directories for def files + defFilePath = . + + # OST trace system requires traces directory to be in USERINCLUDES + MMP_RULES += "USERINCLUDE traces" + + BLD_INF_RULES.prj_exports += \ + "rom/wlanwizard.iby CORE_MW_LAYER_IBY_EXPORT_PATH(wlanwizard.iby)" + + BLD_INF_RULES.prj_exports += \ + "rom/wlanwizard_resources.iby LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(wlanwizard_resources.iby)" + + # Export wlanwizard and wlanwizard plugin apis + BLD_INF_RULES.prj_exports += \ + "inc/wlanwizard.h |../inc/wlanwizard.h" \ + "inc/wlanwizardhelper.h |../inc/wlanwizardhelper.h" \ + "inc/wlanwizardpage.h |../inc/wlanwizardpage.h" \ + "inc/wlanwizardplugin.h |../inc/wlanwizardplugin.h" +} + +# this enables "eap wizard" +wlanwizard_rnd_eap|wlanwizard_rnd_all{ + DEFINES += WLAN_WIZARD_RND_EAP + LIBS += -leapwizard +} + +# this enables "wps wizard" +wlanwizard_rnd_wps|wlanwizard_rnd_all{ + DEFINES += WLAN_WIZARD_RND_WPS + LIBS += -lwpswizard +} + +# this enables "add wlan manual" feature +wlanwizard_rnd|wlanwizard_rnd_all|wlanwizard_rnd_eap|wlanwizard_rnd_wps{ + DEFINES += WLAN_WIZARD_RND + HEADERS += \ + inc/wlanwizardpagenetworkmode.h \ + inc/wlanwizardpagescanning.h \ + inc/wlanwizardpagesecuritymode.h \ + inc/wlanwizardpagessid.h + + SOURCES += \ + src/wlanwizardpagenetworkmode.cpp \ + src/wlanwizardpagescanning.cpp \ + src/wlanwizardpagesecuritymode.cpp \ + src/wlanwizardpagessid.cpp +} + + diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/wlanwizard_rnd.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/wlanwizard_rnd.pro Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,33 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# 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". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# +# Description: +# WLAN Settings Wizard +# + +include(wlanwizard.pro) + +DEFINES += WLAN_WIZARD_RND + +HEADERS += \ + inc/wlanwizardpagenetworkmode.h \ + inc/wlanwizardpagescanning.h \ + inc/wlanwizardpagesecuritymode.h \ + inc/wlanwizardpagessid.h + +SOURCES += \ + src/wlanwizardpagenetworkmode.cpp \ + src/wlanwizardpagescanning.cpp \ + src/wlanwizardpagesecuritymode.cpp \ + src/wlanwizardpagessid.cpp diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/wlanwizard_rnd_all.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/wlanwizard_rnd_all.pro Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,25 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# 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". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# +# Description: +# WLAN Settings Wizard +# + +include(wlanwizard_rnd.pro) + +DEFINES += WLAN_WIZARD_RND_WPS +DEFINES += WLAN_WIZARD_RND_EAP + +LIBS += -lwpswizard +LIBS += -leapwizard diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/wlanwizard_rnd_eap.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/wlanwizard_rnd_eap.pro Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,23 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# 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". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# +# Description: +# WLAN Settings Wizard +# + +include(wlanwizard_rnd.pro) + +DEFINES += WLAN_WIZARD_RND_EAP + +LIBS += -leapwizard diff -r ab513c8439db -r e8f4211554fb wlanutilities/wlanwizard/wlanwizard_rnd_wps.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlanutilities/wlanwizard/wlanwizard_rnd_wps.pro Mon May 24 21:11:39 2010 +0300 @@ -0,0 +1,23 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# 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". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# +# Description: +# WLAN Settings Wizard +# + +include(wlanwizard_rnd.pro) + +DEFINES += WLAN_WIZARD_RND_WPS + +LIBS += -lwpswizard