wlanutilities/wlansniffer/wlansnifferapplication/src/wlansnifferlistview.cpp
author hgs
Mon, 23 Aug 2010 13:30:09 +0300
changeset 53 bdc64aa9b954
parent 49 fb81b597edf1
child 58 301aeb18ae47
permissions -rw-r--r--
201033
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:
hgs
parents:
diff changeset
    15
* WLAN Sniffer List View. 
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
// System includes
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
#include <QGraphicsWidget>
hgs
parents:
diff changeset
    21
#include <QSharedPointer>
53
hgs
parents: 49
diff changeset
    22
#include <QObjectList>
31
hgs
parents:
diff changeset
    23
hgs
parents:
diff changeset
    24
#include <HbLabel>
hgs
parents:
diff changeset
    25
#include <HbPushButton>
hgs
parents:
diff changeset
    26
#include <HbMenu>
hgs
parents:
diff changeset
    27
#include <HbAction>
hgs
parents:
diff changeset
    28
#include <HbListWidget>
hgs
parents:
diff changeset
    29
#include <HbListWidgetItem>
hgs
parents:
diff changeset
    30
#include <HbDocumentLoader>
hgs
parents:
diff changeset
    31
#include <HbInstance>
hgs
parents:
diff changeset
    32
#include <HbMessageBox>
49
hgs
parents: 39
diff changeset
    33
#include <HbParameterLengthLimiter>
31
hgs
parents:
diff changeset
    34
hgs
parents:
diff changeset
    35
#include <xqserviceutil.h>
hgs
parents:
diff changeset
    36
hgs
parents:
diff changeset
    37
// User includes
hgs
parents:
diff changeset
    38
hgs
parents:
diff changeset
    39
#include "wlanqtutils.h"
hgs
parents:
diff changeset
    40
#include "wlanqtutilsap.h"
hgs
parents:
diff changeset
    41
#include "wlanqtutilsiap.h"
hgs
parents:
diff changeset
    42
hgs
parents:
diff changeset
    43
#include "wlansnifferengine.h"
hgs
parents:
diff changeset
    44
#include "wlansniffermainwindow.h"
hgs
parents:
diff changeset
    45
#include "wlansnifferlistview.h"
hgs
parents:
diff changeset
    46
#include "wlansnifferlistitem.h"
hgs
parents:
diff changeset
    47
#include "wlansnifferlistwidget.h"
hgs
parents:
diff changeset
    48
hgs
parents:
diff changeset
    49
#include "OstTraceDefinitions.h"
hgs
parents:
diff changeset
    50
#ifdef OST_TRACE_COMPILER_IN_USE
hgs
parents:
diff changeset
    51
#include "wlansnifferlistviewTraces.h"
hgs
parents:
diff changeset
    52
#endif
hgs
parents:
diff changeset
    53
hgs
parents:
diff changeset
    54
/*!
hgs
parents:
diff changeset
    55
    \class WlanSnifferListView
hgs
parents:
diff changeset
    56
    \brief WLAN Sniffer application's list view implementation.
hgs
parents:
diff changeset
    57
*/
hgs
parents:
diff changeset
    58
hgs
parents:
diff changeset
    59
// External function prototypes
hgs
parents:
diff changeset
    60
hgs
parents:
diff changeset
    61
// Local constants
hgs
parents:
diff changeset
    62
hgs
parents:
diff changeset
    63
//! WLAN Sniffer list view docml file location
hgs
parents:
diff changeset
    64
static const QString WlanSnifferListViewDocml(":/docml/wlansnifferlistview.docml");
hgs
parents:
diff changeset
    65
53
hgs
parents: 49
diff changeset
    66
//! WLAN Sniffer list view object name
hgs
parents: 49
diff changeset
    67
static const QString WlanSnifferListViewName("occ_list");
hgs
parents: 49
diff changeset
    68
31
hgs
parents:
diff changeset
    69
// ======== LOCAL FUNCTIONS ========
hgs
parents:
diff changeset
    70
hgs
parents:
diff changeset
    71
// ======== MEMBER FUNCTIONS ========
hgs
parents:
diff changeset
    72
hgs
parents:
diff changeset
    73
/*!
hgs
parents:
diff changeset
    74
    Constructor.
hgs
parents:
diff changeset
    75
    
hgs
parents:
diff changeset
    76
    @param [in] engine WLAN Sniffer application engine.
hgs
parents:
diff changeset
    77
    @param [in] mainWindow WLAN Sniffer main window.
hgs
parents:
diff changeset
    78
*/
hgs
parents:
diff changeset
    79
hgs
parents:
diff changeset
    80
WlanSnifferListView::WlanSnifferListView(
hgs
parents:
diff changeset
    81
    WlanSnifferEngine *engine,
53
hgs
parents: 49
diff changeset
    82
    WlanSnifferMainWindow *mainWindow) :
hgs
parents: 49
diff changeset
    83
    HbView(),
31
hgs
parents:
diff changeset
    84
    mDocLoader(new HbDocumentLoader(mainWindow)),
hgs
parents:
diff changeset
    85
    mWlanListWidget(),
hgs
parents:
diff changeset
    86
    mContextMenu(),
hgs
parents:
diff changeset
    87
    mContextMenuData(),
hgs
parents:
diff changeset
    88
    mWlanEnableDialog(),
hgs
parents:
diff changeset
    89
    mIgnoreWlanScanResults(false),
hgs
parents:
diff changeset
    90
    mConnectingIapId(WlanQtUtils::IapIdNone),
hgs
parents:
diff changeset
    91
    mEngine(engine),
hgs
parents:
diff changeset
    92
    mSwitchWlanAction(0),
hgs
parents:
diff changeset
    93
    mAddWlanAction(0),
hgs
parents:
diff changeset
    94
    mWlanList(0),
hgs
parents:
diff changeset
    95
    mStatusLabel(0),
hgs
parents:
diff changeset
    96
    mWlanButton(0)
hgs
parents:
diff changeset
    97
{
hgs
parents:
diff changeset
    98
    OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_WLANSNIFFERLISTVIEW_ENTRY);
hgs
parents:
diff changeset
    99
hgs
parents:
diff changeset
   100
    // Initialize UI from the docml based on standalone/embedded status
hgs
parents:
diff changeset
   101
    loadDocml(mEngine->isEmbedded());
hgs
parents:
diff changeset
   102
