wlanutilities/wlanwizard/src/wlanwizardpagescanning.cpp
author hgs
Fri, 09 Jul 2010 10:38:19 +0300
changeset 43 72ebcbb64834
parent 39 7b3e49e4608a
child 49 fb81b597edf1
permissions -rw-r--r--
201027
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(
hgs
parents: 31
diff changeset
   136
        hbTrId("txt_occ_dialog_searching")).arg(mWizard->configuration(
hgs
parents: 31
diff changeset
   137
            WlanWizardPrivate::ConfSsid).toString()));
hgs
parents: 31
diff changeset
   138
31
hgs
parents:
diff changeset
   139
43
hgs
parents: 39
diff changeset
   140
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_INITIALIZEPAGE_EXIT );
31
hgs
parents:
diff changeset
   141
    return mWidget;
hgs
parents:
diff changeset
   142
}
hgs
parents:
diff changeset
   143
hgs
parents:
diff changeset
   144
/*!
hgs
parents:
diff changeset
   145
 * Sends the user to the next page.
39
hgs
parents: 31
diff changeset
   146
 * @param [out] removeFromStack is always true: this page is removed from the 
hgs
parents: 31
diff changeset
   147
 * stacked widget after "Next" button is pressed.
hgs
parents: 31
diff changeset
   148
 * @return the id value of the next page.
31
hgs
parents:
diff changeset
   149
 */
hgs
parents:
diff changeset
   150
int WlanWizardPageScanning::nextId(bool &removeFromStack) const
hgs
parents:
diff changeset
   151
{
43
hgs
parents: 39
diff changeset
   152
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_NEXTID_ENTRY );
31
hgs
parents:
diff changeset
   153
    removeFromStack = true;
hgs
parents:
diff changeset
   154
43
hgs
parents: 39
diff changeset
   155
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_NEXTID_EXIT );
31
hgs
parents:
diff changeset
   156
    return mNextPageId;
hgs
parents:
diff changeset
   157
}
hgs
parents:
diff changeset
   158
hgs
parents:
diff changeset
   159
/*!
39
hgs
parents: 31
diff changeset
   160
 * This function reimplements WlanWizardPage::previousTriggered. When going
hgs
parents: 31
diff changeset
   161
 * back from scanning view, the ongoing scan operation is also stopped. Since
hgs
parents: 31
diff changeset
   162
 * there is no need to react to following the acknowledgement signal from
hgs
parents: 31
diff changeset
   163
 * wlanQtUtils, the corresponding handler slots are disconnected before the
hgs
parents: 31
diff changeset
   164
 * opration and immediately connected again.
hgs
parents: 31
diff changeset
   165
 * @return one step backwards value.
hgs
parents: 31
diff changeset
   166
 */
hgs
parents: 31
diff changeset
   167
int WlanWizardPageScanning::previousTriggered()
hgs
parents: 31
diff changeset
   168
{
43
hgs
parents: 39
diff changeset
   169
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_PREVIOUSTRIGGERED_ENTRY );
39
hgs
parents: 31
diff changeset
   170
    disconnect(this, SLOT(wlanScanDirectReady(int)));
hgs
parents: 31
diff changeset
   171
    disconnect(this, SLOT(wlanScanResultPreCheck(int)));
hgs
parents: 31
diff changeset
   172
    
hgs
parents: 31
diff changeset
   173
    WlanQtUtils* utils = mWizard->wlanQtUtils();
hgs
parents: 31
diff changeset
   174
    
hgs
parents: 31
diff changeset
   175
    utils->stopWlanScan();
hgs
parents: 31
diff changeset
   176
hgs
parents: 31
diff changeset
   177
    bool ok = connect(
hgs
parents: 31
diff changeset
   178
        utils,
hgs
parents: 31
diff changeset
   179
        SIGNAL(wlanScanApReady(int)),
hgs
parents: 31
diff changeset
   180
        this,
hgs
parents: 31
diff changeset
   181
        SLOT(wlanScanResultPreCheck(int)));
hgs
parents: 31
diff changeset
   182
    Q_ASSERT(ok);
