wlanutilities/wlanwizard/src/wlanwizardpagescanning.cpp
author hgs
Fri, 06 Aug 2010 18:38:57 +0300
changeset 49 fb81b597edf1
parent 43 72ebcbb64834
child 53 bdc64aa9b954
permissions -rw-r--r--
201031
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31
hgs
parents:
diff changeset
     1
/*
39
hgs
parents: 31
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents: 31
diff changeset
     3
* All rights reserved.
hgs
parents: 31
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents: 31
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents: 31
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents: 31
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents: 31
diff changeset
     8
*
hgs
parents: 31
diff changeset
     9
* Initial Contributors:
hgs
parents: 31
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents: 31
diff changeset
    11
*
hgs
parents: 31
diff changeset
    12
* Contributors:
hgs
parents: 31
diff changeset
    13
*
hgs
parents: 31
diff changeset
    14
* Description: 
hgs
parents: 31
diff changeset
    15
* WLAN Wizard Page: Scan processing.
hgs
parents: 31
diff changeset
    16
*/
31
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
// System includes
39
hgs
parents: 31
diff changeset
    19
#include <HbParameterLengthLimiter>
31
hgs
parents:
diff changeset
    20
#include <HbMainWindow>
hgs
parents:
diff changeset
    21
#include <HbDocumentLoader>
hgs
parents:
diff changeset
    22
#include <HbWidget>
hgs
parents:
diff changeset
    23
#include <HbLabel>
hgs
parents:
diff changeset
    24
#include <HbProgressBar>
hgs
parents:
diff changeset
    25
#include <cmmanagerdefines_shim.h>
hgs
parents:
diff changeset
    26
#include <wlanqtutils.h>
hgs
parents:
diff changeset
    27
#include <wlanqtutilsap.h>
hgs
parents:
diff changeset
    28
hgs
parents:
diff changeset
    29
// User includes
hgs
parents:
diff changeset
    30
#include "wlanwizard_p.h"
hgs
parents:
diff changeset
    31
#include "wlanwizardpagescanning.h"
hgs
parents:
diff changeset
    32
#include "OstTraceDefinitions.h"
hgs
parents:
diff changeset
    33
#ifdef OST_TRACE_COMPILER_IN_USE
hgs
parents:
diff changeset
    34
#include "wlanwizardpagescanningTraces.h"
hgs
parents:
diff changeset
    35
#endif
hgs
parents:
diff changeset
    36
39
hgs
parents: 31
diff changeset
    37
// Local constants
hgs
parents: 31
diff changeset
    38
31
hgs
parents:
diff changeset
    39
/*!
39
hgs
parents: 31
diff changeset
    40
 * Constructor method for the scanning view object.
hgs
parents: 31
diff changeset
    41
 * @param [in] parent pointer to parent object.
31
hgs
parents:
diff changeset
    42
 */
hgs
parents:
diff changeset
    43
WlanWizardPageScanning::WlanWizardPageScanning(WlanWizardPrivate* parent) :
hgs
parents:
diff changeset
    44
    WlanWizardPageInternal(parent),
hgs
parents:
diff changeset
    45
    mWidget(NULL),
hgs
parents:
diff changeset
    46
    mLabel(NULL),
hgs
parents:
diff changeset
    47
    mLoader(NULL),
hgs
parents:
diff changeset
    48
    mNextPageId(WlanWizardPage::PageNone),
39
hgs
parents: 31
diff changeset
    49
    mScanResultsAvailable(false),
hgs
parents: 31
diff changeset
    50
    mScanStatus(WlanQtUtils::ScanStatusOk)
31
hgs
parents:
diff changeset
    51
{
43
hgs
parents: 39
diff changeset
    52
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_WLANWIZARDPAGESCANNING_ENTRY );
31
hgs
parents:
diff changeset
    53
    WlanQtUtils* utils = mWizard->wlanQtUtils();
hgs
parents:
diff changeset
    54
hgs
parents:
diff changeset
    55
    // Connect normal scan completion signal from wlanQtUtils to result
hgs
parents:
diff changeset
    56
    // handler. Connect here instead of initializePage, since this signal may
hgs
parents:
diff changeset
    57
    // need to be caught event if the window is not active.
39
hgs
parents: 31
diff changeset
    58
    bool ok = connect(
hgs
parents: 31
diff changeset
    59
        utils,
hgs
parents: 31
diff changeset
    60
        SIGNAL(wlanScanApReady(int)),
hgs
parents: 31
diff changeset
    61
        this,
hgs
parents: 31
diff changeset
    62
        SLOT(wlanScanResultPreCheck(int)));
hgs
parents: 31
diff changeset
    63
    
hgs
parents: 31
diff changeset
    64
    Q_ASSERT(ok);
43
hgs
parents: 39
diff changeset
    65
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_WLANWIZARDPAGESCANNING_EXIT );
31
hgs
parents:
diff changeset
    66
}
hgs
parents:
diff changeset
    67
hgs
parents:
diff changeset
    68
/*!
hgs
parents:
diff changeset
    69
 * Destructor. Loader widget is deleted.
hgs
parents:
diff changeset
    70
 * All document widgets are deleted by wlanwizard_p destructor.
hgs
parents:
diff changeset
    71
 */
hgs
parents:
diff changeset
    72