hgs
parents:
diff changeset
   103
    if (mEngine->isEmbedded()) {
hgs
parents:
diff changeset
   104
        // We need to create a custom navigation action and handle exiting
hgs
parents:
diff changeset
   105
        // from the application differently in case the application was
hgs
parents:
diff changeset
   106
        // launched as embedded via QtHighway
hgs
parents:
diff changeset
   107
        HbAction *completeAction = new HbAction(Hb::BackNaviAction, this);
hgs
parents:
diff changeset
   108
        setNavigationAction(completeAction);
hgs
parents:
diff changeset
   109
        bool connectStatus = connect(
hgs
parents:
diff changeset
   110
            completeAction,
hgs
parents:
diff changeset
   111
            SIGNAL(triggered(bool)),
hgs
parents:
diff changeset
   112
            mEngine,
hgs
parents:
diff changeset
   113
            SLOT(completeService()));
hgs
parents:
diff changeset
   114
        Q_ASSERT(connectStatus);
hgs
parents:
diff changeset
   115
    }
hgs
parents:
diff changeset
   116
    
hgs
parents:
diff changeset
   117
    // Connect WLAN network open & close signals
hgs
parents:
diff changeset
   118
    bool connectStatus = connect(
hgs
parents:
diff changeset
   119
        mEngine->wlanQtUtils(),
hgs
parents:
diff changeset
   120
        SIGNAL(wlanNetworkOpened(int)),
hgs
parents:
diff changeset
   121
        this,
hgs
parents:
diff changeset
   122
        SLOT(updateConnectionOpened(int)));
hgs
parents:
diff changeset
   123
    Q_ASSERT(connectStatus);
hgs
parents:
diff changeset
   124
    connectStatus = connect(
hgs
parents:
diff changeset
   125
        mEngine->wlanQtUtils(),
hgs
parents:
diff changeset
   126
        SIGNAL(wlanNetworkClosed(int, int)),
hgs
parents:
diff changeset
   127
        this,
hgs
parents:
diff changeset
   128
        SLOT(updateConnectionClosed(int))); // "reason" parameter ignored
hgs
parents:
diff changeset
   129
    Q_ASSERT(connectStatus);
hgs
parents:
diff changeset
   130
    
hgs
parents:
diff changeset
   131
    // Connect WLAN ON/OFF setting change signal
hgs
parents:
diff changeset
   132
    connectStatus = connect(
hgs
parents:
diff changeset
   133
        mEngine,
hgs
parents:
diff changeset
   134
        SIGNAL(masterWlanStatus(bool)),
hgs
parents:
diff changeset
   135
        this,
hgs
parents:
diff changeset
   136
        SLOT(updateWlanEnabled()));
hgs
parents:
diff changeset
   137
    Q_ASSERT(connectStatus);
hgs
parents:
diff changeset
   138
    
hgs
parents:
diff changeset
   139
    // Connect Force Disable WLAN setting change signal
hgs
parents:
diff changeset
   140
    connectStatus = connect(
hgs
parents:
diff changeset
   141
        mEngine,
hgs
parents:
diff changeset
   142
        SIGNAL(forceDisableWlanStatus(bool)),
hgs
parents:
diff changeset
   143
        this,
hgs
parents:
diff changeset
   144
        SLOT(updateWlanEnabled()));
hgs
parents:
diff changeset
   145
    Q_ASSERT(connectStatus);
hgs
parents:
diff changeset
   146
hgs
parents:
diff changeset
   147
    // Connect signals to catch user interaction with the WLAN network list
hgs
parents:
diff changeset
   148
    connectStatus = connect(
hgs
parents:
diff changeset
   149
        mWlanList,
hgs
parents:
diff changeset
   150
        SIGNAL(activated(HbListWidgetItem *)),
hgs
parents:
diff changeset
   151
        this,
hgs
parents:
diff changeset
   152
        SLOT(handleListItemActivated(HbListWidgetItem *)));
hgs
parents:
diff changeset
   153
    Q_ASSERT(connectStatus);
hgs
parents:
diff changeset
   154
    connectStatus = connect(
hgs
parents:
diff changeset
   155
        mWlanList,
hgs
parents:
diff changeset
   156
        SIGNAL(longPressed(HbListWidgetItem *, QPointF)),
hgs
parents:
diff changeset
   157
        this,
hgs
parents:
diff changeset
   158
        SLOT(handleListItemLongPressed(HbListWidgetItem *, QPointF)));
hgs
parents:
diff changeset
   159
    Q_ASSERT(connectStatus);
hgs
parents:
diff changeset
   160
hgs
parents:
diff changeset
   161
    // Connect signals to catch user interaction with WLAN ON/OFF switching
hgs
parents:
diff changeset
   162
    connectStatus = connect(
hgs
parents:
diff changeset
   163
        mWlanButton,
hgs
parents:
diff changeset
   164
        SIGNAL(clicked(bool)),
hgs
parents:
diff changeset
   165
        this,
hgs
parents:
diff changeset
   166
        SLOT(handleWlanToggled()));
hgs
parents:
diff changeset
   167
    Q_ASSERT(connectStatus);
hgs
parents:
diff changeset
   168
    connectStatus = connect(
hgs
parents:
diff changeset
   169
        mSwitchWlanAction,
hgs
parents:
diff changeset
   170
        SIGNAL(triggered(bool)),
hgs
parents:
diff changeset
   171
        this,
hgs
parents:
diff changeset
   172
        SLOT(handleWlanToggled()));
hgs
parents:
diff changeset
   173
    Q_ASSERT(connectStatus);
hgs
parents:
diff changeset
   174
39
hgs
parents: 31
diff changeset
   175
    // Connect adding WLAN manually
hgs
parents: 31
diff changeset
   176
    connectStatus = connect(
hgs
parents: 31
diff changeset
   177
        mAddWlanAction,
hgs
parents: 31
diff changeset
   178
        SIGNAL(triggered(bool)),
hgs
parents: 31
diff changeset
   179
        this,
hgs
parents: 31
diff changeset
   180
        SLOT(startWlanWizard()));
hgs
parents: 31
diff changeset
   181
    Q_ASSERT(connectStatus);
hgs
parents: 31
diff changeset
   182
    
31
hgs
parents:
diff changeset
   183
    // Connect WLAN scan results signal
hgs
parents:
diff changeset
   184
    connectStatus = connect(
hgs
parents:
diff changeset
   185
        mEngine,
hgs
parents:
diff changeset
   186
        SIGNAL(wlanScanReady()),
hgs
parents:
diff changeset
   187
        this,
hgs
parents:
diff changeset
   188
        SLOT(updateListContent()));