hgs
parents: 31
diff changeset
   183
    
hgs
parents: 31
diff changeset
   184
    ok = connect(
hgs
parents: 31
diff changeset
   185
        utils,
hgs
parents: 31
diff changeset
   186
        SIGNAL(wlanScanDirectReady(int)),
hgs
parents: 31
diff changeset
   187
        this,
hgs
parents: 31
diff changeset
   188
        SLOT(wlanScanDirectReady(int)));
hgs
parents: 31
diff changeset
   189
    Q_ASSERT(ok);
hgs
parents: 31
diff changeset
   190
    
43
hgs
parents: 39
diff changeset
   191
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_PREVIOUSTRIGGERED_EXIT );
39
hgs
parents: 31
diff changeset
   192
    return OneStepBackwards;
hgs
parents: 31
diff changeset
   193
    
hgs
parents: 31
diff changeset
   194
}
hgs
parents: 31
diff changeset
   195
hgs
parents: 31
diff changeset
   196
/*!
hgs
parents: 31
diff changeset
   197
 * This method is overrides the default implementation from WlanWizardPage.
hgs
parents: 31
diff changeset
   198
 * It indicates whether the Next-button should be enabled or not. It also resets
hgs
parents: 31
diff changeset
   199
 * the ConfProcessSettings-configuration to false - meaning that if no scan
hgs
parents: 31
diff changeset
   200
 * results are available, no iap is created.
hgs
parents: 31
diff changeset
   201
 * @return always false - the scanning proceeds to next window
hgs
parents: 31
diff changeset
   202
 * automatically or not at all.
31
hgs
parents:
diff changeset
   203
 */
hgs
parents:
diff changeset
   204
bool WlanWizardPageScanning::showPage()
hgs
parents:
diff changeset
   205
{
43
hgs
parents: 39
diff changeset
   206
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_SHOWPAGE_ENTRY );
39
hgs
parents: 31
diff changeset
   207
    mWizard->setConfiguration(WlanWizardHelper::ConfProcessSettings, false);
43
hgs
parents: 39
diff changeset
   208
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_SHOWPAGE_EXIT );
31
hgs
parents:
diff changeset
   209
    return false;
hgs
parents:
diff changeset
   210
}
hgs
parents:
diff changeset
   211
hgs
parents:
diff changeset
   212
/*!
39
hgs
parents: 31
diff changeset
   213
 * Reimplements the default function in WlanWizardPage. Indicates to the
hgs
parents: 31
diff changeset
   214
 * framework that startOperation() function must be executed.
hgs
parents: 31
diff changeset
   215
 * @return true
hgs
parents: 31
diff changeset
   216
 * @see WlanWizardPage
31
hgs
parents:
diff changeset
   217
 */
hgs
parents:
diff changeset
   218
bool WlanWizardPageScanning::requiresStartOperation()
hgs
parents:
diff changeset
   219
{
43
hgs
parents: 39
diff changeset
   220
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_REQUIRESSTARTOPERATION_ENTRY );
hgs
parents: 39
diff changeset
   221
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_REQUIRESSTARTOPERATION_EXIT );
31
hgs
parents:
diff changeset
   222
    return true;
hgs
parents:
diff changeset
   223
}
hgs
parents:
diff changeset
   224
hgs
parents:
diff changeset
   225
/*!
hgs
parents:
diff changeset
   226
 * Wlan scan is performed as a "post-initialization" which is executed in a
39
hgs
parents: 31
diff changeset
   227
 * separate scheduler loop. If scan results are available, starts reading them.
31
hgs
parents:
diff changeset
   228
 */
hgs
parents:
diff changeset
   229
void WlanWizardPageScanning::startOperation()
hgs
parents:
diff changeset
   230
{
43
hgs
parents: 39
diff changeset
   231
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_STARTOPERATION_ENTRY );
31
hgs
parents:
diff changeset
   232
    OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESCANNING_STARTOPERATION,
hgs
parents:
diff changeset
   233
        "WlanWizardPageScanning::startOperation - start AP scan if results"