WlanWizardPageScanning::~WlanWizardPageScanning()
hgs
parents:
diff changeset
    73
{
43
hgs
parents: 39
diff changeset
    74
    OstTraceFunctionEntry0( DUP1_WLANWIZARDPAGESCANNING_WLANWIZARDPAGESCANNING_ENTRY );
31
hgs
parents:
diff changeset
    75
    delete mLoader;
43
hgs
parents: 39
diff changeset
    76
    OstTraceFunctionExit0( DUP1_WLANWIZARDPAGESCANNING_WLANWIZARDPAGESCANNING_EXIT );
31
hgs
parents:
diff changeset
    77
}
hgs
parents:
diff changeset
    78
hgs
parents:
diff changeset
    79
/*!
39
hgs
parents: 31
diff changeset
    80
 * Page initialization. If view is already loaded, does nothing. Inherited from
hgs
parents: 31
diff changeset
    81
 * WlanWizardPage.
hgs
parents: 31
diff changeset
    82
 * @return pointer to widget "occ_add_wlan_06".
31
hgs
parents:
diff changeset
    83
 */
hgs
parents:
diff changeset
    84
HbWidget* WlanWizardPageScanning::initializePage()
hgs
parents:
diff changeset
    85
{
43
hgs
parents: 39
diff changeset
    86
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_INITIALIZEPAGE_ENTRY );
39
hgs
parents: 31
diff changeset
    87
    OstTrace0(
hgs
parents: 31
diff changeset
    88
        TRACE_NORMAL,
hgs
parents: 31
diff changeset
    89
        WLANWIZARDPAGESCANNING_INITIALIZEPAGE,
hgs
parents: 31
diff changeset
    90
        "WlanWizardPageScanning::initializePage");
31
hgs
parents:
diff changeset
    91
hgs
parents:
diff changeset
    92
    // Next page id is reset with each initialization.    
hgs
parents:
diff changeset
    93
    mNextPageId = WlanWizardPage::PageNone;
hgs
parents:
diff changeset
    94
hgs
parents:
diff changeset
    95
    if (mWidget == NULL) {
hgs
parents:
diff changeset
    96
        mLoader = new HbDocumentLoader(mWizard->mainWindow());
hgs
parents:
diff changeset
    97
hgs
parents:
diff changeset
    98
        bool ok;
hgs
parents:
diff changeset
    99
hgs
parents:
diff changeset
   100
        mLoader->load(":/docml/occ_add_wlan_06.docml", &ok);
39
hgs
parents: 31
diff changeset
   101
        Q_ASSERT(ok);
31
hgs
parents:
diff changeset
   102
hgs
parents:
diff changeset
   103
        // Initialize orientation
39
hgs
parents: 31
diff changeset
   104
        loadDocmlSection(mWizard->mainWindow()->orientation());
31
hgs
parents:
diff changeset
   105
hgs
parents:
diff changeset
   106
        // Load widgets
hgs
parents:
diff changeset
   107
        mWidget = qobject_cast<HbWidget*> (mLoader->findWidget(
hgs
parents:
diff changeset
   108
            "occ_add_wlan_06"));
39
hgs
parents: 31
diff changeset
   109
        Q_ASSERT(mWidget != NULL);
31
hgs
parents:
diff changeset
   110
hgs
parents:
diff changeset
   111
        mLabel = qobject_cast<HbLabel*> (mLoader->findWidget("dialog"));
39
hgs
parents: 31
diff changeset
   112
        Q_ASSERT(mLabel != NULL);
31
hgs
parents:
diff changeset
   113
hgs
parents:
diff changeset
   114
        WlanQtUtils* utils = mWizard->wlanQtUtils();
hgs
parents:
diff changeset
   115
hgs
parents:
diff changeset
   116
        // Connect orientation signal from the main window to orientation
hgs
parents:
diff changeset
   117
        // loader.
39
hgs
parents: 31
diff changeset
   118
        ok = connect(
hgs
parents: 31
diff changeset
   119
            mWizard->mainWindow(),
hgs
parents: 31
diff changeset
   120
            SIGNAL(orientationChanged(Qt::Orientation)),
hgs
parents: 31
diff changeset
   121
            this,
hgs
parents: 31
diff changeset
   122
            SLOT(loadDocmlSection(Qt::Orientation)));
hgs
parents: 31
diff changeset
   123
        Q_ASSERT(ok);
31
hgs
parents:
diff changeset
   124
hgs
parents:
diff changeset
   125
        // Connect direct scan completion signal from wlanQtUtils to result
hgs
parents:
diff changeset
   126
        // handler.
39
hgs
parents: 31
diff changeset
   127
        ok = connect(
hgs
parents: 31
diff changeset
   128
            utils,
hgs
parents: 31
diff changeset
   129
            SIGNAL(wlanScanDirectReady(int)),
hgs
parents: 31
diff changeset
   130
            this,
hgs
parents: 31
diff changeset
   131
            SLOT(wlanScanDirectReady(int)));
31
hgs
parents:
diff changeset
   132
        Q_ASSERT(ok);
hgs
parents:
diff changeset
   133
    }
hgs
parents:
diff changeset
   134
39
hgs
parents: 31
diff changeset
   135
    mLabel->setPlainText(HbParameterLengthLimiter(
49
hgs
parents: 43
diff changeset
   136
        "txt_occ_dialog_searching").arg(mWizard->configuration(
39
hgs
parents: 31
diff changeset
   137
            WlanWizardPrivate::ConfSsid).toString()));
