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 |
|
|
139 |
Q_ASSERT(mWizard == NULL);
|
|
140 |
|
|
141 |
// Stop WLAN scanning for the duration of WLAN Wizard
|
|
142 |
mEngine->stopWlanScanning();
|
|
143 |
|
39
|
144 |
mWizard = QSharedPointer<WlanWizard>(new WlanWizard(this));
|
31
|
145 |
bool connectStatus = connect(
|
39
|
146 |
mWizard.data(),
|
31
|
147 |
SIGNAL(finished(int,bool)),
|
|
148 |
this,
|
39
|
149 |
SLOT(handleWlanWizardComplete(int,bool)),
|
|
150 |
Qt::QueuedConnection);
|
31
|
151 |
Q_ASSERT(connectStatus == true);
|
|
152 |
|
|
153 |
connectStatus = connect(
|
39
|
154 |
mWizard.data(),
|
31
|
155 |
SIGNAL(cancelled()),
|
|
156 |
this,
|
39
|
157 |
SLOT(handleWlanWizardCancelled()),
|
|
158 |
Qt::QueuedConnection);
|
31
|
159 |
Q_ASSERT(connectStatus == true);
|
|
160 |
|
39
|
161 |
// Create an IAP for a specific AP
|
|
162 |
if (ap) {
|
|
163 |
mWizard->setParameters(
|
60
|
164 |
ap->value(WlanQtUtilsAp::ConfIdName).toString(),
|
|
165 |
ap->value(WlanQtUtilsAp::ConfIdSsid).toByteArray(),
|
39
|
166 |
ap->value(WlanQtUtilsAp::ConfIdConnectionMode).toInt(),
|
|
167 |
ap->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(),
|
|
168 |
ap->value(WlanQtUtilsAp::ConfIdWpaPskUse).toInt(),
|
|
169 |
ap->value(WlanQtUtilsAp::ConfIdWpsSupported).toBool());
|
|
170 |
}
|
|
171 |
// else: Add WLAN IAP manually
|
31
|
172 |
|
|
173 |
mWizard->show();
|
|
174 |
|
|
175 |
OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_STARTWLANWIZARD_EXIT);
|
|
176 |
}
|
|
177 |
|
|
178 |
/*!
|
|
179 |
WLAN Wizard successful completion handler.
|
|
180 |
|
|
181 |
@param [in] iapId IAP ID of the new WLAN IAP.
|
|
182 |
@param [in] connected TRUE if connected.
|
|
183 |
*/
|
|
184 |
|
|
185 |
void WlanSnifferMainWindow::handleWlanWizardComplete(
|
|
186 |
int iapId,
|
|
187 |
bool connected)
|
|
188 |
{
|
|
189 |
OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_HANDLEWLANWIZARDCOMPLETE_ENTRY);
|
|
190 |
|
|
191 |
// The wizard must exist
|
|
192 |
Q_ASSERT(mWizard);
|
|
193 |
|
39
|
194 |
// Enable scanning again
|
|
195 |
mEngine->startWlanScanning();
|
|
196 |
|
|
197 |
if (connected) {
|
|
198 |
// The IAP ID must be valid
|
|
199 |
Q_ASSERT(iapId != WlanQtUtils::IapIdNone);
|
|
200 |
|
|
201 |
// Connect (share) the new IAP in order to keep the connection open when
|
|
202 |
// deleting Wizard.
|
|
203 |
mEngine->wlanQtUtils()->connectIap(iapId, false);
|
|
204 |
}
|
|
205 |
// else: created IAP not connected at all, or already dropped
|
|
206 |
// (probably due to being out of coverage) so don't try to share it
|
|
207 |
|
|
208 |
// Delete the Wizard instance. This is OK since the connect is Qt::QueuedConnection.
|
|
209 |
mWizard.clear();
|
31
|
210 |
|
|
211 |
OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_HANDLEWLANWIZARDCOMPLETE_EXIT);
|
|
212 |
}
|
|
213 |
|
|
214 |
/*!
|
|
215 |
WLAN Wizard cancellation handler.
|
|
216 |
*/
|
|
217 |
|
|
218 |
void WlanSnifferMainWindow::handleWlanWizardCancelled()
|
|
219 |
{
|
|
220 |
OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_HANDLEWLANWIZARDCANCELLED_ENTRY);
|
|
221 |
|
|
222 |
// The wizard must exist
|
|
223 |
Q_ASSERT(mWizard);
|
|
224 |
|
39
|
225 |
// Enable scanning again
|
|
226 |
mEngine->startWlanScanning();
|
|
227 |
|
|
228 |
// Delete the Wizard instance. This is OK since the connect is Qt::QueuedConnection.
|
|
229 |
mWizard.clear();
|
31
|
230 |
|
|
231 |
OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_HANDLEWLANWIZARDCANCELLED_EXIT);
|
|
232 |
}
|