hgs
parents:
diff changeset
   234
        " are available." );
hgs
parents:
diff changeset
   235
hgs
parents:
diff changeset
   236
    if (mScanResultsAvailable) {
hgs
parents:
diff changeset
   237
        mScanResultsAvailable = false;
hgs
parents:
diff changeset
   238
        wlanScanApReady();
hgs
parents:
diff changeset
   239
    }
43
hgs
parents: 39
diff changeset
   240
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_STARTOPERATION_EXIT );
31
hgs
parents:
diff changeset
   241
}
hgs
parents:
diff changeset
   242
39
hgs
parents: 31
diff changeset
   243
/*!
hgs
parents: 31
diff changeset
   244
 * Loads the document orientation information from occ_add_wlan_06.docml
hgs
parents: 31
diff changeset
   245
 * This is called each time phone orientation changes.
hgs
parents: 31
diff changeset
   246
 * @param [in] orientation indicates whether the phone is in portrait or
hgs
parents: 31
diff changeset
   247
 * landscape mode.
hgs
parents: 31
diff changeset
   248
 */
hgs
parents: 31
diff changeset
   249
void WlanWizardPageScanning::loadDocmlSection(Qt::Orientation orientation)
hgs
parents: 31
diff changeset
   250
{
43
hgs
parents: 39
diff changeset
   251
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_LOADDOCMLSECTION_ENTRY );
39
hgs
parents: 31
diff changeset
   252
    OstTrace1( TRACE_NORMAL, WLANWIZARDPAGESCANNING_LOADDOCML,
hgs
parents: 31
diff changeset
   253
        "WlanWizardPageScanning::loadDocml - orientation ;orientation=%x",
hgs
parents: 31
diff changeset
   254
        ( TUint )( orientation ) );
hgs
parents: 31
diff changeset
   255
hgs
parents: 31
diff changeset
   256
    WlanWizardPageInternal::loadDocmlSection(
hgs
parents: 31
diff changeset
   257
        mLoader,
hgs
parents: 31
diff changeset
   258
        orientation,
hgs
parents: 31
diff changeset
   259
        ":/docml/occ_add_wlan_06.docml", 
hgs
parents: 31
diff changeset
   260
        "portrait_section",
hgs
parents: 31
diff changeset
   261
        "landscape_section");
43
hgs
parents: 39
diff changeset
   262
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_LOADDOCMLSECTION_EXIT );
39
hgs
parents: 31
diff changeset
   263
}
hgs
parents: 31
diff changeset
   264
hgs
parents: 31
diff changeset
   265
/*!
hgs
parents: 31
diff changeset
   266
 * Checks whether the view is active. If it is, execute wlanScanApReady. If
hgs
parents: 31
diff changeset
   267
 * not, set mScanResultsAvailable to true.
hgs
parents: 31
diff changeset
   268
 * @param [in] scanStatus indicates whether the scan was succesful, cancelled of
hgs
parents: 31
diff changeset
   269
 * failed. The argument is saved to a member variable.
hgs
parents: 31
diff changeset
   270
 */
hgs
parents: 31
diff changeset
   271
void WlanWizardPageScanning::wlanScanResultPreCheck(int scanStatus)
hgs
parents: 31
diff changeset
   272
{
43
hgs
parents: 39
diff changeset
   273
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_WLANSCANRESULTPRECHECK_ENTRY );
39
hgs
parents: 31
diff changeset
   274
    mScanStatus = scanStatus;
hgs
parents: 31
diff changeset
   275
    