hgs
parents: 31
diff changeset
   138
43
hgs
parents: 39
diff changeset
   139
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_INITIALIZEPAGE_EXIT );
31
hgs
parents:
diff changeset
   140
    return mWidget;
hgs
parents:
diff changeset
   141
}
hgs
parents:
diff changeset
   142
hgs
parents:
diff changeset
   143
/*!
hgs
parents:
diff changeset
   144
 * Sends the user to the next page.
39
hgs
parents: 31
diff changeset
   145
 * @param [out] removeFromStack is always true: this page is removed from the 
hgs
parents: 31
diff changeset
   146
 * stacked widget after "Next" button is pressed.
hgs
parents: 31
diff changeset
   147
 * @return the id value of the next page.
31
hgs
parents:
diff changeset
   148
 */
hgs
parents:
diff changeset
   149
int WlanWizardPageScanning::nextId(bool &removeFromStack) const
hgs
parents:
diff changeset
   150
{
43
hgs
parents: 39
diff changeset
   151
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_NEXTID_ENTRY );
31
hgs
parents:
diff changeset
   152
    removeFromStack = true;
hgs
parents:
diff changeset
   153
43
hgs
parents: 39
diff changeset
   154
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_NEXTID_EXIT );
31
hgs
parents:
diff changeset
   155
    return mNextPageId;
hgs
parents:
diff changeset
   156
}
hgs
parents:
diff changeset
   157
hgs
parents:
diff changeset
   158
/*!
39
hgs
parents: 31
diff changeset
   159
 * This function reimplements WlanWizardPage::previousTriggered. When going
hgs
parents: 31
diff changeset
   160
 * back from scanning view, the ongoing scan operation is also stopped. Since
hgs
parents: 31
diff changeset
   161
 * there is no need to react to following the acknowledgement signal from
hgs
parents: 31
diff changeset
   162
 * wlanQtUtils, the corresponding handler slots are disconnected before the
hgs
parents: 31
diff changeset
   163
 * opration and immediately connected again.
hgs
parents: 31
diff changeset
   164
 * @return one step backwards value.
hgs
parents: 31
diff changeset
   165
 */
hgs
parents: 31
diff changeset
   166
int WlanWizardPageScanning::previousTriggered()
hgs
parents: 31
diff changeset
   167
{
43
hgs
parents: 39
diff changeset
   168
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_PREVIOUSTRIGGERED_ENTRY );
39
hgs
parents: 31
diff changeset
   169
    disconnect(this, SLOT(wlanScanDirectReady(int)));
hgs
parents: 31
diff changeset
   170
    disconnect(this, SLOT(wlanScanResultPreCheck(int)));
hgs
parents: 31
diff changeset
   171
    
hgs
parents: 31
diff changeset
   172
    WlanQtUtils* utils = mWizard->wlanQtUtils();
hgs
parents: 31
diff changeset
   173
    
hgs
parents: 31
diff changeset
   174
    utils->stopWlanScan();
hgs
parents: 31
diff changeset
   175
hgs
parents: 31
diff changeset
   176
    bool ok = connect(
hgs
parents: 31
diff changeset
   177
        utils,
hgs
parents: 31
diff changeset
   178
        SIGNAL(wlanScanApReady(int)),
hgs
parents: 31
diff changeset
   179
        this,
hgs
parents: 31
diff changeset
   180
        SLOT(wlanScanResultPreCheck(int)));
hgs
parents: 31
diff changeset
   181
    Q_ASSERT(ok);
hgs
parents: 31
diff changeset
   182
    
hgs
parents: 31
diff changeset
   183
    ok = connect(
hgs
parents: 31
diff changeset
   184
        utils,
hgs
parents: 31
diff changeset
   185
        SIGNAL(wlanScanDirectReady(int)),
hgs
parents: 31
diff changeset
   186
        this,
hgs
parents: 31
diff changeset
   187
        SLOT(wlanScanDirectReady(int)));
hgs
parents: 31
diff changeset
   188
    Q_ASSERT(ok);
hgs
parents: 31
diff changeset
   189
    
43
hgs
parents: 39
diff changeset
   190
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_PREVIOUSTRIGGERED_EXIT );
39
hgs
parents: 31
diff changeset
   191
    return OneStepBackwards;
hgs
parents: 31
diff changeset
   192
    
hgs
parents: 31
diff changeset
   193
}
hgs
parents: 31
diff changeset
   194
hgs
parents: 31
diff changeset
   195
/*!
hgs
parents: 31
diff changeset
   196
 * This method is overrides the default implementation from WlanWizardPage.
hgs
parents: 31
diff changeset
   197
 * It indicates whether the Next-button should be enabled or not. It also resets
hgs
parents: 31
diff changeset
   198
 * the ConfProcessSettings-configuration to false - meaning that if no scan
hgs
parents: 31
diff changeset
   199
 * results are available, no iap is created.
hgs
parents: 31
diff changeset
   200
 * @return always false - the scanning proceeds to next window
hgs
parents: 31
diff changeset
   201
 * automatically or not at all.
31
hgs
parents:
diff changeset
   202
 */
hgs
parents:
diff changeset
   203
