31
|
1 |
/*
|
|
2 |
* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
* WLAN Sniffer main window.
|
|
16 |
*/
|
|
17 |
|
|
18 |
// System includes
|
|
19 |
|
|
20 |
// User includes
|
|
21 |
|
|
22 |
#include "wlanqtutils.h"
|
|
23 |
#include "wlanqtutilsap.h"
|
|
24 |
|
|
25 |
#include "wlanwizard.h"
|
|
26 |
|
|
27 |
#include "wlansnifferengine.h"
|
|
28 |
#include "wlansnifferlistview.h"
|
|
29 |
#include "wlansniffermainwindow.h"
|
|
30 |
|
|
31 |
#include "OstTraceDefinitions.h"
|
|
32 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
33 |
#include "wlansniffermainwindowTraces.h"
|
|
34 |
#endif
|
|
35 |
|
|
36 |
/*!
|
|
37 |
\class WlanSnifferMainWindow
|
|
38 |
\brief WLAN Sniffer main window.
|
|
39 |
*/
|
|
40 |
|
|
41 |
// External function prototypes
|
|
42 |
|
|
43 |
// Local constants
|
|
44 |
|
|
45 |
// ======== LOCAL FUNCTIONS ========
|
|
46 |
|
|
47 |
// ======== MEMBER FUNCTIONS ========
|
|
48 |
|
|
49 |
/*!
|
|
50 |
Constructor.
|
|
51 |
|
|
52 |
@param [in] engine WLAN Sniffer application engine.
|
|
53 |
*/
|
|
54 |
|
|
55 |
WlanSnifferMainWindow::WlanSnifferMainWindow(WlanSnifferEngine *engine) :
|
|
56 |
mWizard(0),
|
|
57 |
mListView(0),
|
|
58 |
mEngine(engine)
|
|
59 |
{
|
|
60 |
OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_WLANSNIFFERMAINWINDOW_ENTRY);
|
|
61 |
|
|
62 |
// Add the list view to the main window
|
|
63 |
addListView();
|
|
64 |
bool connectStatus = connect(
|
|
65 |
mEngine,
|
|
66 |
SIGNAL(toListView(QString)),
|
|
67 |
this,
|
|
68 |
SLOT(toListView(QString)));
|
|
69 |
Q_ASSERT(connectStatus == true);
|
|
70 |
|
|
71 |
// When using WLAN Sniffer service, the view show is called after the service
|
|
72 |
// request arrives.
|
|
73 |
if (!mEngine->isEmbedded()) {
|
|
74 |
// Show the list view
|
|
75 |
toListView(hbTrId("txt_occ_title_wireless_lan"));
|
|
76 |
}
|
|
77 |
|
|
78 |
OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_WLANSNIFFERMAINWINDOW_EXIT);
|
|
79 |
}
|
|
80 |
|
|
81 |
/*!
|
|
82 |
Destructor.
|
|
83 |
*/
|
|
84 |
|
|
85 |
WlanSnifferMainWindow::~WlanSnifferMainWindow()
|
|
86 |
{
|
|
87 |
OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_WLANSNIFFERMAINWINDOWDESTR_ENTRY);
|
|
88 |
OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_WLANSNIFFERMAINWINDOWDESTR_EXIT);
|
|
89 |
}
|
|
90 |
|
|
91 |
/*!
|
|
92 |
Shows the WLAN Sniffer list view.
|
|
93 |
|
|
94 |
@param [in] title View title.
|
|
95 |
*/
|
|
96 |
|
|
97 |
void WlanSnifferMainWindow::toListView(const QString &title)
|
|
98 |
{
|
|
99 |
OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_TOLISTVIEW_ENTRY);
|
|
100 |
|
|
101 |
// Show the list view
|
|
102 |
mListView->setTitle(title);
|
|
103 |
setCurrentView(mListView);
|
|
104 |
show();
|
|
105 |
|
|
106 |
OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_TOLISTVIEW_EXIT);
|
|
107 |
}
|
|
108 |
|
|
109 |
/*!
|
|
110 |
Creates and adds the WLAN List View to main window.
|
|
111 |
*/
|
|
112 |
|
|
113 |
void WlanSnifferMainWindow::addListView()
|
|
114 |
{
|
|
115 |
OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_ADDLISTVIEW_ENTRY);
|
|
116 |
|
|
117 |
mListView = new WlanSnifferListView(mEngine, this);
|
|
118 |
addView(mListView);
|
|
119 |
|
|
120 |
bool connectStatus = connect(
|
|
121 |
mListView,
|
|
122 |
SIGNAL(wizardTriggered(const WlanQtUtilsAp *)),
|
|
123 |
this,
|
|
124 |
SLOT(startWlanWizard(const WlanQtUtilsAp *)));
|
|
125 |
|
|
126 |
OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_ADDLISTVIEW_EXIT);
|
|
127 |
}
|
|
128 |
|
|
129 |
/*!
|
|
130 |
Starts WLAN Wizard for new WLAN IAP creation.
|
|
131 |
|
39
|
132 |
@param [in] ap WLAN Access Point to create, or NULL for adding WLAN manually.
|
31
|
133 |
*/
|
|
134 |
|
|
135 |
void WlanSnifferMainWindow::startWlanWizard(const WlanQtUtilsAp *ap)
|
|
136 |
{
|
|
137 |
OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_STARTWLANWIZARD_ENTRY);
|
|
138 |
|
61
|
139 |
if (mWizard == NULL) {
|
|
140 |
// Stop WLAN scanning for the duration of WLAN Wizard
|
|
141 |
mEngine->stopWlanScanning();
|
|
142 |
|
|
143 |
mWizard = QSharedPointer<WlanWizard>(new WlanWizard(this));
|
|
144 |
bool connectStatus = connect(
|
|
145 |
mWizard.data(),
|
|
146 |
SIGNAL(finished(int,bool)),
|
|
147 |
this,
|
|
148 |
SLOT(handleWlanWizardComplete(int,bool)),
|
|
149 |
Qt::QueuedConnection);
|
|
150 |
Q_ASSERT(connectStatus == true);
|
|
151 |
|
|
152 |
connectStatus = connect(
|
|
153 |
mWizard.data(),
|
|
154 |
SIGNAL(cancelled()),
|
|
155 |
this,
|
|
156 |
SLOT(handleWlanWizardCancelled()),
|
|
157 |
Qt::QueuedConnection);
|
|
158 |
Q_ASSERT(connectStatus == true);
|
|
159 |
|
|
160 |
// Create an IAP for a specific AP
|
|
161 |
if (ap) {
|
|
162 |
mWizard->setParameters(
|
|
163 |
ap->value(WlanQtUtilsAp::ConfIdName).toString(),
|
|
164 |
ap->value(WlanQtUtilsAp::ConfIdSsid).toByteArray(),
|
|
165 |
ap->value(WlanQtUtilsAp::ConfIdConnectionMode).toInt(),
|
|
166 |
ap->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(),
|
|
167 |
ap->value(WlanQtUtilsAp::ConfIdWpaPskUse).toInt(),
|
|
168 |
ap->value(WlanQtUtilsAp::ConfIdWpsSupported).toBool());
|
|
169 |
}
|
|
170 |
// else: Add WLAN IAP manually
|
|
171 |
|
|
172 |
mWizard->show();
|
|
173 |
}
|
|
174 |
// else: already running Wizard, ignore this call
|
31
|
175 |
|
|
176 |
OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_STARTWLANWIZARD_EXIT);
|
|
177 |
}
|
|
178 |
|
|
179 |
/*!
|
|
180 |
WLAN Wizard successful completion handler.
|
|
181 |
|
|
182 |
@param [in] iapId IAP ID of the new WLAN IAP.
|
|
183 |
@param [in] connected TRUE if connected.
|
|
184 |
*/
|
|
185 |
|
|
186 |
void WlanSnifferMainWindow::handleWlanWizardComplete(
|
|
187 |
int iapId,
|
|
188 |
bool connected)
|
|
189 |
{
|
|
190 |
OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_HANDLEWLANWIZARDCOMPLETE_ENTRY);
|
|
191 |
|
|
192 |
// The wizard must exist
|
|
193 |
Q_ASSERT(mWizard);
|
|
194 |
|
39
|
195 |
// Enable scanning again
|
|
196 |
mEngine->startWlanScanning();
|
|
197 |
|
|
198 |
if (connected) {
|
|
199 |
// The IAP ID must be valid
|
|
200 |
Q_ASSERT(iapId != WlanQtUtils::IapIdNone);
|
|
201 |
|
|
202 |
// Connect (share) the new IAP in order to keep the connection open when
|
|
203 |
// deleting Wizard.
|
|
204 |
mEngine->wlanQtUtils()->connectIap(iapId, false);
|
|
205 |
}
|
|
206 |
// else: created IAP not connected at all, or already dropped
|
|
207 |
// (probably due to being out of coverage) so don't try to share it
|
|
208 |
|
|
209 |
// Delete the Wizard instance. This is OK since the connect is Qt::QueuedConnection.
|
|
210 |
mWizard.clear();
|
31
|
211 |
|
|
212 |
OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_HANDLEWLANWIZARDCOMPLETE_EXIT);
|
|
213 |
}
|
|
214 |
|
|
215 |
/*!
|
|
216 |
WLAN Wizard cancellation handler.
|
|
217 |
*/
|
|
218 |
|
|
219 |
void WlanSnifferMainWindow::handleWlanWizardCancelled()
|
|
220 |
{
|
|
221 |
OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_HANDLEWLANWIZARDCANCELLED_ENTRY);
|
|
222 |
|
|
223 |
// The wizard must exist
|
|
224 |
Q_ASSERT(mWizard);
|
|
225 |
|
39
|
226 |
// Enable scanning again
|
|
227 |
mEngine->startWlanScanning();
|
|
228 |
|
|
229 |
// Delete the Wizard instance. This is OK since the connect is Qt::QueuedConnection.
|
|
230 |
mWizard.clear();
|
31
|
231 |
|
|
232 |
OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_HANDLEWLANWIZARDCANCELLED_EXIT);
|
|
233 |
}
|