hgs
parents: 31
diff changeset
   276
    if (!mWidget) {
hgs
parents: 31
diff changeset
   277
        OstTrace1( TRACE_BORDER, WLANWIZARDPAGESCANNING_WLANSCANRESULTPRECHECK,
hgs
parents: 31
diff changeset
   278
            "WlanWizardPageScanning::wlanScanResultPreCheck no widget;this=%x",
hgs
parents: 31
diff changeset
   279
            this );
hgs
parents: 31
diff changeset
   280
hgs
parents: 31
diff changeset
   281
        mScanResultsAvailable = true;
hgs
parents: 31
diff changeset
   282
    } else {
hgs
parents: 31
diff changeset
   283
        if (mWizard->isCurrentPage(mWidget)) {
hgs
parents: 31
diff changeset
   284
            OstTrace0( TRACE_BORDER,
hgs
parents: 31
diff changeset
   285
                DUP1_WLANWIZARDPAGESCANNING_WLANSCANRESULTPRECHECK,
hgs
parents: 31
diff changeset
   286
                "WlanWizardPageScanning::wlanScanResultPreCheck go to results");
hgs
parents: 31
diff changeset
   287
hgs
parents: 31
diff changeset
   288
            wlanScanApReady();
hgs
parents: 31
diff changeset
   289
        } else {
hgs
parents: 31
diff changeset
   290
            OstTrace0( TRACE_BORDER,
hgs
parents: 31
diff changeset
   291
                DUP2_WLANWIZARDPAGESCANNING_WLANSCANRESULTPRECHECK,
hgs
parents: 31
diff changeset
   292
                "WlanWizardPageScanning::wlanScanResultPreCheck"
hgs
parents: 31
diff changeset
   293
                " not current widget" );
hgs
parents: 31
diff changeset
   294
hgs
parents: 31
diff changeset
   295
            mScanResultsAvailable = true;
hgs
parents: 31
diff changeset
   296
        }
hgs
parents: 31
diff changeset
   297
    }
43
hgs
parents: 39
diff changeset
   298
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_WLANSCANRESULTPRECHECK_EXIT );
39
hgs
parents: 31
diff changeset
   299
}
hgs
parents: 31
diff changeset
   300
hgs
parents: 31
diff changeset
   301
/*!
hgs
parents: 31
diff changeset
   302
 * Processes the direct scan results.
hgs
parents: 31
diff changeset
   303
 * @param [in] scanStatus indicates whether the scan was succesful, canceled or
hgs
parents: 31
diff changeset
   304
 * failed. In case the scan was not succesful, always proceed to manual wizard.
hgs
parents: 31
diff changeset
   305
 */
hgs
parents: 31
diff changeset
   306
void WlanWizardPageScanning::wlanScanDirectReady(int scanStatus)
hgs
parents: 31
diff changeset
   307
{
43
hgs
parents: 39
diff changeset
   308
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_WLANSCANDIRECTREADY_ENTRY );
39
hgs
parents: 31
diff changeset
   309
    OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESCANNING_WLANSCANDIRECTREADY,
hgs
parents: 31
diff changeset
   310
        "WlanWizardPageScanning::wlanScanDirectReady" );
hgs
parents: 31
diff changeset
   311
hgs
parents: 31
diff changeset
   312
    WlanQtUtils* utils = mWizard->wlanQtUtils();
hgs
parents: 31
diff changeset
   313
hgs
parents: 31
diff changeset
   314
    Q_ASSERT(utils);
hgs
parents: 31
diff changeset
   315
hgs
parents: 31
diff changeset
   316
    QList<WlanScanResult> filteredResults;
hgs
parents: 31
diff changeset
   317
hgs
parents: 31
diff changeset
   318
    if (scanStatus == WlanQtUtils::ScanStatusOk) {
hgs
parents: 31
diff changeset
   319
        QList<QSharedPointer<WlanQtUtilsAp> > directScanResults;
hgs
parents: 31
diff changeset
   320
        // Read the directed scan results from Qt Utils
hgs
parents: 31
diff changeset
   321
        utils->availableWlanAps(directScanResults);
hgs
parents: 31
diff changeset
   322
hgs
parents: 31
diff changeset
   323
        // Identify open and hidden networks.
hgs
parents: 31
diff changeset
   324
        getFinalScanResults(directScanResults, mWlanApList, filteredResults);
hgs
parents: 31
diff changeset
   325
    }
hgs
parents: 31
diff changeset
   326
hgs
parents: 31
diff changeset
   327
    // Process the scan results. If scan status is not ok, feed an empty
hgs
parents: 31
diff changeset
   328
    // result table to the selection function.