bool WlanWizardPageScanning::showPage()
hgs
parents:
diff changeset
   204
{
43
hgs
parents: 39
diff changeset
   205
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_SHOWPAGE_ENTRY );
39
hgs
parents: 31
diff changeset
   206
    mWizard->setConfiguration(WlanWizardHelper::ConfProcessSettings, false);
43
hgs
parents: 39
diff changeset
   207
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_SHOWPAGE_EXIT );
31
hgs
parents:
diff changeset
   208
    return false;
hgs
parents:
diff changeset
   209
}
hgs
parents:
diff changeset
   210
hgs
parents:
diff changeset
   211
/*!
39
hgs
parents: 31
diff changeset
   212
 * Reimplements the default function in WlanWizardPage. Indicates to the
hgs
parents: 31
diff changeset
   213
 * framework that startOperation() function must be executed.
hgs
parents: 31
diff changeset
   214
 * @return true
hgs
parents: 31
diff changeset
   215
 * @see WlanWizardPage
31
hgs
parents:
diff changeset
   216
 */
hgs
parents:
diff changeset
   217
bool WlanWizardPageScanning::requiresStartOperation()
hgs
parents:
diff changeset
   218
{
43
hgs
parents: 39
diff changeset
   219
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_REQUIRESSTARTOPERATION_ENTRY );
hgs
parents: 39
diff changeset
   220
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_REQUIRESSTARTOPERATION_EXIT );
31
hgs
parents:
diff changeset
   221
    return true;
hgs
parents:
diff changeset
   222
}
hgs
parents:
diff changeset
   223
hgs
parents:
diff changeset
   224
/*!
hgs
parents:
diff changeset
   225
 * Wlan scan is performed as a "post-initialization" which is executed in a
39
hgs
parents: 31
diff changeset
   226
 * separate scheduler loop. If scan results are available, starts reading them.
31
hgs
parents:
diff changeset
   227
 */
hgs
parents:
diff changeset
   228
void WlanWizardPageScanning::startOperation()
hgs
parents:
diff changeset
   229
{
43
hgs
parents: 39
diff changeset
   230
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_STARTOPERATION_ENTRY );
31
hgs
parents:
diff changeset
   231
    OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESCANNING_STARTOPERATION,
hgs
parents:
diff changeset
   232
        "WlanWizardPageScanning::startOperation - start AP scan if results"
hgs
parents:
diff changeset
   233
        " are available." );
hgs
parents:
diff changeset
   234
hgs
parents:
diff changeset
   235
    if (mScanResultsAvailable) {
hgs
parents:
diff changeset
   236
        mScanResultsAvailable = false;
hgs
parents:
diff changeset
   237
        wlanScanApReady();
hgs
parents:
diff changeset
   238
    }
43
hgs
parents: 39
diff changeset
   239
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_STARTOPERATION_EXIT );
31
hgs
parents:
diff changeset
   240
}
hgs
parents:
diff changeset
   241
39
hgs
parents: 31
diff changeset
   242
/*!
hgs
parents: 31
diff changeset
   243
 * Loads the document orientation information from occ_add_wlan_06.docml
hgs
parents: 31
diff changeset
   244
 * This is called each time phone orientation changes.
hgs
parents: 31
diff changeset
   245
 * @param [in] orientation indicates whether the phone is in portrait or
hgs
parents: 31
diff changeset
   246
 * landscape mode.
hgs
parents: 31
diff changeset
   247
 */
hgs
parents: 31
diff changeset
   248
void WlanWizardPageScanning::loadDocmlSection(Qt::Orientation orientation)
hgs
parents: 31
diff changeset
   249
{
43
hgs
parents: 39
diff changeset
   250
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_LOADDOCMLSECTION_ENTRY );
39
hgs
parents: 31
diff changeset
   251
    OstTrace1( TRACE_NORMAL, WLANWIZARDPAGESCANNING_LOADDOCML,
hgs
parents: 31
diff changeset
   252
        "WlanWizardPageScanning::loadDocml - orientation ;orientation=%x",
hgs
parents: 31
diff changeset
   253
        ( TUint )( orientation ) );
hgs
parents: 31
diff changeset
   254
hgs
parents: 31
diff changeset
   255
    WlanWizardPageInternal::loadDocmlSection(
hgs
parents: 31
diff changeset
   256
        mLoader,
hgs
parents: 31
diff changeset
   257
        orientation,
hgs
parents: 31
diff changeset
   258
        ":/docml/occ_add_wlan_06.docml", 
hgs
parents: 31
diff changeset
   259
        "portrait_section",
hgs
parents: 31
diff changeset
   260
        "landscape_section");
43
hgs
parents: 39
diff changeset
   261
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_LOADDOCMLSECTION_EXIT );
39
hgs
parents: 31
diff changeset
   262
}
hgs
parents: 31
diff changeset
   263
hgs
parents: 31
diff changeset
   264
/*!
hgs
parents: 31
diff changeset
   265
 * Checks whether the view is active. If it is, execute wlanScanApReady. If
hgs
parents: 31
diff changeset
   266
 * not, set mScanResultsAvailable to true.
hgs
parents: 31
diff changeset
   267
 * @param [in] scanStatus indicates whether the scan was succesful, cancelled of
hgs
parents: 31
diff changeset
   268
 * failed. The argument is saved to a member variable.
hgs
parents: 31
diff changeset
   269
 */
