31
|
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: Security mode Selection.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
// System includes
|
|
20 |
#include <HbDocumentLoader>
|
|
21 |
#include <HbWidget>
|
|
22 |
#include <HbRadioButtonList>
|
|
23 |
#include <HbMainWindow>
|
|
24 |
#include <HbLabel>
|
|
25 |
#include <cmmanagerdefines_shim.h>
|
|
26 |
|
|
27 |
// User includes
|
|
28 |
#include "wlanwizard_p.h"
|
|
29 |
#include "wlanwizard.h"
|
|
30 |
#include "wlanwizardpagesecuritymode.h"
|
39
|
31 |
#include "wlanwizardscanlist.h"
|
31
|
32 |
#include "OstTraceDefinitions.h"
|
|
33 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
34 |
#include "wlanwizardpagesecuritymodeTraces.h"
|
|
35 |
#endif
|
|
36 |
|
|
37 |
/*!
|
39
|
38 |
* Constructor method for the Sequrity mode query view object.
|
|
39 |
* @param [in] parent pointer to parent object.
|
31
|
40 |
*/
|
|
41 |
WlanWizardPageSecurityMode::WlanWizardPageSecurityMode(
|
|
42 |
WlanWizardPrivate* parent) :
|
|
43 |
WlanWizardPageInternal(parent),
|
|
44 |
mWidget(NULL),
|
|
45 |
mList(NULL),
|
|
46 |
mLabel(NULL),
|
|
47 |
mLoader(NULL),
|
|
48 |
mValid(false)
|
|
49 |
{
|
43
|
50 |
OstTraceFunctionEntry0( WLANWIZARDPAGESECURITYMODE_WLANWIZARDPAGESECURITYMODE_ENTRY );
|
|
51 |
OstTraceFunctionExit0( WLANWIZARDPAGESECURITYMODE_WLANWIZARDPAGESECURITYMODE_EXIT );
|
31
|
52 |
}
|
|
53 |
|
|
54 |
/*!
|
|
55 |
* Destructor. Loader widget is deleted.
|
|
56 |
* All document widgets are deleted by wlanwizard_p destructor.
|
|
57 |
*/
|
|
58 |
WlanWizardPageSecurityMode::~WlanWizardPageSecurityMode()
|
|
59 |
{
|
43
|
60 |
OstTraceFunctionEntry0( DUP1_WLANWIZARDPAGESECURITYMODE_WLANWIZARDPAGESECURITYMODE_ENTRY );
|
31
|
61 |
delete mLoader;
|
43
|
62 |
OstTraceFunctionExit0( DUP1_WLANWIZARDPAGESECURITYMODE_WLANWIZARDPAGESECURITYMODE_EXIT );
|
31
|
63 |
}
|
|
64 |
|
|
65 |
/*!
|
39
|
66 |
* Page initialization. If view widget is already loaded, does nothing.
|
|
67 |
* @return pointer to widget "occ_add_wlan_02".
|
31
|
68 |
*/
|
|
69 |
HbWidget* WlanWizardPageSecurityMode::initializePage()
|
|
70 |
{
|
43
|
71 |
OstTraceFunctionEntry0( WLANWIZARDPAGESECURITYMODE_INITIALIZEPAGE_ENTRY );
|
31
|
72 |
OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESECURITYMODE_INITIALIZEPAGE,
|
|
73 |
"WlanWizardPageSecurityMode::initializePage" );
|
|
74 |
|
|
75 |
if (mWidget==NULL) {
|
|
76 |
|
|
77 |
mLoader = new HbDocumentLoader(mWizard->mainWindow());
|
|
78 |
|
|
79 |
bool ok;
|
|
80 |
|
|
81 |
mLoader->load( ":/docml/occ_add_wlan_02_03.docml", &ok );
|
39
|
82 |
Q_ASSERT(ok);
|
31
|
83 |
|
|
84 |
// Initialize orientation
|
39
|
85 |
loadDocmlSection( mWizard->mainWindow()->orientation() );
|
31
|
86 |
|
|
87 |
// Load widgets
|
|
88 |
mWidget = qobject_cast<HbWidget*> (mLoader->findWidget("occ_add_wlan_02"));
|
39
|
89 |
Q_ASSERT(mWidget != NULL);
|
31
|
90 |
|
|
91 |
mList = qobject_cast<HbRadioButtonList*> (mLoader->findWidget("list"));
|
39
|
92 |
Q_ASSERT(mList != NULL);
|
31
|
93 |
|
|
94 |
mLabel = qobject_cast<HbLabel*> (mLoader->findWidget("dialog_6"));
|
39
|
95 |
Q_ASSERT(mLabel != NULL);
|
31
|
96 |
|
|
97 |
mLabel->setPlainText(hbTrId("txt_occ_dialog_select_network_security_mode"));
|
|
98 |
|
|
99 |
// Connect orientation signal from the main window to orientation
|
|
100 |
// loader.
|
|
101 |
ok &= connect( mWizard->mainWindow(),
|
|
102 |
SIGNAL(orientationChanged(Qt::Orientation)),
|
39
|
103 |
this, SLOT(loadDocmlSection(Qt::Orientation)));
|
|
104 |
Q_ASSERT(ok);
|
31
|
105 |
|
|
106 |
// Connect signal from the radio button list indicating that an item
|
|
107 |
// has been selected to validation handler.
|
|
108 |
ok &= connect( mList, SIGNAL(itemSelected(int)),
|
39
|
109 |
this, SLOT(itemSelected()));
|
|
110 |
Q_ASSERT(ok);
|
|
111 |
}
|
|
112 |
|
|
113 |
// Create contents to the security mode radio button list.
|
|
114 |
populateSecModeList();
|
31
|
115 |
|
43
|
116 |
OstTraceFunctionExit0( WLANWIZARDPAGESECURITYMODE_INITIALIZEPAGE_EXIT );
|
31
|
117 |
return mWidget;
|
|
118 |
}
|
|
119 |
|
|
120 |
/*!
|
39
|
121 |
* Validates the Sequrity more selection and sets the configuration in
|
|
122 |
* the wlanwizard.
|
|
123 |
* @param [out] removeFromStack returns false.
|
|
124 |
* @return depending on the sequrity mode, returns the appropriate view
|
|
125 |
* identifier.
|
31
|
126 |
*/
|
|
127 |
int WlanWizardPageSecurityMode::nextId(bool &removeFromStack) const
|
|
128 |
{
|
43
|
129 |
OstTraceFunctionEntry0( WLANWIZARDPAGESECURITYMODE_NEXTID_ENTRY );
|
31
|
130 |
removeFromStack = false;
|
|
131 |
|
|
132 |
// The configuration is selected from the mSecModes list, which is ordered
|
|
133 |
// during the page initialization.
|
|
134 |
mWizard->setConfiguration( WlanWizardPrivate::ConfSecurityMode,
|
|
135 |
mSecModes.at( mList->selected() ) );
|
|
136 |
|
|
137 |
// The configuration is selected from the mUsePsk list, which is ordered
|
|
138 |
// during the page initialization.
|
|
139 |
mWizard->setConfiguration( WlanWizardPrivate::ConfUsePsk,
|
|
140 |
mUsePsk.at( mList->selected() ) );
|
43
|
141 |
OstTraceFunctionExit0( LANWIZARDPAGESECURITYMODE_NEXTID_EXIT );
|
31
|
142 |
return mPageIds.at( mList->selected() );
|
|
143 |
}
|
|
144 |
|
|
145 |
/*!
|
39
|
146 |
* This method is overrides the default implementation from WlanWizardPage.
|
|
147 |
* It indicates whether the Next-button should be enabled or not.
|
|
148 |
* @return true, if a mode has been selected.
|
|
149 |
*/
|
|
150 |
bool WlanWizardPageSecurityMode::showPage()
|
|
151 |
{
|
43
|
152 |
OstTraceFunctionEntry0( WLANWIZARDPAGESECURITYMODE_SHOWPAGE_ENTRY );
|
|
153 |
OstTraceFunctionExit0( WLANWIZARDPAGESECURITYMODE_SHOWPAGE_EXIT );
|
39
|
154 |
return mValid;
|
|
155 |
}
|
|
156 |
|
|
157 |
/*!
|
|
158 |
* Is invoked when user selects a mode from the radio button list.
|
|
159 |
* (HbRadioButtonList's itemSelected-signal)
|
31
|
160 |
*/
|
39
|
161 |
void WlanWizardPageSecurityMode::itemSelected()
|
|
162 |
{
|
43
|
163 |
OstTraceFunctionEntry0( WLANWIZARDPAGESECURITYMODE_ITEMSELECTED_ENTRY );
|
39
|
164 |
OstTrace0( TRACE_BORDER, WLANWIZARDPAGESECURITYMODE_ITEMSELECTED,
|
|
165 |
"WlanWizardPageSecurityMode::itemSelected" );
|
|
166 |
|
|
167 |
mValid = true;
|
|
168 |
mWizard->enableNextButton(mValid);
|
43
|
169 |
OstTraceFunctionExit0( WLANWIZARDPAGESECURITYMODE_ITEMSELECTED_EXIT );
|
39
|
170 |
}
|
|
171 |
|
|
172 |
/*!
|
|
173 |
* Loads the document orientation information from occ_add_wlan_02_03.docml
|
|
174 |
* This is called each time phone orientation changes.
|
|
175 |
* @param [in] orientation indicates whether the phone is in portrait or
|
|
176 |
* landscape mode.
|
|
177 |
*/
|
|
178 |
void WlanWizardPageSecurityMode::loadDocmlSection(Qt::Orientation orientation)
|
31
|
179 |
{
|
43
|
180 |
OstTraceFunctionEntry0( WLANWIZARDPAGESECURITYMODE_LOADDOCMLSECTION_ENTRY );
|
31
|
181 |
OstTrace1( TRACE_NORMAL, WLANWIZARDPAGESECURITYMODE_LOADDOCML,
|
|
182 |
"WlanWizardPageSecurityMode::loadDocml - orientation;orientation=%x",
|
|
183 |
( TUint )( orientation ) );
|
|
184 |
|
39
|
185 |
WlanWizardPageInternal::loadDocmlSection(
|
|
186 |
mLoader,
|
|
187 |
orientation,
|
|
188 |
":/docml/occ_add_wlan_02_03.docml",
|
|
189 |
"portrait_section",
|
|
190 |
"landscape_section");
|
43
|
191 |
OstTraceFunctionExit0( WLANWIZARDPAGESECURITYMODE_LOADDOCMLSECTION_EXIT );
|
31
|
192 |
}
|
|
193 |
|
|
194 |
/*!
|
|
195 |
* Support function that creates the contents of the security mode list.
|
|
196 |
*/
|
|
197 |
void WlanWizardPageSecurityMode::populateSecModeList()
|
|
198 |
{
|
43
|
199 |
OstTraceFunctionEntry0( WLANWIZARDPAGESECURITYMODE_POPULATESECMODELIST_ENTRY );
|
31
|
200 |
QStringList items;
|
43
|
201 |
|
31
|
202 |
mSecModes.clear();
|
|
203 |
mPageIds.clear();
|
39
|
204 |
mUsePsk.clear();
|
|
205 |
|
|
206 |
// A list is created. Since there is no practical way of knowing whether
|
|
207 |
// the new contents are different from the previous contents (if there
|
|
208 |
// even were any in the first place) the validity is always reset.
|
|
209 |
mValid = false;
|
31
|
210 |
|
|
211 |
// Create the radio button list to correspond to correct security mode
|
|
212 |
// identifiers and page identifiers.
|
|
213 |
// Populate the list according to network mode selection.
|
|
214 |
addToList(items, hbTrId("txt_occ_list_open"),
|
|
215 |
CMManagerShim::WlanSecModeOpen,
|
|
216 |
WlanWizardPage::PageProcessSettings,
|
|
217 |
false);
|
|
218 |
|
|
219 |
addToList(items, hbTrId("txt_occ_list_wep_1"),
|
|
220 |
CMManagerShim::WlanSecModeWep,
|
|
221 |
WlanWizardPageInternal::PageKeyQuery,
|
|
222 |
true);
|
|
223 |
|
|
224 |
// In case of Ad-hoc network, exclude wpa, eap and 802.1X modes.
|
39
|
225 |
if (mWizard->configuration(WlanWizardPrivate::ConfNetworkMode).toInt()
|
31
|
226 |
!= CMManagerShim::Adhoc) {
|
|
227 |
|
|
228 |
addToList(items, hbTrId("txt_occ_list_wpa_with_password"),
|
|
229 |
CMManagerShim::WlanSecModeWpa,
|
|
230 |
WlanWizardPageInternal::PageKeyQuery,
|
|
231 |
true);
|
|
232 |
|
|
233 |
addToList(items, hbTrId("txt_occ_list_wpa_with_eap"),
|
|
234 |
CMManagerShim::WlanSecModeWpa,
|
|
235 |
WlanWizardPage::PageEapStart,
|
|
236 |
false);
|
|
237 |
|
|
238 |
addToList(items, hbTrId("txt_occ_list_8021x_1"),
|
|
239 |
CMManagerShim::WlanSecMode802_1x,
|
|
240 |
WlanWizardPage::PageEapStart,
|
|
241 |
false);
|
|
242 |
}
|
|
243 |
|
|
244 |
mList->setItems(items);
|
43
|
245 |
|
|
246 |
OstTraceFunctionExit0( WLANWIZARDPAGESECURITYMODE_POPULATESECMODELIST_EXIT );
|
31
|
247 |
}
|
|
248 |
|
|
249 |
/*!
|
39
|
250 |
* A support function to map the radio button list to a generic network
|
|
251 |
* mode list. This enables the changing of button order without it
|
|
252 |
* affecting the entire class.
|
|
253 |
* @param [out] list is a reference to a local list that will be placed as an
|
|
254 |
* argument to the radio button list.
|
|
255 |
* @param [in] item is a reference to the text value that is appended to the
|
|
256 |
* list
|
|
257 |
* @param [in] mode is the security mode associated with the item
|
|
258 |
* @param [in] page is the id of the next wizard page when this item is selected.
|
|
259 |
* @param [in] psk indicates whether password needs to be queried.
|
31
|
260 |
*/
|
|
261 |
void WlanWizardPageSecurityMode::addToList(QStringList &list,
|
|
262 |
const QString &item, int mode, int page, bool psk)
|
|
263 |
{
|
43
|
264 |
OstTraceFunctionEntry0( WLANWIZARDPAGESECURITYMODE_ADDTOLIST_ENTRY );
|
39
|
265 |
if (mWizard->configurationExists(WlanWizardHelper::ConfAvailableNetworkOptions)) {
|
|
266 |
WlanNetworkSetting netMode;
|
|
267 |
netMode.mode = mWizard->configuration(WlanWizardPrivate::ConfNetworkMode).toInt();
|
|
268 |
netMode.hidden = mWizard->configuration(WlanWizardPrivate::ConfHiddenWlan).toBool();
|
43
|
269 |
netMode.wpsSupported = mWizard->configuration(WlanWizardPrivate::ConfWpsSupported).toBool();
|
39
|
270 |
WlanWizardScanList networkOptions = mWizard->configuration(
|
|
271 |
WlanWizardHelper::ConfAvailableNetworkOptions).value<WlanWizardScanList>();
|
|
272 |
|
|
273 |
for (int i = 0; i < networkOptions.secModes(netMode); i++) {
|
|
274 |
WlanSecuritySetting secMode = networkOptions.getSecMode(netMode, i);
|
43
|
275 |
|
39
|
276 |
if (secMode.mode == mode && secMode.usePsk == psk) {
|
|
277 |
list << item;
|
|
278 |
mSecModes.append(mode);
|
|
279 |
mPageIds.append(page);
|
|
280 |
mUsePsk.append(psk);
|
|
281 |
}
|
|
282 |
}
|
|
283 |
}
|
|
284 |
else {
|
|
285 |
list << item;
|
|
286 |
mSecModes.append(mode);
|
|
287 |
mPageIds.append(page);
|
|
288 |
mUsePsk.append(psk);
|
|
289 |
}
|
43
|
290 |
OstTraceFunctionExit0( WLANWIZARDPAGESECURITYMODE_ADDTOLIST_EXIT );
|
31
|
291 |
}
|