hgs
parents: 31
diff changeset
   329
    selectNextPageActions(filteredResults);
43
hgs
parents: 39
diff changeset
   330
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_WLANSCANDIRECTREADY_EXIT );
39
hgs
parents: 31
diff changeset
   331
}
hgs
parents: 31
diff changeset
   332
hgs
parents: 31
diff changeset
   333
/*!
hgs
parents: 31
diff changeset
   334
 * All wlan channels have been scanned for public networks. After processing the
hgs
parents: 31
diff changeset
   335
 * results a direct scan is initiated. This function also checks whether the
hgs
parents: 31
diff changeset
   336
 * scan was succesful, canceled or failed. In case the scan was not succesful,
hgs
parents: 31
diff changeset
   337
 * always proceed to manual wizard.
hgs
parents: 31
diff changeset
   338
 */
hgs
parents: 31
diff changeset
   339
void WlanWizardPageScanning::wlanScanApReady()
hgs
parents: 31
diff changeset
   340
{
43
hgs
parents: 39
diff changeset
   341
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_WLANSCANAPREADY_ENTRY );
39
hgs
parents: 31
diff changeset
   342
    OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESCANNING_WLANSCANAPREADY,
hgs
parents: 31
diff changeset
   343
        "WlanWizardPageScanning::wlanScanApReady" );
hgs
parents: 31
diff changeset
   344
hgs
parents: 31
diff changeset
   345
    if (mScanStatus == WlanQtUtils::ScanStatusOk) {
hgs
parents: 31
diff changeset
   346
        WlanQtUtils* utils = mWizard->wlanQtUtils();
hgs
parents: 31
diff changeset
   347
        Q_ASSERT(utils);
hgs
parents: 31
diff changeset
   348
hgs
parents: 31
diff changeset
   349
        QList<QSharedPointer<WlanQtUtilsAp> > openScanResults;
hgs
parents: 31
diff changeset
   350
hgs
parents: 31
diff changeset
   351
        // Fetch the list of scan results.
hgs
parents: 31
diff changeset
   352
        utils->availableWlanAps(openScanResults);
hgs
parents: 31
diff changeset
   353
hgs
parents: 31
diff changeset
   354
        // The name of the network that we are looking for.
hgs
parents: 31
diff changeset
   355
        QString ssid =
hgs
parents: 31
diff changeset
   356
            mWizard->configuration(WlanWizardPrivate::ConfSsid).toString();
hgs
parents: 31
diff changeset
   357
hgs
parents: 31
diff changeset
   358
        // Store matching scan results.
hgs
parents: 31
diff changeset
   359
        getSsidMatchList(ssid, openScanResults);
hgs
parents: 31
diff changeset
   360
hgs
parents: 31
diff changeset
   361
        // Next directed scan.
hgs
parents: 31
diff changeset
   362
        utils->scanWlanDirect(ssid);
hgs
parents: 31
diff changeset
   363
    }
hgs
parents: 31
diff changeset
   364
    else {
hgs
parents: 31
diff changeset
   365
        mWizard->clearConfiguration(WlanWizardHelper::ConfAvailableNetworkOptions);
hgs
parents: 31
diff changeset
   366
        mNextPageId = WlanWizardPageInternal::PageNetworkMode;
hgs
parents: 31
diff changeset
   367
        mWizard->nextPage();
hgs
parents: 31
diff changeset
   368
    }
43
hgs
parents: 39
diff changeset
   369
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_WLANSCANAPREADY_EXIT );
39
hgs
parents: 31
diff changeset
   370
}
hgs
parents: 31
diff changeset
   371
hgs
parents: 31
diff changeset
   372
/*!
hgs
parents: 31
diff changeset
   373
 * This function stores all the APs that match ssid parameter to mWlanApList
hgs
parents: 31
diff changeset
   374
 * member list.
hgs
parents: 31
diff changeset
   375
 * @param [in] ssid is the name of the network we are interested in.
hgs
parents: 31
diff changeset
   376
 * @param [in] matchList is the list of all APs that were revealed in the scan.
hgs
parents: 31
diff changeset
   377
 */