hgs
parents: 31
diff changeset
   270
void WlanWizardPageScanning::wlanScanResultPreCheck(int scanStatus)
hgs
parents: 31
diff changeset
   271
{
43
hgs
parents: 39
diff changeset
   272
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_WLANSCANRESULTPRECHECK_ENTRY );
39
hgs
parents: 31
diff changeset
   273
    mScanStatus = scanStatus;
hgs
parents: 31
diff changeset
   274
    
hgs
parents: 31
diff changeset
   275
    if (!mWidget) {
hgs
parents: 31
diff changeset
   276
        OstTrace1( TRACE_BORDER, WLANWIZARDPAGESCANNING_WLANSCANRESULTPRECHECK,
hgs
parents: 31
diff changeset
   277
            "WlanWizardPageScanning::wlanScanResultPreCheck no widget;this=%x",
hgs
parents: 31
diff changeset
   278
            this );
hgs
parents: 31
diff changeset
   279
hgs
parents: 31
diff changeset
   280
        mScanResultsAvailable = true;
hgs
parents: 31
diff changeset
   281
    } else {
hgs
parents: 31
diff changeset
   282
        if (mWizard->isCurrentPage(mWidget)) {
hgs
parents: 31
diff changeset
   283
            OstTrace0( TRACE_BORDER,
hgs
parents: 31
diff changeset
   284
                DUP1_WLANWIZARDPAGESCANNING_WLANSCANRESULTPRECHECK,
hgs
parents: 31
diff changeset
   285
                "WlanWizardPageScanning::wlanScanResultPreCheck go to results");
hgs
parents: 31
diff changeset
   286
hgs
parents: 31
diff changeset
   287
            wlanScanApReady();
hgs
parents: 31
diff changeset
   288
        } else {
hgs
parents: 31
diff changeset
   289
            OstTrace0( TRACE_BORDER,
hgs
parents: 31
diff changeset
   290
                DUP2_WLANWIZARDPAGESCANNING_WLANSCANRESULTPRECHECK,
hgs
parents: 31
diff changeset
   291
                "WlanWizardPageScanning::wlanScanResultPreCheck"
hgs
parents: 31
diff changeset
   292
                " not current widget" );
hgs
parents: 31
diff changeset
   293
hgs
parents: 31
diff changeset
   294
            mScanResultsAvailable = true;
hgs
parents: 31
diff changeset
   295
        }
hgs
parents: 31
diff changeset
   296
    }
43
hgs
parents: 39
diff changeset
   297
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_WLANSCANRESULTPRECHECK_EXIT );
39
hgs
parents: 31
diff changeset
   298
}
hgs
parents: 31
diff changeset
   299
hgs
parents: 31
diff changeset
   300
/*!
hgs
parents: 31
diff changeset
   301
 * Processes the direct scan results.
hgs
parents: 31
diff changeset
   302
 * @param [in] scanStatus indicates whether the scan was succesful, canceled or
hgs
parents: 31
diff changeset
   303
 * failed. In case the scan was not succesful, always proceed to manual wizard.
hgs
parents: 31
diff changeset
   304
 */
hgs
parents: 31
diff changeset
   305
void WlanWizardPageScanning::wlanScanDirectReady(int scanStatus)
hgs
parents: 31
diff changeset
   306
{
43
hgs
parents: 39
diff changeset
   307
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_WLANSCANDIRECTREADY_ENTRY );
39
hgs
parents: 31
diff changeset
   308
    OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESCANNING_WLANSCANDIRECTREADY,
hgs
parents: 31
diff changeset
   309
        "WlanWizardPageScanning::wlanScanDirectReady" );
hgs
parents: 31
diff changeset
   310
hgs
parents: 31
diff changeset
   311
    WlanQtUtils* utils = mWizard->wlanQtUtils();
hgs
parents: 31
diff changeset
   312
hgs
parents: 31
diff changeset
   313
    Q_ASSERT(utils);
hgs
parents: 31
diff changeset
   314
hgs
parents: 31
diff changeset
   315
    QList<WlanScanResult> filteredResults;
hgs
parents: 31
diff changeset
   316
hgs
parents: 31
diff changeset
   317
    if (scanStatus == WlanQtUtils::ScanStatusOk) {
hgs
parents: 31
diff changeset
   318
        QList<QSharedPointer<WlanQtUtilsAp> > directScanResults;
hgs
parents: 31
diff changeset
   319
        // Read the directed scan results from Qt Utils
hgs
parents: 31
diff changeset
   320
        utils->availableWlanAps(directScanResults);
hgs
parents: 31
diff changeset
   321
hgs
parents: 31
diff changeset
   322
        // Identify open and hidden networks.
hgs
parents: 31
diff changeset
   323
        getFinalScanResults(directScanResults, mWlanApList, filteredResults);
hgs
parents: 31
diff changeset
   324
    }
hgs
parents: 31
diff changeset
   325
hgs
parents: 31
diff changeset
   326
    // Process the scan results. If scan status is not ok, feed an empty
hgs
parents: 31
diff changeset
   327
    // result table to the selection function.
hgs
parents: 31
diff changeset
   328
    selectNextPageActions(filteredResults);