hgs
parents:
diff changeset
   189
    Q_ASSERT(connectStatus);
hgs
parents:
diff changeset
   190
hgs
parents:
diff changeset
   191
    // Set the initial value of WLAN state
hgs
parents:
diff changeset
   192
    updateWlanEnabled();
hgs
parents:
diff changeset
   193
hgs
parents:
diff changeset
   194
    OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_WLANSNIFFERLISTVIEW_EXIT);
hgs
parents:
diff changeset
   195
}
hgs
parents:
diff changeset
   196
hgs
parents:
diff changeset
   197
/*!
hgs
parents:
diff changeset
   198
    Destructor.
hgs
parents:
diff changeset
   199
*/
hgs
parents:
diff changeset
   200
hgs
parents:
diff changeset
   201
WlanSnifferListView::~WlanSnifferListView()
hgs
parents:
diff changeset
   202
{
hgs
parents:
diff changeset
   203
    OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_WLANSNIFFERLISTVIEWDESTR_ENTRY);
hgs
parents:
diff changeset
   204
    OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_WLANSNIFFERLISTVIEWDESTR_EXIT);
hgs
parents:
diff changeset
   205
}
hgs
parents:
diff changeset
   206
hgs
parents:
diff changeset
   207
/*!
hgs
parents:
diff changeset
   208
    Loading of WLAN Sniffer List View docml.
hgs
parents:
diff changeset
   209
    
hgs
parents:
diff changeset
   210
    @param [in] isEmbedded TRUE if WLAN Sniffer is launched as embedded. 
hgs
parents:
diff changeset
   211
*/
hgs
parents:
diff changeset
   212
hgs
parents:
diff changeset
   213
void WlanSnifferListView::loadDocml(bool isEmbedded)
hgs
parents:
diff changeset
   214
{
hgs
parents:
diff changeset
   215
    OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_LOADDOCML_ENTRY);
53
hgs
parents: 49
diff changeset
   216
hgs
parents: 49
diff changeset
   217
    // Pass the view to the document loader. Document loader uses this view
hgs
parents: 49
diff changeset
   218
    // when docml is parsed, instead of creating a new view.
hgs
parents: 49
diff changeset
   219
    setObjectName(WlanSnifferListViewName);
hgs
parents: 49
diff changeset
   220
    QObjectList objectList;
hgs
parents: 49
diff changeset
   221
    objectList.append(this);
hgs
parents: 49
diff changeset
   222
    mDocLoader->setObjectTree(objectList);
hgs
parents: 49
diff changeset
   223
hgs
parents: 49
diff changeset
   224
    // First load the common section
31
hgs
parents:
diff changeset
   225
    bool ok = false;
hgs
parents:
diff changeset
   226
    mDocLoader->load(WlanSnifferListViewDocml, &ok);
hgs
parents:
diff changeset
   227
    Q_ASSERT(ok);
hgs
parents:
diff changeset
   228
    
hgs
parents:
diff changeset
   229
    // Then load the mode specific section
hgs
parents:
diff changeset
   230
    if (isEmbedded) {
hgs
parents:
diff changeset
   231
        mDocLoader->load(WlanSnifferListViewDocml, "embedded", &ok);
hgs
parents:
diff changeset
   232
    } else {
hgs
parents:
diff changeset
   233
        mDocLoader->load(WlanSnifferListViewDocml, "standalone", &ok);
hgs
parents:
diff changeset
   234
    }
hgs
parents:
diff changeset
   235
    Q_ASSERT(ok);
hgs
parents:
diff changeset
   236
    
hgs
parents:
diff changeset
   237
    // Load the view by name from the xml file
53
hgs
parents: 49
diff changeset
   238
    QGraphicsWidget *widget = mDocLoader->findWidget(WlanSnifferListViewName);
31
hgs
parents:
diff changeset
   239
    Q_ASSERT(widget);
hgs
parents:
diff changeset
   240
hgs
parents:
diff changeset
   241
    // Set view menu
hgs
parents:
diff changeset
   242
    HbMenu *viewMenu = qobject_cast<HbMenu *>(mDocLoader->findWidget("viewMenu"));
hgs
parents:
diff changeset
   243
    Q_ASSERT(viewMenu);
hgs
parents:
diff changeset
   244
    setMenu(viewMenu);
hgs
parents:
diff changeset
   245
hgs
parents:
diff changeset
   246
    // WLAN Sniffer list widget takes responsibility of the list widget behaviour
hgs
parents:
diff changeset
   247
    mWlanList = qobject_cast<HbListWidget *>(mDocLoader->findWidget("listWidget"));
hgs
parents:
diff changeset
   248
    Q_ASSERT(mWlanList);
hgs
parents:
diff changeset
   249
    mWlanListWidget = QSharedPointer<WlanSnifferListWidget>(new WlanSnifferListWidget(mWlanList));
hgs
parents:
diff changeset
   250
hgs
parents:
diff changeset
   251
    // Retrieve pointers to widgets we need to access from the code
hgs
parents:
diff changeset
   252
    mSwitchWlanAction = qobject_cast<HbAction *>(mDocLoader->findObject("switchWlanAction"));
hgs
parents:
diff changeset
   253
    Q_ASSERT(mSwitchWlanAction);
hgs
parents:
diff changeset
   254
hgs
parents:
diff changeset
   255
    mAddWlanAction = qobject_cast<HbAction *>(mDocLoader->findObject("addWlanAction"));
hgs
parents:
diff changeset
   256
    Q_ASSERT(mAddWlanAction);
hgs
parents:
diff changeset
   257
hgs
parents:
diff changeset
   258
    mWlanButton = qobject_cast<HbPushButton *>(mDocLoader->findWidget("wlanButton"));
hgs
parents:
diff changeset
   259
    Q_ASSERT(mWlanButton);
hgs
parents:
diff changeset
   260
    
hgs
parents:
diff changeset
   261
    mStatusLabel = qobject_cast<HbLabel *>(mDocLoader->findWidget("statusLabel"));
hgs
parents:
diff changeset
   262
    Q_ASSERT(mStatusLabel);
hgs
parents:
diff changeset
   263
    
hgs
parents:
diff changeset
   264
    OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_LOADDOCML_EXIT);
hgs
parents:
diff changeset
   265
}
hgs
parents:
diff changeset
   266
hgs
parents:
diff changeset
   267