hgs
parents: 31
diff changeset
   378
void WlanWizardPageScanning::getSsidMatchList(
hgs
parents: 31
diff changeset
   379
    QString ssid,
hgs
parents: 31
diff changeset
   380
    const QList<QSharedPointer<WlanQtUtilsAp> > &matchList)
hgs
parents: 31
diff changeset
   381
{
43
hgs
parents: 39
diff changeset
   382
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_GETSSIDMATCHLIST_ENTRY );
39
hgs
parents: 31
diff changeset
   383
    mWlanApList.clear();
hgs
parents: 31
diff changeset
   384
    QSharedPointer<WlanQtUtilsAp> item;
hgs
parents: 31
diff changeset
   385
hgs
parents: 31
diff changeset
   386
    for (int i = 0; i < matchList.size(); i++) {
hgs
parents: 31
diff changeset
   387
        item = matchList.at(i);
hgs
parents: 31
diff changeset
   388
        if (item->value(WlanQtUtilsAp::ConfIdSsid).toString() == ssid) {
hgs
parents: 31
diff changeset
   389
            mWlanApList.append(item);
hgs
parents: 31
diff changeset
   390
        }
hgs
parents: 31
diff changeset
   391
    }
43
hgs
parents: 39
diff changeset
   392
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_GETSSIDMATCHLIST_EXIT );
39
hgs
parents: 31
diff changeset
   393
}
hgs
parents: 31
diff changeset
   394
hgs
parents: 31
diff changeset
   395
/*
hgs
parents: 31
diff changeset
   396
 * Find out which of the direct scan results are open networks by comparing
hgs
parents: 31
diff changeset
   397
 * result to open scan results. Return finalResults.
hgs
parents: 31
diff changeset
   398
 * @param [in] directScanResults are the results of a directed scan.
hgs
parents: 31
diff changeset
   399
 * @param [in] openScanResults are the results of a scan inquiring any APs.
hgs
parents: 31
diff changeset
   400
 * @param [out] finalResults is a list of APs with visibility flag included.
hgs
parents: 31
diff changeset
   401
 */
hgs
parents: 31
diff changeset
   402
void WlanWizardPageScanning::getFinalScanResults(
hgs
parents: 31
diff changeset
   403
    const QList<QSharedPointer<WlanQtUtilsAp> > &directScanResults,
hgs
parents: 31
diff changeset
   404
    const QList<QSharedPointer<WlanQtUtilsAp> > &openScanResults,
hgs
parents: 31
diff changeset
   405
    QList<WlanScanResult> &finalResults)
hgs
parents: 31
diff changeset
   406
{
43
hgs
parents: 39
diff changeset
   407
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_GETFINALSCANRESULTS_ENTRY );
39
hgs
parents: 31
diff changeset
   408
    finalResults.clear();
hgs
parents: 31
diff changeset
   409
hgs
parents: 31
diff changeset
   410
    // The key assumption of this algorithm is that both direct and public scan
hgs
parents: 31
diff changeset
   411
    // reveal the same set of AP:s with the exception of hidden AP:s.
hgs
parents: 31
diff changeset
   412
    // In other words: Direct scan result set is the whole set with each AP 
hgs
parents: 31
diff changeset
   413
    // marked as hidden by default. If an AP has been revealed also by public
hgs
parents: 31
diff changeset
   414
    // scan, it is changed to visible.
