|
1 /* |
|
2 * Copyright (c) 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 Wizard Page: Processing settings, connection and running ict. |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <HbMainWindow> |
|
20 #include <HbDocumentLoader> |
|
21 #include <HbWidget> |
|
22 #include <HbLabel> |
|
23 #include <HbProgressBar> |
|
24 #include <wlanerrorcodes.h> |
|
25 |
|
26 // User includes |
|
27 #include "wlanwizardplugin.h" |
|
28 #include "wlanqtutils.h" |
|
29 #include "wlanwizard_p.h" |
|
30 #include "wlanwizardpageprocessingsettings.h" |
|
31 #include "OstTraceDefinitions.h" |
|
32 #ifdef OST_TRACE_COMPILER_IN_USE |
|
33 #include "wlanwizardpageprocessingsettingsTraces.h" |
|
34 #endif |
|
35 |
|
36 /*! |
|
37 \class WlanWizardPageProcessingSettings |
|
38 \brief Implements Processing settings wizard page. |
|
39 |
|
40 In this page |
|
41 - possible wizard plugin settings are stored |
|
42 - connection to the wlan ap is established |
|
43 - ICT (Internet connectivity test) is run |
|
44 */ |
|
45 |
|
46 // External function prototypes |
|
47 |
|
48 // Local constants |
|
49 |
|
50 // ======== LOCAL FUNCTIONS ======== |
|
51 |
|
52 // ======== MEMBER FUNCTIONS ======== |
|
53 |
|
54 |
|
55 /*! |
|
56 Constructor. |
|
57 |
|
58 @param [in] parent pointer to private implementation of wizard. |
|
59 */ |
|
60 WlanWizardPageProcessingSettings::WlanWizardPageProcessingSettings( |
|
61 WlanWizardPrivate* parent) : |
|
62 WlanWizardPageInternal(parent), |
|
63 mDocLoader(NULL), |
|
64 mWidget(NULL), |
|
65 mLabel(NULL), |
|
66 mNextPageId(WlanWizardPageInternal::PageSummary) |
|
67 { |
|
68 WlanQtUtils* utils = mWizard->wlanQtUtils(); |
|
69 |
|
70 bool ok; |
|
71 ok = connect( |
|
72 utils, SIGNAL(wlanNetworkOpened(int)), |
|
73 this, SLOT(wlanNetworkOpened(int))); |
|
74 Q_ASSERT(ok); |
|
75 |
|
76 ok = connect( |
|
77 utils, SIGNAL(wlanNetworkClosed(int,int)), |
|
78 this, SLOT(wlanNetworkClosed(int,int))); |
|
79 Q_ASSERT(ok); |
|
80 |
|
81 #ifdef ICT_RESULT_ENUM |
|
82 ok = connect( |
|
83 utils, SIGNAL(ictResult(int,WlanLoginIctsResultType)), |
|
84 this, SLOT(ictResult(int,WlanLoginIctsResultType))); |
|
85 #else |
|
86 ok &= connect( |
|
87 utils, SIGNAL(ictResult(int,bool)), |
|
88 this, SLOT(ictResult(int,bool))); |
|
89 #endif |
|
90 Q_UNUSED(ok); |
|
91 Q_ASSERT(ok); |
|
92 } |
|
93 |
|
94 /*! |
|
95 Destructor. |
|
96 */ |
|
97 WlanWizardPageProcessingSettings::~WlanWizardPageProcessingSettings() |
|
98 { |
|
99 // signals are automatically disconnected |
|
100 delete mDocLoader; |
|
101 |
|
102 // Wizard framework deletes the visualization (owns mWidget). |
|
103 } |
|
104 |
|
105 /*! |
|
106 See WlanWizardPage::initializePage() |
|
107 */ |
|
108 HbWidget* WlanWizardPageProcessingSettings::initializePage() |
|
109 { |
|
110 if (!mWidget) { |
|
111 mDocLoader = new HbDocumentLoader(mWizard->mainWindow()); |
|
112 |
|
113 bool ok; |
|
114 mDocLoader->load(":/docml/occ_add_wlan_06.docml", &ok); |
|
115 Q_ASSERT(ok); |
|
116 loadDocmlSection(mWizard->mainWindow()->orientation()); |
|
117 |
|
118 mWidget = qobject_cast<HbWidget*> (mDocLoader->findWidget("occ_add_wlan_06")); |
|
119 Q_ASSERT(mWidget != NULL); |
|
120 |
|
121 mLabel = qobject_cast<HbLabel*> (mDocLoader->findWidget("dialog")); |
|
122 Q_ASSERT(mLabel != NULL); |
|
123 |
|
124 ok = connect( |
|
125 mWizard->mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)), |
|
126 this, SLOT(loadDocmlSection(Qt::Orientation))); |
|
127 Q_ASSERT(ok); |
|
128 } |
|
129 |
|
130 mLabel->setPlainText(hbTrId("txt_occ_dialog_checking_connection_to_1").arg( |
|
131 mWizard->configuration(WlanWizardPrivate::ConfSsid).toString())); |
|
132 |
|
133 return mWidget; |
|
134 } |
|
135 |
|
136 /*! |
|
137 See WlanWizardPage::nextId() |
|
138 |
|
139 @param [out] removeFromStack return value is always true |
|
140 |
|
141 @return WlanWizardPageInternal::PageSummary |
|
142 */ |
|
143 int WlanWizardPageProcessingSettings::nextId(bool &removeFromStack) const |
|
144 { |
|
145 removeFromStack = true; |
|
146 return mNextPageId; |
|
147 } |
|
148 |
|
149 |
|
150 /*! |
|
151 See WlanWizardPage::showPage() |
|
152 |
|
153 @return false. Next button is dimmed when the page is displayed. |
|
154 */ |
|
155 bool WlanWizardPageProcessingSettings::showPage() |
|
156 { |
|
157 return false; |
|
158 } |
|
159 |
|
160 /*! |
|
161 Loads docml at initialization phase and when HbMainWindow sends orientation() |
|
162 signal. |
|
163 |
|
164 @param [in] orientation to be loaded. |
|
165 */ |
|
166 void WlanWizardPageProcessingSettings::loadDocmlSection(Qt::Orientation orientation) |
|
167 { |
|
168 bool ok; |
|
169 // Load the orientation specific section |
|
170 if (orientation == Qt::Horizontal) { |
|
171 mDocLoader->load(":/docml/occ_add_wlan_06.docml", "landscape_section", &ok); |
|
172 Q_ASSERT(ok); |
|
173 } |
|
174 else { |
|
175 Q_ASSERT(orientation == Qt::Vertical); |
|
176 mDocLoader->load(":/docml/occ_add_wlan_06.docml", "portrait_section", &ok); |
|
177 Q_ASSERT(ok); |
|
178 } |
|
179 } |
|
180 |
|
181 /*! |
|
182 This method is connected to WlanQtUtils::wlanNetworkClosed(int, int) signal. |
|
183 to get disconnected status events of currently established connection. |
|
184 |
|
185 In case of failure, movement to generic error page is triggered. |
|
186 |
|
187 @param [in] iapId IAP ID |
|
188 @param [in] reason Symbian Error code. |
|
189 */ |
|
190 void WlanWizardPageProcessingSettings::wlanNetworkClosed(int iapId, int reason) |
|
191 { |
|
192 OstTraceExt2( TRACE_BORDER, |
|
193 WLANWIZARDPAGEPROCESSINGSETTINGS_WLANNETWORKCLOSED, |
|
194 "WlanWizardPageProcessingSettings::wlanNetworkClosed;iapId=%d;reason=%d", |
|
195 iapId, reason ); |
|
196 |
|
197 if (iapId != mWizard->configuration(WlanWizardHelper::ConfIapId).toInt()) { |
|
198 return; |
|
199 } |
|
200 |
|
201 mWizard->setConfiguration(WlanWizardPrivate::ConfIctStatus, false); |
|
202 mWizard->setConfiguration(WlanWizardPrivate::ConfConnected, false); |
|
203 |
|
204 if (mWizard->isCurrentPage(mWidget)) { |
|
205 QString errorText; |
|
206 switch (reason) { |
|
207 case KErrWlanOpenAuthFailed: |
|
208 case KErrWlanSharedKeyAuthRequired: |
|
209 case KErrWlanWpaAuthRequired: |
|
210 case KErrWlanWpaAuthFailed: |
|
211 case KErrWlan802dot1xAuthFailed: |
|
212 case KErrWlanIllegalEncryptionKeys: |
|
213 case KErrWlanPskModeRequired: |
|
214 case KErrWlanEapModeRequired: |
|
215 errorText = hbTrId("txt_occ_dialog_authentication_unsuccessful"); |
|
216 break; |
|
217 |
|
218 case KErrWlanIllegalWpaPskKey: |
|
219 errorText = hbTrId("txt_occ_dialog_incorrect_wpa_preshared_key_pleas"); |
|
220 break; |
|
221 |
|
222 case KErrWlanSharedKeyAuthFailed: |
|
223 errorText = hbTrId("txt_occ_dialog_incorrect_wep_key_please_check_the"); |
|
224 break; |
|
225 |
|
226 case KErrNone: |
|
227 // Do nothing, when connection is dropped we don't get any error code |
|
228 default: |
|
229 // Get plugin specific localized error text if any |
|
230 WlanWizardPlugin *plugin = mWizard->wlanWizardPlugin(); |
|
231 |
|
232 if (plugin){ |
|
233 errorText = plugin->errorString(reason); |
|
234 } |
|
235 if (errorText.length() == 0) { |
|
236 errorText = hbTrId("txt_occ_dialog_connection_failed"); |
|
237 } |
|
238 break; |
|
239 } |
|
240 mNextPageId = WlanWizardPageInternal::PageGenericError; |
|
241 mWizard->setConfiguration( |
|
242 WlanWizardHelper::ConfGenericErrorString, errorText); |
|
243 mWizard->nextPage(); |
|
244 } |
|
245 |
|
246 OstTrace0( |
|
247 TRACE_BORDER, WLANWIZARDPAGEPROCESSINGSETTINGS_WLANNETWORKCLOSED_DONE, |
|
248 "WlanWizardPageProcessingSettings::wlanNetworkClosed - Done" ); |
|
249 } |
|
250 |
|
251 /*! |
|
252 Handles ictResult(int, bool) signal from WlanQtUtils and calls |
|
253 WlanWizardHelper::nextPage() to trigger movement to next page. |
|
254 |
|
255 @param [in] iapId IAP ID |
|
256 @param [in] reason ICT result, Symbian error code |
|
257 */ |
|
258 #ifdef ICT_RESULT_ENUM |
|
259 void WlanWizardPageProcessingSettings::ictResult(int iapId, WlanLoginIctsResultType reason) |
|
260 { |
|
261 OstTraceExt2( |
|
262 TRACE_BORDER, |
|
263 WLANWIZARDPAGEPROCESSINGSETTINGS_ICTRESULT, |
|
264 "WlanWizardPageProcessingSettings::ictResult;iapId=%d;result=%d", |
|
265 iapId, reason ); |
|
266 |
|
267 if (iapId != mWizard->configuration(WlanWizardHelper::ConfIapId).toInt()) { |
|
268 Q_ASSERT(false); |
|
269 return; |
|
270 } |
|
271 mWizard->setConfiguration(WlanWizardPrivate::ConfConnected, true); |
|
272 mWizard->setConfiguration(WlanWizardPrivate::ConfIctStatus, reason); |
|
273 if(reason == IctsCanceled) { |
|
274 QString errorText; |
|
275 // TODO: What error string should be loaded? |
|
276 mNextPageId = WlanWizardPageInternal::PageGenericError; |
|
277 mWizard->setConfiguration( |
|
278 WlanWizardHelper::ConfGenericErrorString, errorText); |
|
279 } |
|
280 mWizard->nextPage(); |
|
281 |
|
282 OstTrace0( TRACE_BORDER, WLANWIZARDPAGEPROCESSINGSETTINGS_ICTRESULT_DONE, |
|
283 "WlanWizardPageProcessingSettings::ictResult - Done" ); |
|
284 } |
|
285 #else |
|
286 void WlanWizardPageProcessingSettings::ictResult(int iapId, bool reason) |
|
287 { |
|
288 OstTraceExt2( |
|
289 TRACE_BORDER, |
|
290 WLANWIZARDPAGEPROCESSINGSETTINGS_ICTRESULT_1, |
|
291 "WlanWizardPageProcessingSettings::ictResult;iapId=%d;result=%d", |
|
292 iapId, reason ); |
|
293 |
|
294 if (iapId != mWizard->configuration(WlanWizardHelper::ConfIapId).toInt()) { |
|
295 Q_ASSERT(false); |
|
296 return; |
|
297 } |
|
298 mWizard->setConfiguration(WlanWizardPrivate::ConfConnected, true); |
|
299 mWizard->setConfiguration(WlanWizardPrivate::ConfIctStatus, reason); |
|
300 mWizard->nextPage(); |
|
301 |
|
302 OstTrace0( TRACE_BORDER, WLANWIZARDPAGEPROCESSINGSETTINGS_ICTRESULT_DONE_1, |
|
303 "WlanWizardPageProcessingSettings::ictResult - Done" ); |
|
304 } |
|
305 #endif |
|
306 |
|
307 /*! |
|
308 Handles wlanNetworkOpened(int) signal from WlanQtUtils. |
|
309 |
|
310 @param [in] iapId IAP ID |
|
311 */ |
|
312 void WlanWizardPageProcessingSettings::wlanNetworkOpened(int iapId) |
|
313 { |
|
314 Q_UNUSED(iapId); |
|
315 OstTrace1( |
|
316 TRACE_BORDER, |
|
317 WLANWIZARDPAGEPROCESSINGSETTINGS_WLANNETWORKOPENED, |
|
318 "WlanWizardPageProcessingSettings::wlanNetworkOpened;iapId=%d", |
|
319 iapId); |
|
320 } |
|
321 |
|
322 /*! |
|
323 See WlanWizardPage::requiresStartOperation(). |
|
324 |
|
325 Indicates to framework that startOperation() needs to called. |
|
326 */ |
|
327 bool WlanWizardPageProcessingSettings::requiresStartOperation() |
|
328 { |
|
329 return true; |
|
330 } |
|
331 |
|
332 /*! |
|
333 See WlanWizardPage::startOperation(). |
|
334 |
|
335 Starts the page operation. |
|
336 */ |
|
337 void WlanWizardPageProcessingSettings::startOperation() |
|
338 { |
|
339 if (mWizard->handleIap()) { |
|
340 mNextPageId = WlanWizardPageInternal::PageSummary; |
|
341 |
|
342 // in case wlan connection is already established disconnect it |
|
343 // note that connectIap() disconnects implicitly connection when |
|
344 // same IAP is already connected. |
|
345 WlanQtUtils* utils = mWizard->wlanQtUtils(); |
|
346 int connectedIapId = utils->activeIap(); |
|
347 int iapId = mWizard->configuration(WlanWizardHelper::ConfIapId).toInt(); |
|
348 if (connectedIapId != iapId){ |
|
349 utils->disconnectIap(connectedIapId); |
|
350 } |
|
351 mWizard->wlanQtUtils()->connectIap( iapId, true); |
|
352 } else { |
|
353 mNextPageId = WlanWizardPageInternal::PageGenericError; |
|
354 mWizard->setConfiguration( |
|
355 WlanWizardHelper::ConfGenericErrorString, |
|
356 hbTrId("txt_occ_dialog_unable_to_save_settings_please_ret")); |
|
357 mWizard->nextPage(); |
|
358 } |
|
359 } |