/*!
hgs
parents:
diff changeset
   268
    Updates WLAN status label based on current WLAN status.
hgs
parents:
diff changeset
   269
    
hgs
parents:
diff changeset
   270
    @param [in] enabled True if WLAN is enabled.
hgs
parents:
diff changeset
   271
*/
hgs
parents:
diff changeset
   272
hgs
parents:
diff changeset
   273
void WlanSnifferListView::updateWlanStatusLabel(bool enabled)
hgs
parents:
diff changeset
   274
{
hgs
parents:
diff changeset
   275
    OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_UPDATEWLANSTATUSLABEL_ENTRY);
hgs
parents:
diff changeset
   276
    
hgs
parents:
diff changeset
   277
    QString status;
hgs
parents:
diff changeset
   278
    if (!enabled) {
hgs
parents:
diff changeset
   279
        // WLAN is OFF
hgs
parents:
diff changeset
   280
        status = hbTrId("txt_occ_grid_wlan_is_switched_off");
hgs
parents:
diff changeset
   281
    } else {
hgs
parents:
diff changeset
   282
        int iapId = mEngine->wlanQtUtils()->activeIap();
hgs
parents:
diff changeset
   283
        
hgs
parents:
diff changeset
   284
        switch (mEngine->wlanQtUtils()->connectionStatus()) {
hgs
parents:
diff changeset
   285
        case WlanQtUtils::ConnStatusConnecting:
hgs
parents:
diff changeset
   286
            // WLAN is connecting
hgs
parents:
diff changeset
   287
            Q_ASSERT(iapId != WlanQtUtils::IapIdNone);
49
hgs
parents: 39
diff changeset
   288
            status = HbParameterLengthLimiter(
hgs
parents: 39
diff changeset
   289
                "txt_occ_grid_connecting_to_1").arg(
hgs
parents: 39
diff changeset
   290
                    mEngine->wlanQtUtils()->iapName(iapId));
31
hgs
parents:
diff changeset
   291
            break;
hgs
parents:
diff changeset
   292
            
hgs
parents:
diff changeset
   293
        case WlanQtUtils::ConnStatusConnected:
hgs
parents:
diff changeset
   294
            // WLAN is connected
hgs
parents:
diff changeset
   295
            Q_ASSERT(iapId != WlanQtUtils::IapIdNone);
49
hgs
parents: 39
diff changeset
   296
            status = HbParameterLengthLimiter(
hgs
parents: 39
diff changeset
   297
                "txt_occ_grid_connected_to_1").arg(
hgs
parents: 39
diff changeset
   298
                    mEngine->wlanQtUtils()->iapName(iapId));
31
hgs
parents:
diff changeset
   299
            break;
hgs
parents:
diff changeset
   300
            
hgs
parents:
diff changeset
   301
        default:
hgs
parents:
diff changeset
   302
            // WLAN is disconnected
hgs
parents:
diff changeset
   303
            status = hbTrId("txt_occ_grid_not_connected");        
hgs
parents:
diff changeset
   304
            break;
hgs
parents:
diff changeset
   305
        }
hgs
parents:
diff changeset
   306
    }
hgs
parents:
diff changeset
   307
    mStatusLabel->setPlainText(status);
hgs
parents:
diff changeset
   308
hgs
parents:
diff changeset
   309
    OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_UPDATEWLANSTATUSLABEL_EXIT);
hgs
parents:
diff changeset
   310
}
hgs
parents:
diff changeset
   311
hgs
parents:
diff changeset
   312
/*!
hgs
parents:
diff changeset
   313
    Handles a "Connect" action for the selected IAP or AP item.
hgs
parents:
diff changeset
   314
    
hgs
parents:
diff changeset
   315
    @param data IAP ID (int), or AP class (WlanQtUtilsAp) to connect.
hgs
parents:
diff changeset
   316
*/
hgs
parents:
diff changeset
   317
hgs
parents:
diff changeset
   318
void WlanSnifferListView::handleConnect(QVariant data)
hgs
parents:
diff changeset
   319
{
hgs
parents:
diff changeset
   320
    OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_HANDLECONNECT_ENTRY);
hgs
parents:
diff changeset
   321
hgs
parents:
diff changeset
   322
    // Check whether we need to disconnect a previous connection first
hgs
parents:
diff changeset
   323
    int activeWlanId = mEngine->wlanQtUtils()->activeIap();
hgs
parents:
diff changeset
   324
    
hgs
parents:
diff changeset
   325
    // Get IAP ID if IAP is available
hgs
parents:
diff changeset
   326
    int iapId = WlanQtUtils::IapIdNone;
hgs
parents:
diff changeset
   327
    if (data.canConvert<int>()) {
hgs
parents:
diff changeset
   328
        iapId = data.toInt();
hgs
parents:
diff changeset
   329
    }
hgs
parents:
diff changeset
   330
    OstTraceExt2(
hgs
parents:
diff changeset
   331
        TRACE_NORMAL,
hgs
parents:
diff changeset
   332
        WLANSNIFFERLISTVIEW_HANDLECONNECT,
hgs
parents:
diff changeset
   333
        "WlanSnifferListView::handleConnect;activeWlanId=%d;iapId=%d",
hgs
parents:
diff changeset
   334
        activeWlanId,
hgs
parents:
diff changeset
   335
        iapId);
hgs
parents:
diff changeset
   336
    
hgs
parents:
diff changeset
   337
    // Skip connecting if the IAP is already connected
hgs
parents:
diff changeset
   338
    if (activeWlanId != WlanQtUtils::IapIdNone && iapId == activeWlanId) {
hgs
parents:
diff changeset
   339
        return;
hgs
parents:
diff changeset
   340
    }
hgs
parents:
diff changeset
   341
    
hgs
parents:
diff changeset
   342
    if (activeWlanId != WlanQtUtils::IapIdNone) {
hgs
parents:
diff changeset
   343
        mEngine->wlanQtUtils()->disconnectIap(activeWlanId);
hgs
parents:
diff changeset
   344
        
hgs
parents:
diff changeset
   345
        // Update list widget so that the IAP is no longer connected
hgs
parents:
diff changeset
   346
        updateListContent();
hgs
parents:
diff changeset
   347
    }
hgs
parents:
diff changeset
   348
    
