39
|
1 |
/*
|
60
|
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 the "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 |
* WPS Wizard: Private implementation.
|
|
16 |
*/
|
39
|
17 |
|
|
18 |
// System includes
|
60
|
19 |
|
|
20 |
#include <QGraphicsWidget>
|
|
21 |
#include <QApplication>
|
|
22 |
|
39
|
23 |
#include <HbTranslator>
|
|
24 |
#include <HbDocumentLoader>
|
|
25 |
#include <HbMainWindow>
|
|
26 |
#include <HbView>
|
|
27 |
#include <HbStackedWidget>
|
|
28 |
#include <HbLabel>
|
|
29 |
#include <HbAction>
|
60
|
30 |
|
39
|
31 |
#include <cmmanagerdefines_shim.h>
|
|
32 |
|
60
|
33 |
// User includes
|
39
|
34 |
|
|
35 |
#include "wlanwizardhelper.h"
|
|
36 |
// WPS Wizard
|
|
37 |
#include "wpswizard.h"
|
|
38 |
#include "wpswizard_p.h"
|
|
39 |
// Wizard Pages
|
|
40 |
#include "wpswizardsteptwo.h"
|
|
41 |
#include "wpswizardstepthreebutton.h"
|
|
42 |
#include "wpswizardstepthreenumber.h"
|
|
43 |
#include "wpswizardstepfour.h"
|
|
44 |
#include "wpswizardstepfive.h"
|
|
45 |
|
60
|
46 |
// Trace includes
|
|
47 |
|
|
48 |
#include "OstTraceDefinitions.h"
|
|
49 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
50 |
#include "wpswizard_pTraces.h"
|
|
51 |
#endif
|
|
52 |
|
39
|
53 |
//Forward Decalrations
|
|
54 |
|
|
55 |
// External function prototypes
|
|
56 |
|
|
57 |
// Local constants
|
|
58 |
|
|
59 |
|
|
60 |
/*!
|
|
61 |
\class WpsWizardPrivate
|
|
62 |
\brief This class providesthe private class implementation for WPS wizard
|
|
63 |
*/
|
|
64 |
|
|
65 |
// ======== LOCAL FUNCTIONS ========
|
|
66 |
|
|
67 |
// ======== MEMBER FUNCTIONS ========
|
|
68 |
|
|
69 |
/*!
|
|
70 |
Constructor for the private implementation of wps wizard
|
|
71 |
|
|
72 |
@param [in] wizard WpsWizard* pointer to the framework object
|
|
73 |
@param [in] wizardHelper WlanWizardHelper * pointer to the wizard helpper class
|
|
74 |
|
|
75 |
@return WpsWizardPrivate
|
|
76 |
*/
|
60
|
77 |
WpsWizardPrivate::WpsWizardPrivate(
|
|
78 |
WpsWizard* wizard,
|
39
|
79 |
WlanWizardHelper *wizardHelper) :
|
|
80 |
q_ptr(wizard),
|
|
81 |
mWizardHelper(wizardHelper),
|
|
82 |
mTranslator(new HbTranslator("wpswizardplugin")),
|
|
83 |
mRandomNumber(0)
|
|
84 |
{
|
|
85 |
OstTraceFunctionEntry1(WPSWIZARDPRIVATE_WPSWIZARDPRIVATE_ENTRY, this);
|
|
86 |
createPages();
|
|
87 |
OstTraceFunctionExit1(WPSWIZARDPRIVATE_WPSWIZARDPRIVATE_EXIT, this);
|
|
88 |
}
|
|
89 |
|
|
90 |
/*!
|
|
91 |
Destructor
|
|
92 |
*/
|
|
93 |
WpsWizardPrivate::~WpsWizardPrivate()
|
|
94 |
{
|
|
95 |
OstTraceFunctionEntry1(WPSWIZARDPRIVATE_WPSWIZARDPRIVATE_DESTRUCTOR_ENTRY, this);
|
|
96 |
// have to delete the memory that was allocated in this object
|
|
97 |
mIapList.clear();
|
|
98 |
OstTraceFunctionExit1(WPSWIZARDPRIVATE_WPSWIZARDPRIVATE_DESTRUCTOR_EXIT, this);
|
|
99 |
}
|
|
100 |
|
|
101 |
/*!
|
|
102 |
Provides the caller with the functionality to enable/disable the 'Next' button
|
|
103 |
|
|
104 |
@param [in] enable bool to indicate whether to enable or disable the 'next button'
|
|
105 |
*/
|
|
106 |
void WpsWizardPrivate::enableNextButton(bool enable)
|
|
107 |
{
|
|
108 |
OstTraceFunctionEntry1(WPSWIZARDPRIVATE_ENABLENEXTBUTTON_ENTRY, this);
|
|
109 |
mWizardHelper->enableNextButton(enable);
|
|
110 |
OstTraceFunctionExit1(WPSWIZARDPRIVATE_ENABLENEXTBUTTON_EXIT, this);
|
|
111 |
}
|
|
112 |
|
|
113 |
/*!
|
|
114 |
Provides the functionality to automatically move to the next page.
|
|
115 |
*/
|
|
116 |
void WpsWizardPrivate::nextPage()
|
|
117 |
{
|
|
118 |
OstTraceFunctionEntry1(WPSWIZARDPRIVATE_NEXTPAGE_ENTRY, this);
|
|
119 |
mWizardHelper->nextPage();
|
|
120 |
OstTraceFunctionExit1(WPSWIZARDPRIVATE_NEXTPAGE_EXIT, this);
|
|
121 |
}
|
|
122 |
|
|
123 |
/*!
|
|
124 |
Provides access to the main window
|
|
125 |
|
|
126 |
@return HbMainWindow* An instance of HbMainWindow.
|
|
127 |
*/
|
|
128 |
HbMainWindow* WpsWizardPrivate::mainWindow()
|
|
129 |
{
|
|
130 |
return mWizardHelper->mainWindow();
|
|
131 |
}
|
|
132 |
|
|
133 |
/*!
|
|
134 |
Provides the functionality to store the received settings
|
|
135 |
|
|
136 |
@param [in] index int indicates the index in the array of received
|
|
137 |
settings to be stored
|
|
138 |
*/
|
|
139 |
void WpsWizardPrivate::storeSettings(int index)
|
|
140 |
{
|
|
141 |
OstTraceFunctionEntry1(WPSWIZARDPRIVATE_STORESETTINGS_ENTRY, this);
|
|
142 |
|
|
143 |
if (mIapList.count() > index)
|
|
144 |
{
|
|
145 |
mWpsAttr = mIapList[index];
|
|
146 |
|
|
147 |
// SSID
|
|
148 |
QString ssid = QString::fromUtf8(reinterpret_cast<const char*> (mWpsAttr.iSsid.Ptr()),
|
|
149 |
mWpsAttr.iSsid.Length());
|
60
|
150 |
mWizardHelper->setConfiguration(WlanWizardHelper::ConfName, ssid);
|
|
151 |
mWizardHelper->setConfiguration(WlanWizardHelper::ConfSsid, ssid.toUtf8());
|
39
|
152 |
// WEP Key1
|
|
153 |
QString str = QString::fromUtf8(reinterpret_cast<const char*>(mWpsAttr.iWepKey1.Ptr()),
|
|
154 |
mWpsAttr.iWepKey1.Length());
|
|
155 |
mWizardHelper->setConfiguration(WlanWizardHelper::ConfKeyWep1, str);
|
|
156 |
// WEP Key2
|
|
157 |
str = QString::fromUtf8(reinterpret_cast<const char*> (mWpsAttr.iWepKey2.Ptr()),
|
|
158 |
mWpsAttr.iWepKey2.Length());
|
|
159 |
mWizardHelper->setConfiguration(WlanWizardHelper::ConfKeyWep2, str);
|
|
160 |
// WEP Key3
|
|
161 |
str = QString::fromUtf8(reinterpret_cast<const char*> (mWpsAttr.iWepKey3.Ptr()),
|
|
162 |
mWpsAttr.iWepKey3.Length());
|
|
163 |
mWizardHelper->setConfiguration(WlanWizardHelper::ConfKeyWep3, str);
|
|
164 |
// WEP Key4
|
|
165 |
str = QString::fromUtf8(reinterpret_cast<const char*> (mWpsAttr.iWepKey4.Ptr()),
|
|
166 |
mWpsAttr.iWepKey4.Length());
|
|
167 |
mWizardHelper->setConfiguration(WlanWizardHelper::ConfKeyWep4, str);
|
|
168 |
//Default WEP key in use
|
|
169 |
mWizardHelper->setConfiguration(WlanWizardHelper::ConfKeyWepDefault,
|
|
170 |
convertDefaultWepKey(mWpsAttr.iWepDefaultKey));
|
|
171 |
//Key WPA
|
|
172 |
str = QString::fromUtf8(reinterpret_cast<const char*> (mWpsAttr.iWpaPreSharedKey.Ptr()),
|
|
173 |
mWpsAttr.iWpaPreSharedKey.Length());
|
|
174 |
mWizardHelper->setConfiguration(WlanWizardHelper::ConfKeyWpa, str);
|
|
175 |
// security mode
|
|
176 |
mWizardHelper->setConfiguration(WlanWizardHelper::ConfSecurityMode,
|
|
177 |
convertSecurityModes(mWpsAttr.iSecurityMode));
|
|
178 |
// Network Mode
|
|
179 |
mWizardHelper->setConfiguration(WlanWizardHelper::ConfNetworkMode,
|
|
180 |
convertNetworkModes(mWpsAttr.iOperatingMode));
|
|
181 |
|
|
182 |
mWizardHelper->setConfiguration(WlanWizardHelper::ConfUsePsk, true);
|
|
183 |
}
|
|
184 |
|
|
185 |
OstTraceFunctionExit1(WPSWIZARDPRIVATE_STORESETTINGS_EXIT, this);
|
|
186 |
}
|
|
187 |
|
|
188 |
/*!
|
|
189 |
Provides the functionality to retrieve the ssid of the network to connect
|
|
190 |
|
|
191 |
@return returns the SSID as a QString
|
|
192 |
*/
|
|
193 |
QString WpsWizardPrivate::getSsid()
|
|
194 |
{
|
|
195 |
OstTraceFunctionEntry1(WPSWIZARDPRIVATE_GETSSID_ENTRY, this);
|
|
196 |
QString ssid;
|
|
197 |
ssid = mWizardHelper->configuration(WlanWizardHelper::ConfSsid).toString();
|
|
198 |
OstTraceFunctionExit1(WPSWIZARDPRIVATE_GETSSID_EXIT, this);
|
|
199 |
return ssid;
|
|
200 |
}
|
|
201 |
|
|
202 |
/*!
|
|
203 |
Provides functionality for the caller to store the array of
|
|
204 |
recieved settings from AP
|
|
205 |
|
|
206 |
@param [in] credentials QList<TWlanProtectedSetupCredentialAttribute>&
|
|
207 |
received settings from wps enabled AP
|
|
208 |
*/
|
|
209 |
void WpsWizardPrivate::storeSettingsArray(QList<
|
|
210 |
TWlanProtectedSetupCredentialAttribute>& credentials)
|
|
211 |
{
|
|
212 |
OstTraceFunctionEntry1(WPSWIZARDPRIVATE_STORESETTINGSARRAY_ENTRY, this);
|
|
213 |
mIapList = credentials;
|
|
214 |
OstTraceFunctionExit1(WPSWIZARDPRIVATE_STORESETTINGSARRAY_EXIT, this);
|
|
215 |
}
|
|
216 |
|
|
217 |
/*!
|
|
218 |
Returns the array of settings received from the AP
|
|
219 |
|
|
220 |
@return Array containing the settings
|
|
221 |
*/
|
|
222 |
QList<TWlanProtectedSetupCredentialAttribute> WpsWizardPrivate::getSettingsArray()
|
|
223 |
{
|
|
224 |
OstTraceFunctionEntry1(WPSWIZARDPRIVATE_GETSETTINGSARRAY_ENTRY, this);
|
|
225 |
OstTraceFunctionExit1(WPSWIZARDPRIVATE_GETSETTINGSARRAY_EXIT, this);
|
|
226 |
return mIapList;
|
|
227 |
}
|
|
228 |
|
|
229 |
/*!
|
|
230 |
Creates the required pages for WPS setup
|
|
231 |
*/
|
|
232 |
void WpsWizardPrivate::createPages()
|
|
233 |
{
|
|
234 |
OstTraceFunctionEntry1(WPSWIZARDPRIVATE_CREATEPAGES_ENTRY, this);
|
|
235 |
|
|
236 |
mWizardHelper->addPage(WpsWizardPage::PageWpsWizardStep2,
|
|
237 |
new WpsPageStepTwo(this));
|
|
238 |
|
|
239 |
mWizardHelper->addPage(WpsWizardPage::PageWpsWizardStep3_Button,
|
|
240 |
new WpsPageStepThreeButton(this));
|
|
241 |
|
|
242 |
mWizardHelper->addPage(WpsWizardPage::PageWpsWizardStep3_Number,
|
|
243 |
new WpsPageStepThreeNumber(this));
|
|
244 |
|
|
245 |
mWizardHelper->addPage(WpsWizardPage::PageWpsWizardStep4,
|
|
246 |
new WpsPageStepFour(this));
|
|
247 |
|
|
248 |
mWizardHelper->addPage(WpsWizardPage::PageWpsWizardStep5,
|
|
249 |
new WpsPageStepFive(this));
|
|
250 |
|
|
251 |
OstTraceFunctionExit1(WPSWIZARDPRIVATE_CREATEPAGES_EXIT, this);
|
|
252 |
}
|
|
253 |
|
|
254 |
/*!
|
|
255 |
Converts enums between wlan security mode to cm manager enums.
|
|
256 |
|
|
257 |
@param [in] securityMode Security operating mode from wlanmgmt api
|
|
258 |
|
|
259 |
@return int converted CMManagerShim::WlanSecMode codes
|
|
260 |
*/
|
|
261 |
int WpsWizardPrivate::convertSecurityModes(TWlanIapSecurityMode securityMode)
|
|
262 |
{
|
|
263 |
CMManagerShim::WlanSecMode cmManagerSecurityMode;
|
|
264 |
switch(securityMode) {
|
|
265 |
case EWlanIapSecurityModeWep:
|
|
266 |
cmManagerSecurityMode = CMManagerShim::WlanSecModeWep;
|
|
267 |
break;
|
|
268 |
|
|
269 |
case EWlanIapSecurityModeWpa:
|
|
270 |
cmManagerSecurityMode = CMManagerShim::WlanSecModeWpa;
|
|
271 |
break;
|
|
272 |
|
|
273 |
case EWlanIapSecurityModeWpa2Only:
|
|
274 |
cmManagerSecurityMode = CMManagerShim::WlanSecModeWpa2;
|
|
275 |
break;
|
|
276 |
|
|
277 |
default:
|
|
278 |
// invalid securityMode.
|
|
279 |
// Not possible to get EWlanIapSecurityMode802d1x here. Since not
|
|
280 |
// supported with wps
|
|
281 |
Q_ASSERT(EWlanIapSecurityModeAllowUnsecure == securityMode);
|
|
282 |
cmManagerSecurityMode = CMManagerShim::WlanSecModeOpen;
|
|
283 |
break;
|
|
284 |
}
|
|
285 |
|
|
286 |
return cmManagerSecurityMode;
|
|
287 |
}
|
|
288 |
|
|
289 |
/*!
|
|
290 |
Converts enums between wlan wep key index to cm manager enums.
|
|
291 |
|
|
292 |
@param [in] defaultWepKey Default wep key used in wlanmgmt api
|
|
293 |
|
|
294 |
@return int converted CMManagerShim::WlanWepKeyIndex codes
|
|
295 |
*/
|
|
296 |
int WpsWizardPrivate::convertDefaultWepKey(TWlanDefaultWepKey defaultWepKey)
|
|
297 |
{
|
|
298 |
int cmManagerWepKeyIndex;
|
|
299 |
|
|
300 |
switch (defaultWepKey) {
|
|
301 |
case EWlanDefaultWepKey2:
|
|
302 |
cmManagerWepKeyIndex = CMManagerShim::WepKeyIndex2;
|
|
303 |
break;
|
|
304 |
|
|
305 |
case EWlanDefaultWepKey3:
|
|
306 |
cmManagerWepKeyIndex = CMManagerShim::WepKeyIndex3;
|
|
307 |
break;
|
|
308 |
|
|
309 |
case EWlanDefaultWepKey4:
|
|
310 |
cmManagerWepKeyIndex = CMManagerShim::WepKeyIndex4;
|
|
311 |
break;
|
|
312 |
|
|
313 |
case EWlanDefaultWepKey1:
|
|
314 |
default:
|
|
315 |
// It is possible that the value of defaultWepKey is not initialized
|
|
316 |
// when security mode is Open. That's why we cannot assert here.
|
|
317 |
cmManagerWepKeyIndex = CMManagerShim::WepKeyIndex1;
|
|
318 |
break;
|
|
319 |
}
|
|
320 |
return cmManagerWepKeyIndex;
|
|
321 |
}
|
|
322 |
|
|
323 |
/*!
|
|
324 |
Converts enums between wlan network mode to cm manager enums.
|
|
325 |
|
|
326 |
@param [in] networkMode Networking operating mode from wlanmgmt api
|
|
327 |
|
|
328 |
@return int converted CMManagerShim::WlanConnMode codes
|
|
329 |
*/
|
|
330 |
int WpsWizardPrivate::convertNetworkModes(TWlanOperatingMode networkMode)
|
|
331 |
{
|
|
332 |
CMManagerShim::WlanConnMode wlanConnMode;
|
|
333 |
switch (networkMode) {
|
|
334 |
case EWlanOperatingModeAdhoc:
|
|
335 |
wlanConnMode = CMManagerShim::Adhoc;
|
|
336 |
break;
|
|
337 |
|
|
338 |
default:
|
|
339 |
Q_ASSERT(EWlanOperatingModeInfrastructure == networkMode);
|
|
340 |
wlanConnMode = CMManagerShim::Infra;
|
|
341 |
break;
|
|
342 |
}
|
|
343 |
return wlanConnMode;
|
|
344 |
}
|
|
345 |
|
|
346 |
/*!
|
|
347 |
Provides with the functionality to store the PIN generated
|
|
348 |
|
|
349 |
@param [in] random The generated PIN code to be used in succesive steps
|
|
350 |
|
|
351 |
*/
|
|
352 |
void WpsWizardPrivate::setPin(int random)
|
|
353 |
{
|
|
354 |
OstTraceFunctionEntry1(WPSWIZARDPRIVATE_SETPIN_ENTRY, this);
|
|
355 |
mRandomNumber = random;
|
|
356 |
OstTraceFunctionExit1(WPSWIZARDPRIVATE_SETPIN_EXIT, this);
|
|
357 |
}
|
|
358 |
|
|
359 |
/*!
|
|
360 |
Returns the PIN code stored in one of the WPS Pages
|
|
361 |
|
|
362 |
@return PIN code to be used in the WPS operation.
|
|
363 |
*/
|
|
364 |
int WpsWizardPrivate::getPin()
|
|
365 |
{
|
|
366 |
OstTraceFunctionEntry1(WPSWIZARDPRIVATE_GETPIN_ENTRY, this);
|
|
367 |
OstTraceFunctionExit1(WPSWIZARDPRIVATE_GETPIN_EXIT, this);
|
|
368 |
return mRandomNumber;
|
|
369 |
}
|
|
370 |
|
|
371 |
/*!
|
|
372 |
Returns page id when manual configuration is chosen
|
|
373 |
|
|
374 |
@param [in] useWps is WPS used or not?
|
|
375 |
|
|
376 |
@return new page id
|
|
377 |
*/
|
|
378 |
int WpsWizardPrivate::nextPageId(bool useWps)
|
|
379 |
{
|
|
380 |
OstTraceFunctionEntry1(WPSWIZARDPRIVATE_NEXTPAGEID_ENTRY, this);
|
|
381 |
OstTraceFunctionExit1(WPSWIZARDPRIVATE_NEXTPAGEID_EXIT, this);
|
|
382 |
return mWizardHelper->nextPageId(useWps);
|
|
383 |
}
|
|
384 |
|
|
385 |
/*!
|
|
386 |
Sets wlan configuration value for given configuration identifier.
|
|
387 |
See ConfigurationId for further details about the data types in QVariant.
|
|
388 |
|
|
389 |
@param [in] confId Configuration Identifier do to be set
|
|
390 |
@param [in] value Value for configuration.
|
|
391 |
*/
|
|
392 |
void WpsWizardPrivate::setConfiguration(
|
|
393 |
WlanWizardHelper::ConfigurationId confId,
|
|
394 |
const QVariant &value)
|
|
395 |
{
|
|
396 |
mWizardHelper->setConfiguration(confId, value);
|
|
397 |
}
|