43
hgs
parents: 39
diff changeset
   329
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_WLANSCANDIRECTREADY_EXIT );
39
hgs
parents: 31
diff changeset
   330
}
hgs
parents: 31
diff changeset
   331
hgs
parents: 31
diff changeset
   332
/*!
hgs
parents: 31
diff changeset
   333
 * All wlan channels have been scanned for public networks. After processing the
hgs
parents: 31
diff changeset
   334
 * results a direct scan is initiated. This function also checks whether the
hgs
parents: 31
diff changeset
   335
 * scan was succesful, canceled or failed. In case the scan was not succesful,
hgs
parents: 31
diff changeset
   336
 * always proceed to manual wizard.
hgs
parents: 31
diff changeset
   337
 */
hgs
parents: 31
diff changeset
   338
void WlanWizardPageScanning::wlanScanApReady()
hgs
parents: 31
diff changeset
   339
{
43
hgs
parents: 39
diff changeset
   340
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_WLANSCANAPREADY_ENTRY );
39
hgs
parents: 31
diff changeset
   341
    OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESCANNING_WLANSCANAPREADY,
hgs
parents: 31
diff changeset
   342
        "WlanWizardPageScanning::wlanScanApReady" );
hgs
parents: 31
diff changeset
   343
hgs
parents: 31
diff changeset
   344
    if (mScanStatus == WlanQtUtils::ScanStatusOk) {
hgs
parents: 31
diff changeset
   345
        WlanQtUtils* utils = mWizard->wlanQtUtils();
hgs
parents: 31
diff changeset
   346
        Q_ASSERT(utils);
hgs
parents: 31
diff changeset
   347
hgs
parents: 31
diff changeset
   348
        QList<QSharedPointer<WlanQtUtilsAp> > openScanResults;
hgs
parents: 31
diff changeset
   349
hgs
parents: 31
diff changeset
   350
        // Fetch the list of scan results.
hgs
parents: 31
diff changeset
   351
        utils->availableWlanAps(openScanResults);
hgs
parents: 31
diff changeset
   352
hgs
parents: 31
diff changeset
   353
        // The name of the network that we are looking for.
hgs
parents: 31
diff changeset
   354
        QString ssid =
hgs
parents: 31
diff changeset
   355
            mWizard->configuration(WlanWizardPrivate::ConfSsid).toString();
hgs
parents: 31
diff changeset
   356
hgs
parents: 31
diff changeset
   357
        // Store matching scan results.
hgs
parents: 31
diff changeset
   358
        getSsidMatchList(ssid, openScanResults);
hgs
parents: 31
diff changeset
   359
hgs
parents: 31
diff changeset
   360
        // Next directed scan.
hgs
parents: 31
diff changeset
   361
        utils->scanWlanDirect(ssid);
hgs
parents: 31
diff changeset
   362
    }
hgs
parents: 31
diff changeset
   363
    else {
hgs
parents: 31
diff changeset
   364
        mWizard->clearConfiguration(WlanWizardHelper::ConfAvailableNetworkOptions);
hgs
parents: 31
diff changeset
   365
        mNextPageId = WlanWizardPageInternal::PageNetworkMode;
hgs
parents: 31
diff changeset
   366
        mWizard->nextPage();
hgs
parents: 31
diff changeset
   367
    }
43
hgs
parents: 39
diff changeset
   368
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_WLANSCANAPREADY_EXIT );
39
hgs
parents: 31
diff changeset
   369
}
hgs
parents: 31
diff changeset
   370
hgs
parents: 31
diff changeset
   371
/*!
hgs
parents: 31
diff changeset
   372
 * This function stores all the APs that match ssid parameter to mWlanApList
hgs
parents: 31
diff changeset
   373
 * member list.
hgs
parents: 31
diff changeset
   374
 * @param [in] ssid is the name of the network we are interested in.
hgs
parents: 31
diff changeset
   375
 * @param [in] matchList is the list of all APs that were revealed in the scan.
hgs
parents: 31
diff changeset
   376
 */
hgs
parents: 31
diff changeset
   377
void WlanWizardPageScanning::getSsidMatchList(
hgs
parents: 31
diff changeset
   378
    QString ssid,
hgs
parents: 31
diff changeset
   379
    const QList<QSharedPointer<WlanQtUtilsAp> > &matchList)
hgs
parents: 31
diff changeset
   380
{
43
hgs
parents: 39
diff changeset
   381
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_GETSSIDMATCHLIST_ENTRY );
39
hgs
parents: 31
diff changeset
   382
    mWlanApList.clear();
hgs
parents: 31
diff changeset
   383
    QSharedPointer<WlanQtUtilsAp> item;
hgs
parents: 31
diff changeset
   384
hgs
parents: 31
diff changeset
   385
    for (int i = 0; i < matchList.size(); i++) {
hgs
parents: 31
diff changeset
   386
        item = matchList.at(i);
hgs
parents: 31
diff changeset
   387
        if (item->value(WlanQtUtilsAp::ConfIdSsid).toString() == ssid) {
hgs
parents: 31
diff changeset
   388
            mWlanApList.append(item);
hgs
parents: 31
diff changeset
   389
        }
hgs
parents: 31
diff changeset
   390
    }
43
hgs
parents: 39
diff changeset
   391
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_GETSSIDMATCHLIST_EXIT );
39
hgs
parents: 31
diff changeset
   392
}
hgs
parents: 31
diff changeset
   393