hgs
parents:
diff changeset
   349
    if (iapId != WlanQtUtils::IapIdNone) {
hgs
parents:
diff changeset
   350
        // Item was an IAP, connect it.
hgs
parents:
diff changeset
   351
        mConnectingIapId = iapId;
hgs
parents:
diff changeset
   352
        mStatusLabel->setPlainText(
49
hgs
parents: 39
diff changeset
   353
            HbParameterLengthLimiter(
hgs
parents: 39
diff changeset
   354
                "txt_occ_grid_connecting_to_1").arg(
hgs
parents: 39
diff changeset
   355
                    mEngine->wlanQtUtils()->iapName(iapId)));
31
hgs
parents:
diff changeset
   356
        mEngine->wlanQtUtils()->connectIap(iapId);
hgs
parents:
diff changeset
   357
    } else {
hgs
parents:
diff changeset
   358
        // Item is a WLAN AP. Summon the Wlan Wizard to handle creation
hgs
parents:
diff changeset
   359
        // of the IAP and connecting it.
hgs
parents:
diff changeset
   360
        Q_ASSERT(data.canConvert<WlanQtUtilsAp>());
hgs
parents:
diff changeset
   361
        WlanQtUtilsAp ap = data.value<WlanQtUtilsAp>();
hgs
parents:
diff changeset
   362
        emit wizardTriggered(&ap);
hgs
parents:
diff changeset
   363
    }
hgs
parents:
diff changeset
   364
hgs
parents:
diff changeset
   365
    OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_HANDLECONNECT_EXIT);
hgs
parents:
diff changeset
   366
}
hgs
parents:
diff changeset
   367
hgs
parents:
diff changeset
   368
/*!
hgs
parents:
diff changeset
   369
    Updates WLAN list widget with new WLAN scan results. 
hgs
parents:
diff changeset
   370
*/
hgs
parents:
diff changeset
   371
hgs
parents:
diff changeset
   372
void WlanSnifferListView::updateListContent()
hgs
parents:
diff changeset
   373
{
hgs
parents:
diff changeset
   374
    OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_UPDATELISTCONTENT_ENTRY);
hgs
parents:
diff changeset
   375
hgs
parents:
diff changeset
   376
    if (!mIgnoreWlanScanResults) {
hgs
parents:
diff changeset
   377
        // Get the latest scan results
hgs
parents:
diff changeset
   378
        QList< QSharedPointer<WlanQtUtilsIap> > iaps;
hgs
parents:
diff changeset
   379
        QList< QSharedPointer<WlanQtUtilsAp> > aps;
hgs
parents:
diff changeset
   380
        mEngine->wlanQtUtils()->availableWlans(iaps, aps);
hgs
parents:
diff changeset
   381
    
hgs
parents:
diff changeset
   382
        // Check for connected IAP
hgs
parents:
diff changeset
   383
        int iapId = WlanQtUtils::IapIdNone;
hgs
parents:
diff changeset
   384
        if (mEngine->wlanQtUtils()->connectionStatus() ==
hgs
parents:
diff changeset
   385
            WlanQtUtils::ConnStatusConnected) {
hgs
parents:
diff changeset
   386
            iapId = mEngine->wlanQtUtils()->activeIap();
hgs
parents:
diff changeset
   387
        }
hgs
parents:
diff changeset
   388
    
hgs
parents:
diff changeset
   389
        // Let the list widget class update the list content
hgs
parents:
diff changeset
   390
        mWlanListWidget->updateContent(iaps, aps, iapId);
hgs
parents:
diff changeset
   391
    }
hgs
parents:
diff changeset
   392
hgs
parents:
diff changeset
   393
    OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_UPDATELISTCONTENT_EXIT);
hgs
parents:
diff changeset
   394
}
hgs
parents:
diff changeset
   395
hgs
parents:
diff changeset
   396
/*!
hgs
parents:
diff changeset
   397
    WLAN state settings change handler. This slot handles both the
hgs
parents:
diff changeset
   398
    WLAN ON/OFF setting and WLAN forced OFF setting.
hgs
parents:
diff changeset
   399
    Updates all WLAN ON/OFF related (UI) elements.
hgs
parents:
diff changeset
   400
*/
hgs
parents:
diff changeset
   401
hgs
parents:
diff changeset
   402
void WlanSnifferListView::updateWlanEnabled()
hgs
parents:
diff changeset
   403
{
hgs
parents:
diff changeset
   404
    OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_UPDATEWLANENABLED_ENTRY);
hgs
parents:
diff changeset
   405
    
hgs
parents:
diff changeset
   406
    // Check the updated setting status
hgs
parents:
diff changeset
   407
    bool forcedOff = mEngine->forceDisableWlan();
hgs
parents:
diff changeset
   408
    bool enabled = mEngine->masterWlan() && !forcedOff;
hgs
parents:
diff changeset
   409
    
hgs
parents:
diff changeset
   410
    // Update the WLAN status label
hgs
parents:
diff changeset
   411
    updateWlanStatusLabel(enabled);
hgs
parents:
diff changeset
   412
hgs
parents:
diff changeset
   413
    // Set the WLAN ON/OFF button state
hgs
parents:
diff changeset
   414
    mWlanButton->setChecked(enabled);
hgs
parents:
diff changeset
   415
hgs
parents:
diff changeset
   416
    // Select the right WLAN button icon and menu action text
hgs
parents:
diff changeset
   417
    if (enabled) {
hgs
parents:
diff changeset
   418
        mWlanButton->setIcon(HbIcon("qtg_mono_wlan"));
hgs
parents:
diff changeset
   419
        mSwitchWlanAction->setText(hbTrId("txt_occ_opt_switch_wlan_off"));
hgs
parents:
diff changeset
   420
    } else {
hgs
parents:
diff changeset
   421
        mWlanButton->setIcon(HbIcon("qtg_mono_wlan_offline"));
hgs
parents:
diff changeset
   422
        mSwitchWlanAction->setText(hbTrId("txt_occ_opt_switch_wlan_on"));
hgs
parents:
diff changeset
   423
    }
hgs
parents:
diff changeset
   424
hgs
parents:
diff changeset
   425
    // Set triggable WLAN UI elements disabled if WLAN is forced OFF
hgs
parents:
diff changeset
   426
    mWlanButton->setEnabled(!forcedOff);
hgs
parents:
diff changeset
   427
    mSwitchWlanAction->setEnabled(!forcedOff);
hgs
parents:
diff changeset
   428
hgs
parents:
diff changeset
   429
    // Disable manual WLAN IAP creation when WLAN is switched OFF
hgs
parents:
diff changeset
   430
    mAddWlanAction->setEnabled(enabled);
hgs
parents:
diff changeset
   431