hgs
parents: 31
diff changeset
   415
    for (int i = 0; i < directScanResults.size(); i++) {
hgs
parents: 31
diff changeset
   416
        WlanScanResult resultItem;
hgs
parents: 31
diff changeset
   417
hgs
parents: 31
diff changeset
   418
        resultItem.scanResult = directScanResults.at(i);
hgs
parents: 31
diff changeset
   419
        
hgs
parents: 31
diff changeset
   420
        // Initialize as hidden.
hgs
parents: 31
diff changeset
   421
        resultItem.networkHidden = true;
hgs
parents: 31
diff changeset
   422
         
hgs
parents: 31
diff changeset
   423
        for (int j = 0; j < openScanResults.size(); j++) {
hgs
parents: 31
diff changeset
   424
            if (WlanQtUtilsAp::compare(
hgs
parents: 31
diff changeset
   425
                openScanResults.at(j).data(), 
hgs
parents: 31
diff changeset
   426
                directScanResults.at(i).data()) == 0) {
hgs
parents: 31
diff changeset
   427
                // Mark open, if a public scan revealed the same AP
hgs
parents: 31
diff changeset
   428
                resultItem.networkHidden = false;
hgs
parents: 31
diff changeset
   429
            }
hgs
parents: 31
diff changeset
   430
        }
hgs
parents: 31
diff changeset
   431
hgs
parents: 31
diff changeset
   432
        finalResults.append(resultItem);
hgs
parents: 31
diff changeset
   433
    }
43
hgs
parents: 39
diff changeset
   434
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_GETFINALSCANRESULTS_EXIT );
39
hgs
parents: 31
diff changeset
   435
}
hgs
parents: 31
diff changeset
   436
hgs
parents: 31
diff changeset
   437
/*!
hgs
parents: 31
diff changeset
   438
 * This function processes the scan results in case multiple results were
hgs
parents: 31
diff changeset
   439
 * acquired with matching SSIDs.
hgs
parents: 31
diff changeset
   440
 * @param [in] finalResults is the list of APs revealed by the last scans.
hgs
parents: 31
diff changeset
   441
 * @return the identifier of the next page.
hgs
parents: 31
diff changeset
   442
 */
hgs
parents: 31
diff changeset
   443
int WlanWizardPageScanning::processMultipleScanResults(
hgs
parents: 31
diff changeset
   444
    const QList<WlanScanResult> &finalResults)
hgs
parents: 31
diff changeset
   445
{
43
hgs
parents: 39
diff changeset
   446
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_PROCESSMULTIPLESCANRESULTS_ENTRY );
39
hgs
parents: 31
diff changeset
   447
    WlanWizardScanList networkOptions;
hgs
parents: 31
diff changeset
   448
    int nextPage;
hgs
parents: 31
diff changeset
   449
hgs
parents: 31
diff changeset
   450
    // Build the list of results to be placed in the configuration.
hgs
parents: 31
diff changeset
   451
    networkOptions.build(finalResults);
hgs
parents: 31
diff changeset
   452
    
hgs
parents: 31
diff changeset
   453
    QVariant tmp;
hgs
parents: 31
diff changeset
   454
    tmp.setValue(networkOptions);
hgs
parents: 31
diff changeset
   455
hgs
parents: 31
diff changeset
   456
    mWizard->setConfiguration(
hgs
parents: 31
diff changeset
   457
        WlanWizardHelper::ConfAvailableNetworkOptions, tmp);
hgs
parents: 31
diff changeset
   458
43
hgs
parents: 39
diff changeset
   459
    if (networkOptions.wpsSelected()) {
hgs
parents: 39
diff changeset
   460
        // In case all available network mode options support wps, go directly
hgs
parents: 39
diff changeset
   461
        // to wps-wizard.
hgs
parents: 39
diff changeset
   462
        nextPage = WlanWizardPageInternal::PageWpsStart;
hgs
parents: 39
diff changeset
   463
    } else if (networkOptions.netModes() > SingleResult) {
hgs
parents: 39
diff changeset
   464
        // If there are more than one network mode choices, go to manual selection
hgs
parents: 39
diff changeset
   465
        // of network mode.
39
hgs
parents: 31
diff changeset
   466
        nextPage = WlanWizardPageInternal::PageNetworkMode;
hgs
parents: 31
diff changeset
   467
    } else {
hgs
parents: 31
diff changeset
   468
        // if only a single network mode option is available, the mode query
hgs
parents: 31
diff changeset
   469
        // may be skipped and the next page is set to security mode query.
hgs
parents: 31
diff changeset
   470
        WlanNetworkSetting setting = networkOptions.getNetModes().at(0);
hgs
parents: 31
diff changeset
   471
        mWizard->setConfiguration(WlanWizardHelper::ConfNetworkMode, setting.mode);
hgs
parents: 31
diff changeset
   472
        mWizard->setConfiguration(WlanWizardHelper::ConfHiddenWlan, setting.hidden);
43
hgs
parents: 39
diff changeset
   473
        mWizard->setConfiguration(WlanWizardHelper::ConfWpsSupported, setting.wpsSupported);
39
hgs
parents: 31
diff changeset
   474
        nextPage = WlanWizardPageInternal::PageNetworkSecurity;
hgs
parents: 31
diff changeset
   475
    }