hgs
parents: 31
diff changeset
   394
/*
hgs
parents: 31
diff changeset
   395
 * Find out which of the direct scan results are open networks by comparing
hgs
parents: 31
diff changeset
   396
 * result to open scan results. Return finalResults.
hgs
parents: 31
diff changeset
   397
 * @param [in] directScanResults are the results of a directed scan.
hgs
parents: 31
diff changeset
   398
 * @param [in] openScanResults are the results of a scan inquiring any APs.
hgs
parents: 31
diff changeset
   399
 * @param [out] finalResults is a list of APs with visibility flag included.
hgs
parents: 31
diff changeset
   400
 */
hgs
parents: 31
diff changeset
   401
void WlanWizardPageScanning::getFinalScanResults(
hgs
parents: 31
diff changeset
   402
    const QList<QSharedPointer<WlanQtUtilsAp> > &directScanResults,
hgs
parents: 31
diff changeset
   403
    const QList<QSharedPointer<WlanQtUtilsAp> > &openScanResults,
hgs
parents: 31
diff changeset
   404
    QList<WlanScanResult> &finalResults)
hgs
parents: 31
diff changeset
   405
{
43
hgs
parents: 39
diff changeset
   406
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_GETFINALSCANRESULTS_ENTRY );
39
hgs
parents: 31
diff changeset
   407
    finalResults.clear();
hgs
parents: 31
diff changeset
   408
hgs
parents: 31
diff changeset
   409
    // The key assumption of this algorithm is that both direct and public scan
hgs
parents: 31
diff changeset
   410
    // reveal the same set of AP:s with the exception of hidden AP:s.
hgs
parents: 31
diff changeset
   411
    // In other words: Direct scan result set is the whole set with each AP 
hgs
parents: 31
diff changeset
   412
    // marked as hidden by default. If an AP has been revealed also by public
hgs
parents: 31
diff changeset
   413
    // scan, it is changed to visible.
hgs
parents: 31
diff changeset
   414
    for (int i = 0; i < directScanResults.size(); i++) {
hgs
parents: 31
diff changeset
   415
        WlanScanResult resultItem;
hgs
parents: 31
diff changeset
   416
hgs
parents: 31
diff changeset
   417
        resultItem.scanResult = directScanResults.at(i);
hgs
parents: 31
diff changeset
   418
        
hgs
parents: 31
diff changeset
   419
        // Initialize as hidden.
hgs
parents: 31
diff changeset
   420
        resultItem.networkHidden = true;
hgs
parents: 31
diff changeset
   421
         
hgs
parents: 31
diff changeset
   422
        for (int j = 0; j < openScanResults.size(); j++) {
hgs
parents: 31
diff changeset
   423
            if (WlanQtUtilsAp::compare(
hgs
parents: 31
diff changeset
   424
                openScanResults.at(j).data(), 
hgs
parents: 31
diff changeset
   425
                directScanResults.at(i).data()) == 0) {
hgs
parents: 31
diff changeset
   426
                // Mark open, if a public scan revealed the same AP
hgs
parents: 31
diff changeset
   427
                resultItem.networkHidden = false;
hgs
parents: 31
diff changeset
   428
            }
hgs
parents: 31
diff changeset
   429
        }
hgs
parents: 31
diff changeset
   430
hgs
parents: 31
diff changeset
   431
        finalResults.append(resultItem);
hgs
parents: 31
diff changeset
   432
    }
43
hgs
parents: 39
diff changeset
   433
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_GETFINALSCANRESULTS_EXIT );
39
hgs
parents: 31
diff changeset
   434
}
hgs
parents: 31
diff changeset
   435
hgs
parents: 31
diff changeset
   436
/*!
hgs
parents: 31
diff changeset
   437
 * This function processes the scan results in case multiple results were
hgs
parents: 31
diff changeset
   438
 * acquired with matching SSIDs.
hgs
parents: 31
diff changeset
   439
 * @param [in] finalResults is the list of APs revealed by the last scans.
hgs
parents: 31
diff changeset
   440
 * @return the identifier of the next page.
hgs
parents: 31
diff changeset
   441
 */
hgs
parents: 31
diff changeset
   442
int WlanWizardPageScanning::processMultipleScanResults(
hgs
parents: 31
diff changeset
   443
    const QList<WlanScanResult> &finalResults)
hgs
parents: 31
diff changeset
   444
{
43
hgs
parents: 39
diff changeset
   445
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_PROCESSMULTIPLESCANRESULTS_ENTRY );
39
hgs
parents: 31
diff changeset
   446
    WlanWizardScanList networkOptions;
hgs
parents: 31
diff changeset
   447
    int nextPage;
hgs
parents: 31
diff changeset
   448
hgs
parents: 31
diff changeset
   449
    // Build the list of results to be placed in the configuration.
hgs
parents: 31
diff changeset
   450
    networkOptions.build(finalResults);
hgs
parents: 31
diff changeset
   451
    
hgs
parents: 31
diff changeset
   452
    QVariant tmp;
hgs
parents: 31
diff changeset
   453
    tmp.setValue(networkOptions);
hgs
parents: 31
diff changeset
   454
hgs
parents: 31
diff changeset
   455
    mWizard->setConfiguration(
hgs
parents: 31
diff changeset
   456
        WlanWizardHelper::ConfAvailableNetworkOptions, tmp);