hgs
parents:
diff changeset
   432
    // Switch WLAN scanning ON/OFF
hgs
parents:
diff changeset
   433
    if (enabled) {
hgs
parents:
diff changeset
   434
        mEngine->startWlanScanning();
hgs
parents:
diff changeset
   435
    } else {
hgs
parents:
diff changeset
   436
        mEngine->stopWlanScanning();
hgs
parents:
diff changeset
   437
        // Clear the network list when going to offline
hgs
parents:
diff changeset
   438
        mWlanList->clear();
hgs
parents:
diff changeset
   439
    }
hgs
parents:
diff changeset
   440
hgs
parents:
diff changeset
   441
    OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_UPDATEWLANENABLED_EXIT);
hgs
parents:
diff changeset
   442
}
hgs
parents:
diff changeset
   443
hgs
parents:
diff changeset
   444
/*!
hgs
parents:
diff changeset
   445
    Connection opened slot. Updates connection status.
hgs
parents:
diff changeset
   446
    
hgs
parents:
diff changeset
   447
    @param [in] iapId IAP ID of the connected WLAN IAP. 
hgs
parents:
diff changeset
   448
*/
hgs
parents:
diff changeset
   449
hgs
parents:
diff changeset
   450
void WlanSnifferListView::updateConnectionOpened(int iapId)
hgs
parents:
diff changeset
   451
{
hgs
parents:
diff changeset
   452
    OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_UPDATECONNECTIONOPENED_ENTRY);
hgs
parents:
diff changeset
   453
    
hgs
parents:
diff changeset
   454
    mConnectingIapId = WlanQtUtils::IapIdNone;
hgs
parents:
diff changeset
   455
    mStatusLabel->setPlainText(
49
hgs
parents: 39
diff changeset
   456
        HbParameterLengthLimiter(
hgs
parents: 39
diff changeset
   457
            "txt_occ_grid_connected_to_1").arg(
hgs
parents: 39
diff changeset
   458
                mEngine->wlanQtUtils()->iapName(iapId)));
31
hgs
parents:
diff changeset
   459
    
hgs
parents:
diff changeset
   460
    // Update the list widget content
hgs
parents:
diff changeset
   461
    updateListContent();
hgs
parents:
diff changeset
   462
hgs
parents:
diff changeset
   463
    // Scroll to the top of the list
hgs
parents:
diff changeset
   464
    mWlanListWidget->scrollTo(0);
hgs
parents:
diff changeset
   465
    
hgs
parents:
diff changeset
   466
    OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_UPDATECONNECTIONOPENED_EXIT);
hgs
parents:
diff changeset
   467
}
hgs
parents:
diff changeset
   468
hgs
parents:
diff changeset
   469
/*!
hgs
parents:
diff changeset
   470
    Connection closing handler. Updates connection status.
hgs
parents:
diff changeset
   471
    
hgs
parents:
diff changeset
   472
    @param [in] iapId Disconnected IAP ID. 
hgs
parents:
diff changeset
   473
*/
hgs
parents:
diff changeset
   474
hgs
parents:
diff changeset
   475
void WlanSnifferListView::updateConnectionClosed(int iapId)
hgs
parents:
diff changeset
   476
{
hgs
parents:
diff changeset
   477
    OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_UPDATECONNECTIONCLOSED_ENTRY);
hgs
parents:
diff changeset
   478
    
hgs
parents:
diff changeset
   479
    if (mEngine->masterWlan() && !mEngine->forceDisableWlan()) {
hgs
parents:
diff changeset
   480
        // Check whether we can update the status text to "Not connected"
hgs
parents:
diff changeset
   481
        if (mConnectingIapId == WlanQtUtils::IapIdNone ||
hgs
parents:
diff changeset
   482
            mConnectingIapId == iapId) {
hgs
parents:
diff changeset
   483
            mStatusLabel->setPlainText(hbTrId("txt_occ_grid_not_connected"));
hgs
parents:
diff changeset
   484
        }
hgs
parents:
diff changeset
   485
        // else: we are already connecting to another network so don't touch
hgs
parents:
diff changeset
   486
        // the status label
hgs
parents:
diff changeset
   487
        
hgs
parents:
diff changeset
   488
        // Update the list widget content
hgs
parents:
diff changeset
   489
        updateListContent();
hgs
parents:
diff changeset
   490
    }
hgs
parents:
diff changeset
   491
hgs
parents:
diff changeset
   492
    if (mConnectingIapId == iapId) {
hgs
parents:
diff changeset
   493
        // Not connecting to this network anymore
hgs
parents:
diff changeset
   494
        mConnectingIapId = WlanQtUtils::IapIdNone;
hgs
parents:
diff changeset
   495
    }
hgs
parents:
diff changeset
   496
hgs
parents:
diff changeset
   497
    OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_UPDATECONNECTIONCLOSED_EXIT);
hgs
parents:
diff changeset
   498
}
hgs
parents:
diff changeset
   499
hgs
parents:
diff changeset
   500
/*!
hgs
parents:
diff changeset
   501
    Context menu closing handler.
hgs
parents:
diff changeset
   502
*/
hgs
parents:
diff changeset
   503
hgs
parents:
diff changeset
   504
void WlanSnifferListView::handleContextMenuClosed()
hgs
parents:
diff changeset
   505
{
hgs
parents:
diff changeset
   506
    OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_HANDLECONTEXTMENUCLOSED_ENTRY);
hgs
parents:
diff changeset
   507
hgs
parents:
diff changeset
   508
    // Let list updating start again
hgs
parents:
diff changeset
   509
    mIgnoreWlanScanResults = false;
hgs
parents:
diff changeset
   510
    
hgs
parents:
diff changeset
   511
    OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_HANDLECONTEXTMENUCLOSED_EXIT);
hgs
parents:
diff changeset
   512
}
hgs
parents:
diff changeset
   513
hgs
parents:
diff changeset
   514
/*!
hgs
parents:
diff changeset
   515
    List item activation handler. Connects the WLAN network, and if there
hgs
parents:
diff changeset
   516
    is no IAP yet for it, starts WLAN Wizard.
hgs
parents:
diff changeset
   517
    
hgs
parents:
diff changeset
   518
    @param [in] item Selected WLAN network list item. 
hgs
parents:
diff changeset
   519
*/
hgs
parents:
diff changeset
   520
hgs
parents:
diff changeset
   521