hgs
parents: 31
diff changeset
   476
    
43
hgs
parents: 39
diff changeset
   477
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_PROCESSMULTIPLESCANRESULTS_EXIT );
39
hgs
parents: 31
diff changeset
   478
    return nextPage;
hgs
parents: 31
diff changeset
   479
}
hgs
parents: 31
diff changeset
   480
hgs
parents: 31
diff changeset
   481
/*!
hgs
parents: 31
diff changeset
   482
 * This function decides what to do with the scan results.
hgs
parents: 31
diff changeset
   483
 * @param [in] finalResults is the list of APs revealed by the last scans.
hgs
parents: 31
diff changeset
   484
 */
hgs
parents: 31
diff changeset
   485
void WlanWizardPageScanning::selectNextPageActions(
hgs
parents: 31
diff changeset
   486
    const QList<WlanScanResult> &finalResults)
hgs
parents: 31
diff changeset
   487
{
43
hgs
parents: 39
diff changeset
   488
    OstTraceFunctionEntry0( WLANWIZARDPAGESCANNING_SELECTNEXTPAGEACTIONS_ENTRY );
39
hgs
parents: 31
diff changeset
   489
    mWizard->clearConfiguration(WlanWizardHelper::ConfAvailableNetworkOptions);
hgs
parents: 31
diff changeset
   490
    
hgs
parents: 31
diff changeset
   491
    if (finalResults.isEmpty()) {
hgs
parents: 31
diff changeset
   492
        // In case of no results at all were found.
hgs
parents: 31
diff changeset
   493
        mNextPageId = WlanWizardPageInternal::PageNetworkMode;
hgs
parents: 31
diff changeset
   494
    } else if (finalResults.size() == SingleResult) {
hgs
parents: 31
diff changeset
   495
        // In case there is only a single result.
hgs
parents: 31
diff changeset
   496
        WlanScanResult item = finalResults.first();
hgs
parents: 31
diff changeset
   497
        mNextPageId = mWizard->getNextPageId(
hgs
parents: 31
diff changeset
   498
            item.scanResult->value(WlanQtUtilsAp::ConfIdSsid).toString(),
hgs
parents: 31
diff changeset
   499
            item.scanResult->value(WlanQtUtilsAp::ConfIdConnectionMode).toInt(),
hgs
parents: 31
diff changeset
   500
            item.scanResult->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(),
hgs
parents: 31
diff changeset
   501
            item.scanResult->value(WlanQtUtilsAp::ConfIdWpaPskUse).toBool(),
hgs
parents: 31
diff changeset
   502
            item.networkHidden,
hgs
parents: 31
diff changeset
   503
            item.scanResult->value(WlanQtUtilsAp::ConfIdWpsSupported).toBool());
hgs
parents: 31
diff changeset
   504
    } else {
hgs
parents: 31
diff changeset
   505
        // In case more than one result is available.
hgs
parents: 31
diff changeset
   506
        mWizard->setConfiguration(WlanWizardHelper::ConfProcessSettings, true);
hgs
parents: 31
diff changeset
   507
        mNextPageId = processMultipleScanResults(finalResults);
hgs
parents: 31
diff changeset
   508
    }
hgs
parents: 31
diff changeset
   509
hgs
parents: 31
diff changeset
   510
    mWizard->nextPage();
43
hgs
parents: 39
diff changeset
   511
    OstTraceFunctionExit0( WLANWIZARDPAGESCANNING_SELECTNEXTPAGEACTIONS_EXIT );
39
hgs
parents: 31
diff changeset
   512
}