|
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 |
|
89 delete mWizard; |
|
90 |
|
91 OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_WLANSNIFFERMAINWINDOWDESTR_EXIT); |
|
92 } |
|
93 |
|
94 /*! |
|
95 Shows the WLAN Sniffer list view. |
|
96 |
|
97 @param [in] title View title. |
|
98 */ |
|
99 |
|
100 void WlanSnifferMainWindow::toListView(const QString &title) |
|
101 { |
|
102 OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_TOLISTVIEW_ENTRY); |
|
103 |
|
104 // Show the list view |
|
105 mListView->setTitle(title); |
|
106 setCurrentView(mListView); |
|
107 show(); |
|
108 |
|
109 OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_TOLISTVIEW_EXIT); |
|
110 } |
|
111 |
|
112 /*! |
|
113 Creates and adds the WLAN List View to main window. |
|
114 */ |
|
115 |
|
116 void WlanSnifferMainWindow::addListView() |
|
117 { |
|
118 OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_ADDLISTVIEW_ENTRY); |
|
119 |
|
120 mListView = new WlanSnifferListView(mEngine, this); |
|
121 addView(mListView); |
|
122 |
|
123 bool connectStatus = connect( |
|
124 mListView, |
|
125 SIGNAL(wizardTriggered(const WlanQtUtilsAp *)), |
|
126 this, |
|
127 SLOT(startWlanWizard(const WlanQtUtilsAp *))); |
|
128 |
|
129 OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_ADDLISTVIEW_EXIT); |
|
130 } |
|
131 |
|
132 /*! |
|
133 Starts WLAN Wizard for new WLAN IAP creation. |
|
134 |
|
135 @param [in] ap WLAN Access Point to create. |
|
136 */ |
|
137 |
|
138 void WlanSnifferMainWindow::startWlanWizard(const WlanQtUtilsAp *ap) |
|
139 { |
|
140 OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_STARTWLANWIZARD_ENTRY); |
|
141 |
|
142 Q_ASSERT(mWizard == NULL); |
|
143 |
|
144 // Stop WLAN scanning for the duration of WLAN Wizard |
|
145 mEngine->stopWlanScanning(); |
|
146 |
|
147 mWizard = new WlanWizard(this); |
|
148 bool connectStatus = connect( |
|
149 mWizard, |
|
150 SIGNAL(finished(int,bool)), |
|
151 this, |
|
152 SLOT(handleWlanWizardComplete(int,bool))); |
|
153 Q_ASSERT(connectStatus == true); |
|
154 |
|
155 connectStatus = connect( |
|
156 mWizard, |
|
157 SIGNAL(cancelled()), |
|
158 this, |
|
159 SLOT(handleWlanWizardCancelled())); |
|
160 Q_ASSERT(connectStatus == true); |
|
161 |
|
162 mWizard->setParameters( |
|
163 ap->value(WlanQtUtilsAp::ConfIdSsid).toString(), |
|
164 ap->value(WlanQtUtilsAp::ConfIdConnectionMode).toInt(), |
|
165 ap->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(), |
|
166 ap->value(WlanQtUtilsAp::ConfIdWpaPskUse).toInt(), |
|
167 ap->value(WlanQtUtilsAp::ConfIdHidden).toBool(), |
|
168 ap->value(WlanQtUtilsAp::ConfIdWpsSupported).toBool()); |
|
169 |
|
170 mWizard->show(); |
|
171 |
|
172 OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_STARTWLANWIZARD_EXIT); |
|
173 } |
|
174 |
|
175 /*! |
|
176 WLAN Wizard successful completion handler. |
|
177 |
|
178 @param [in] iapId IAP ID of the new WLAN IAP. |
|
179 @param [in] connected TRUE if connected. |
|
180 */ |
|
181 |
|
182 void WlanSnifferMainWindow::handleWlanWizardComplete( |
|
183 int iapId, |
|
184 bool connected) |
|
185 { |
|
186 OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_HANDLEWLANWIZARDCOMPLETE_ENTRY); |
|
187 |
|
188 // Enable scanning again |
|
189 mEngine->startWlanScanning(); |
|
190 |
|
191 // TODO: Will be needed in "Adding WLAN network manually" subfeature |
|
192 Q_UNUSED(connected); |
|
193 |
|
194 // The IAP ID must be valid |
|
195 Q_ASSERT(iapId != WlanQtUtils::IapIdNone); |
|
196 |
|
197 // Connect (share) the new IAP in order to keep the connection open when |
|
198 // deleting Wizard. |
|
199 // Todo: this needs some checking when "Adding WLAN IAP manually" subfeature |
|
200 // is implemented, because we don't want to connect the IAP, if Wizard didn't |
|
201 // connect it. |
|
202 mEngine->wlanQtUtils()->connectIap(iapId, false); |
|
203 |
|
204 // The wizard must exist |
|
205 Q_ASSERT(mWizard); |
|
206 |
|
207 // Delete the Wizard instance, but only when returning to event loop, because |
|
208 // execution returns back to Wizard after this slot. |
|
209 mWizard->deleteLater(); |
|
210 mWizard = NULL; |
|
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 // Enable scanning again |
|
224 mEngine->startWlanScanning(); |
|
225 |
|
226 // The wizard must exist |
|
227 Q_ASSERT(mWizard); |
|
228 |
|
229 // Delete the Wizard instance, but only when returning to event loop, because |
|
230 // execution returns back to Wizard after this slot. |
|
231 mWizard->deleteLater(); |
|
232 mWizard = NULL; |
|
233 |
|
234 OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_HANDLEWLANWIZARDCANCELLED_EXIT); |
|
235 } |