void WlanSnifferListView::handleListItemActivated(HbListWidgetItem *item)
hgs
parents:
diff changeset
   522
{
hgs
parents:
diff changeset
   523
    OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_HANDLELISTITEMACTIVATED_ENTRY);
hgs
parents:
diff changeset
   524
    
hgs
parents:
diff changeset
   525
    handleConnect(item->data());
hgs
parents:
diff changeset
   526
hgs
parents:
diff changeset
   527
    OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_HANDLELISTITEMACTIVATED_EXIT);
hgs
parents:
diff changeset
   528
}
hgs
parents:
diff changeset
   529
hgs
parents:
diff changeset
   530
/*!
hgs
parents:
diff changeset
   531
    WLAN List item long press handler.
hgs
parents:
diff changeset
   532
    The long press of a list item (i.e. WLAN IAP) opens a context menu that
hgs
parents:
diff changeset
   533
    is populated depending on the state of the WLAN network in case.
hgs
parents:
diff changeset
   534
    
hgs
parents:
diff changeset
   535
    @param [in] item Selected list item.
hgs
parents:
diff changeset
   536
    @param [in] coords Coordinates of the long press.
hgs
parents:
diff changeset
   537
*/
hgs
parents:
diff changeset
   538
hgs
parents:
diff changeset
   539
void WlanSnifferListView::handleListItemLongPressed(
hgs
parents:
diff changeset
   540
    HbListWidgetItem *item,
hgs
parents:
diff changeset
   541
    const QPointF &coords)
hgs
parents:
diff changeset
   542
{
hgs
parents:
diff changeset
   543
    OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_HANDLELISTITEMLONGPRESSED_ENTRY);
hgs
parents:
diff changeset
   544
hgs
parents:
diff changeset
   545
    mContextMenu = QSharedPointer<HbMenu>(new HbMenu());
hgs
parents:
diff changeset
   546
hgs
parents:
diff changeset
   547
    int activeIap = mEngine->wlanQtUtils()->activeIap();
hgs
parents:
diff changeset
   548
    
hgs
parents:
diff changeset
   549
    // Remember the item that was long pressed
hgs
parents:
diff changeset
   550
    mContextMenuData = item->data();
hgs
parents:
diff changeset
   551
    if (mContextMenuData.canConvert<int>()
hgs
parents:
diff changeset
   552
        && mContextMenuData.toInt() == activeIap) {
hgs
parents:
diff changeset
   553
        // Connected IAP, add "Disconnect" action
hgs
parents:
diff changeset
   554
        mContextMenu->addAction(
hgs
parents:
diff changeset
   555
            hbTrId("txt_common_menu_disconnect"),
hgs
parents:
diff changeset
   556
            this,
hgs
parents:
diff changeset
   557
            SLOT(handleListItemDisconnect()));
hgs
parents:
diff changeset
   558
    } else {
hgs
parents:
diff changeset
   559
        // Not connected IAP or AP, add "Connect" action
hgs
parents:
diff changeset
   560
        mContextMenu->addAction(
hgs
parents:
diff changeset
   561
            hbTrId("txt_common_menu_connect"),
hgs
parents:
diff changeset
   562
            this,
hgs
parents:
diff changeset
   563
            SLOT(handleListItemConnect()));
hgs
parents:
diff changeset
   564
    }
hgs
parents:
diff changeset
   565
    
hgs
parents:
diff changeset
   566
    // Show the menu and connect closure signal (to re-enable list refreshing)
hgs
parents:
diff changeset
   567
    bool connectStatus = connect(
hgs
parents:
diff changeset
   568
        mContextMenu.data(),
hgs
parents:
diff changeset
   569
        SIGNAL(aboutToClose()),
hgs
parents:
diff changeset
   570
        this,
hgs
parents:
diff changeset
   571
        SLOT(handleContextMenuClosed()));
hgs
parents:
diff changeset
   572
    Q_ASSERT(connectStatus);
hgs
parents:
diff changeset
   573
    mContextMenu->setTimeout(HbPopup::ContextMenuTimeout);
hgs
parents:
diff changeset
   574
    mContextMenu->setPreferredPos(coords);
hgs
parents:
diff changeset
   575
    mContextMenu->show();
hgs
parents:
diff changeset
   576
    
hgs
parents:
diff changeset
   577
    // Skip WLAN scan result updates during context menu handling
hgs
parents:
diff changeset
   578
    mIgnoreWlanScanResults = true;
hgs
parents:
diff changeset
   579
    
hgs
parents:
diff changeset
   580
    OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_HANDLELISTITEMLONGPRESSED_EXIT);
hgs
parents:
diff changeset
   581
}
hgs
parents:
diff changeset
   582
hgs
parents:
diff changeset
   583
/*!
hgs
parents:
diff changeset
   584
    Handles the "Connect" action selected from the context menu for a list item.
hgs
parents:
diff changeset
   585
*/
hgs
parents:
diff changeset
   586
hgs
parents:
diff changeset
   587
void WlanSnifferListView::handleListItemConnect()
hgs
parents:
diff changeset
   588
{
hgs
parents:
diff changeset
   589
    OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_HANDLELISTITEMCONNECT_ENTRY);
hgs
parents:
diff changeset
   590
hgs
parents:
diff changeset
   591
    handleConnect(mContextMenuData);
hgs
parents:
diff changeset
   592
    
hgs
parents:
diff changeset
   593
    OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_HANDLELISTITEMCONNECT_EXIT);
hgs
parents:
diff changeset
   594
}
hgs
parents:
diff changeset
   595
hgs
parents:
diff changeset
   596
/*!
hgs
parents:
diff changeset
   597
    Handles the "Disconnect" action selected from the context menu for a list item.
hgs
parents:
diff changeset
   598
*/
hgs
parents:
diff changeset
   599
hgs
parents:
diff changeset
   600
void WlanSnifferListView::handleListItemDisconnect()
hgs
parents:
diff changeset
   601
{
hgs
parents:
diff changeset
   602
    OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_HANDLELISTITEMDISCONNECT_ENTRY);
hgs
parents:
diff changeset
   603
hgs
parents:
diff changeset
   604
    // "Disconnect" was only added, if the item was an IAP and data was
hgs
parents:
diff changeset
   605
    // the IAP ID.
hgs
parents:
diff changeset
   606
    Q_ASSERT(mContextMenuData.canConvert<int>());
hgs
parents:
diff changeset
   607
    mEngine->wlanQtUtils()->disconnectIap(mContextMenuData.toInt());
hgs
parents:
diff changeset
   608
    