hgs
parents: 31
diff changeset
   457
43
hgs
parents: 39
diff changeset
   458
    if (networkOptions.wpsSelected()) {
hgs
parents: 39
diff changeset
   459
        // In case all available network mode options support wps, go directly
hgs
parents: 39
diff changeset
   460
        // to wps-wizard.
hgs
parents: 39
diff changeset
   461
        nextPage = WlanWizardPageInternal::PageWpsStart;
hgs
parents: 39
diff changeset
   462
    } else if (networkOptions.netModes() > SingleResult) {
hgs
parents: 39
diff changeset
   463
        // If there are more than one network mode choices, go to manual selection
hgs
parents: 39
diff changeset
   464
        // of network mode.
39
hgs
parents: 31
diff changeset
   465
        nextPage = WlanWizardPageInternal::PageNetworkMode;
hgs
parents: 31
diff changeset
   466
    } else {
hgs
parents: 31
diff changeset
   467
        // if only a single network mode option is available, the mode query
hgs
parents: 31
diff changeset
   468
        // may be skipped and the next page is set to security mode query.
hgs
parents: 31
diff changeset
   469
        WlanNetworkSetting setting = networkOptions.getNetModes().at(0);
hgs
parents: 31
diff changeset
   470
        mWizard->setConfiguration(WlanWizardHelper::ConfNetworkMode, setting.mode);
hgs
parents: 31
diff changeset
   471
        mWizard->setConfiguration(WlanWizardHelper::ConfHiddenWlan, setting.hidden);
43
hgs
parents: 39
diff changeset
   472
        mWizard->setConfiguration(WlanWizardHelper::ConfWpsSupported, setting.wpsSupported);
39
hgs
parents: 31
diff changeset
   473
        nextPage = WlanWizardPageInternal::PageNetworkSecurity;
hgs
parents: 31
diff changeset
   474
    }
hgs
parents: 31
diff changeset
   475
    
43
hgs
parents: 39
diff changeset
   476
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_PROCESSMULTIPLESCANRESULTS_EXIT );
39
hgs
parents: 31
diff changeset
   477
    return nextPage;
hgs
parents: 31
diff changeset
   478
}
hgs
parents: 31
diff changeset
   479
hgs
parents: 31
diff changeset
   480
/*!
hgs
parents: 31
diff changeset
   481
 * This function decides what to do with the scan results.
hgs
parents: 31
diff changeset
   482
 * @param [in] finalResults is the list of APs revealed by the last scans.
hgs
parents: 31
diff changeset
   483
 */
hgs
parents: 31
diff changeset
   484
void WlanWizardPageScanning::selectNextPageActions(
hgs
parents: 31
diff changeset
   485
    const QList<WlanScanResult> &finalResults)
hgs
parents: 31
diff changeset
   486
{
43
hgs
parents: 39
diff changeset
   487
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_SELECTNEXTPAGEACTIONS_ENTRY );
39
hgs
parents: 31
diff changeset
   488
    mWizard->clearConfiguration(WlanWizardHelper::ConfAvailableNetworkOptions);
hgs
parents: 31
diff changeset
   489
    
hgs
parents: 31
diff changeset
   490
    if (finalResults.isEmpty()) {
hgs
parents: 31
diff changeset
   491
        // In case of no results at all were found.
hgs
parents: 31
diff changeset
   492
        mNextPageId = WlanWizardPageInternal::PageNetworkMode;
hgs
parents: 31
diff changeset
   493
    } else if (finalResults.size() == SingleResult) {
hgs
parents: 31
diff changeset
   494
        // In case there is only a single result.
hgs
parents: 31
diff changeset
   495
        WlanScanResult item = finalResults.first();
hgs
parents: 31
diff changeset
   496
        mNextPageId = mWizard->getNextPageId(
hgs
parents: 31
diff changeset
   497
            item.scanResult->value(WlanQtUtilsAp::ConfIdSsid).toString(),
hgs
parents: 31
diff changeset
   498
            item.scanResult->value(WlanQtUtilsAp::ConfIdConnectionMode).toInt(),
hgs
parents: 31
diff changeset
   499
            item.scanResult->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(),
hgs
parents: 31
diff changeset
   500
            item.scanResult->value(WlanQtUtilsAp::ConfIdWpaPskUse).toBool(),
hgs
parents: 31
diff changeset
   501
            item.networkHidden,
hgs
parents: 31
diff changeset
   502
            item.scanResult->value(WlanQtUtilsAp::ConfIdWpsSupported).toBool());
hgs
parents: 31
diff changeset
   503
    } else {
hgs
parents: 31
diff changeset
   504
        // In case more than one result is available.
hgs
parents: 31
diff changeset
   505
        mWizard->setConfiguration(WlanWizardHelper::ConfProcessSettings, true);
hgs
parents: 31
diff changeset
   506
        mNextPageId = processMultipleScanResults(finalResults);
hgs
parents: 31
diff changeset
   507
    }
hgs
parents: 31
diff changeset
   508
hgs
parents: 31
diff changeset
   509
    mWizard->nextPage();
43
hgs
parents: 39
diff changeset
   510
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_SELECTNEXTPAGEACTIONS_EXIT );
39
hgs
parents: 31
diff changeset
   511
}