hgs
parents:
diff changeset
   609
    OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_HANDLELISTITEMDISCONNECT_EXIT);
hgs
parents:
diff changeset
   610
}
hgs
parents:
diff changeset
   611
hgs
parents:
diff changeset
   612
/*!
hgs
parents:
diff changeset
   613
    Function for handling WLAN ON/OFF switch initiation.
hgs
parents:
diff changeset
   614
*/
hgs
parents:
diff changeset
   615
hgs
parents:
diff changeset
   616
void WlanSnifferListView::handleWlanToggled()
hgs
parents:
diff changeset
   617
{
hgs
parents:
diff changeset
   618
    OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_HANDLEWLANTOGGLED_ENTRY);
hgs
parents:
diff changeset
   619
    
hgs
parents:
diff changeset
   620
    // Toggle the new WLAN ON/OFF value
hgs
parents:
diff changeset
   621
    bool wlanOn = mEngine->masterWlan(); 
hgs
parents:
diff changeset
   622
    OstTraceExt1(
hgs
parents:
diff changeset
   623
        TRACE_NORMAL,
hgs
parents:
diff changeset
   624
        WLANSNIFFERLISTVIEW_HANDLEWLANTOGGLED,
hgs
parents:
diff changeset
   625
        "WlanSnifferListView::handleWlanToggled;wlan=%hhu",
hgs
parents:
diff changeset
   626
        wlanOn);
hgs
parents:
diff changeset
   627
    
hgs
parents:
diff changeset
   628
    // We have to check whether the offline mode is ON. If it is, then the
hgs
parents:
diff changeset
   629
    // user needs to be queried whether WLAN will be used in offline mode.
hgs
parents:
diff changeset
   630
    if (!wlanOn && mEngine->offlineMode()) {
hgs
parents:
diff changeset
   631
        // Show the dialog and wait for user input.
hgs
parents:
diff changeset
   632
        mWlanEnableDialog = QSharedPointer<HbMessageBox>(
hgs
parents:
diff changeset
   633
            new HbMessageBox(HbMessageBox::MessageTypeQuestion)); 
hgs
parents:
diff changeset
   634
        mWlanEnableDialog->setTimeout(HbPopup::StandardTimeout);
hgs
parents:
diff changeset
   635
        mWlanEnableDialog->setText(hbTrId("txt_occ_info_activate_wlan_in_airplane_mode"));
hgs
parents:
diff changeset
   636
        // Open the dialog and connect the result to the handleWlanEnableDialogClosed slot
hgs
parents:
diff changeset
   637
        mWlanEnableDialog->open(this, SLOT(handleWlanEnableDialogClosed(HbAction*)));
hgs
parents:
diff changeset
   638
    } else {
hgs
parents:
diff changeset
   639
        // Stop WLAN scanning immediately when switching WLAN OFF.
hgs
parents:
diff changeset
   640
        // WLAN might have sent scan results just before disabling WLAN.
hgs
parents:
diff changeset
   641
        if (wlanOn) {
hgs
parents:
diff changeset
   642
            mEngine->stopWlanScanning();
hgs
parents:
diff changeset
   643
        }
hgs
parents:
diff changeset
   644
        mEngine->setMasterWlan(!wlanOn);
hgs
parents:
diff changeset
   645
    }
hgs
parents:
diff changeset
   646
hgs
parents:
diff changeset
   647
    OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_HANDLEWLANTOGGLED_EXIT);
hgs
parents:
diff changeset
   648
}
hgs
parents:
diff changeset
   649
hgs
parents:
diff changeset
   650
/*!
39
hgs
parents: 31
diff changeset
   651
    Function for handling WLAN Wizard starting when adding WLAN manually.
hgs
parents: 31
diff changeset
   652
*/
hgs
parents: 31
diff changeset
   653
hgs
parents: 31
diff changeset
   654
void WlanSnifferListView::startWlanWizard()
hgs
parents: 31
diff changeset
   655
{
hgs
parents: 31
diff changeset
   656
    OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_STARTWLANWIZARD_ENTRY);
hgs
parents: 31
diff changeset
   657
hgs
parents: 31
diff changeset
   658
    // TODO: Stop connections & do other cleanup before wizard can start? 
hgs
parents: 31
diff changeset
   659
hgs
parents: 31
diff changeset
   660
    emit wizardTriggered(NULL);
hgs
parents: 31
diff changeset
   661
hgs
parents: 31
diff changeset
   662
    OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_STARTWLANWIZARD_EXIT);
hgs
parents: 31
diff changeset
   663
}
hgs
parents: 31
diff changeset
   664
hgs
parents: 31
diff changeset
   665
/*!
31
hgs
parents:
diff changeset
   666
    Function to handle the input received when the wlan enabling 
hgs
parents:
diff changeset
   667
    query is closed.
hgs
parents:
diff changeset
   668
    
hgs
parents:
diff changeset
   669
    @param [in] action The user action received from the dialog.
hgs
parents:
diff changeset
   670
*/
hgs
parents:
diff changeset
   671
hgs
parents:
diff changeset
   672
void WlanSnifferListView::handleWlanEnableDialogClosed(HbAction *action)
hgs
parents:
diff changeset
   673
{
hgs
parents:
diff changeset
   674
    OstTraceFunctionEntry0(WLANSNIFFERLISTVIEW_HANDLEWLANENABLEDIALOGCLOSED_ENTRY);
hgs
parents:
diff changeset
   675
    
hgs
parents:
diff changeset
   676
    // The dialog must exist
hgs
parents:
diff changeset
   677
    Q_ASSERT(mWlanEnableDialog);
hgs
parents:
diff changeset
   678
    
hgs
parents:
diff changeset
   679
    // If the user selected yes, then the wlan value is toggled,
hgs
parents:
diff changeset
   680
    // otherwise nothing needs to be done.
hgs
parents:
diff changeset
   681
    // TODO: Update actions().at(0) when a better solution is provided by orbit
hgs
parents:
diff changeset
   682
    if (action == mWlanEnableDialog->actions().at(0)) {
hgs
parents:
diff changeset
   683
        mEngine->setMasterWlan(true); 
hgs
parents:
diff changeset
   684
    }
hgs
parents:
diff changeset
   685
hgs
parents:
diff changeset
   686
    OstTraceFunctionExit0(WLANSNIFFERLISTVIEW_HANDLEWLANENABLEDIALOGCLOSED_EXIT);
hgs
parents:
diff changeset
   687
}