31
|
1 |
/*
|
53
|
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: Network mode Selection.
|
|
16 |
*/
|
31
|
17 |
|
|
18 |
// System includes
|
|
19 |
#include <HbDocumentLoader>
|
|
20 |
#include <HbWidget>
|
|
21 |
#include <HbRadioButtonList>
|
|
22 |
#include <HbMainWindow>
|
|
23 |
#include <HbLabel>
|
|
24 |
#include <cmmanagerdefines_shim.h>
|
|
25 |
|
|
26 |
// User includes
|
|
27 |
#include "wlanwizard_p.h"
|
|
28 |
#include "wlanwizard.h"
|
|
29 |
#include "wlanwizardpagenetworkmode.h"
|
39
|
30 |
#include "wlanwizardscanlist.h"
|
31
|
31 |
#include "OstTraceDefinitions.h"
|
|
32 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
33 |
#include "wlanwizardpagenetworkmodeTraces.h"
|
|
34 |
#endif
|
|
35 |
|
39
|
36 |
// Local constants
|
|
37 |
|
31
|
38 |
/*!
|
39
|
39 |
* Constructor method for the network mode view object
|
|
40 |
* @param parent [in] pointer to parent object.
|
31
|
41 |
*/
|
|
42 |
WlanWizardPageNetworkMode::WlanWizardPageNetworkMode(
|
|
43 |
WlanWizardPrivate* parent) :
|
|
44 |
WlanWizardPageInternal(parent),
|
|
45 |
mWidget(NULL),
|
|
46 |
mList(NULL),
|
|
47 |
mLabel(NULL),
|
61
|
48 |
mLoader(NULL)
|
31
|
49 |
{
|
43
|
50 |
OstTraceFunctionEntry0( WLANWIZARDPAGENETWORKMODE_WLANWIZARDPAGENETWORKMODE_ENTRY );
|
|
51 |
OstTraceFunctionExit0( WLANWIZARDPAGENETWORKMODE_WLANWIZARDPAGENETWORKMODE_EXIT );
|
31
|
52 |
}
|
|
53 |
|
|
54 |
/*!
|
|
55 |
* Destructor. Loader widget is deleted.
|
|
56 |
* All document widgets are deleted by wlanwizard_p destructor.
|
|
57 |
*/
|
|
58 |
WlanWizardPageNetworkMode::~WlanWizardPageNetworkMode()
|
|
59 |
{
|
43
|
60 |
OstTraceFunctionEntry0( DUP1_WLANWIZARDPAGENETWORKMODE_WLANWIZARDPAGENETWORKMODE_ENTRY );
|
31
|
61 |
delete mLoader;
|
43
|
62 |
OstTraceFunctionExit0( DUP1_WLANWIZARDPAGENETWORKMODE_WLANWIZARDPAGENETWORKMODE_EXIT );
|
31
|
63 |
}
|
|
64 |
|
|
65 |
/*!
|
|
66 |
* Page initialization. If view is already loaded, does nothing.
|
39
|
67 |
* Inherited from WlanWizardPage.
|
31
|
68 |
*/
|
|
69 |
HbWidget* WlanWizardPageNetworkMode::initializePage()
|
|
70 |
{
|
43
|
71 |
OstTraceFunctionEntry0( WLANWIZARDPAGENETWORKMODE_INITIALIZEPAGE_ENTRY );
|
31
|
72 |
OstTrace0( TRACE_NORMAL, WLANWIZARDPAGENETWORKMODE_INITIALIZEPAGE,
|
|
73 |
"WlanWizardPageNetworkMode::initializePage" );
|
|
74 |
|
|
75 |
if (mWidget == NULL) {
|
|
76 |
mLoader = new HbDocumentLoader(mWizard->mainWindow());
|
|
77 |
|
|
78 |
bool ok;
|
|
79 |
|
|
80 |
mLoader->load(":/docml/occ_add_wlan_02_03.docml", &ok);
|
39
|
81 |
Q_ASSERT(ok);
|
31
|
82 |
|
39
|
83 |
loadDocmlSection(mWizard->mainWindow()->orientation());
|
31
|
84 |
|
|
85 |
mWidget = qobject_cast<HbWidget*> (mLoader->findWidget(
|
|
86 |
"occ_add_wlan_02"));
|
39
|
87 |
Q_ASSERT(mWidget != NULL);
|
31
|
88 |
|
|
89 |
mList = qobject_cast<HbRadioButtonList*> (mLoader->findWidget("list"));
|
39
|
90 |
Q_ASSERT(mList != NULL);
|
31
|
91 |
|
|
92 |
mLabel = qobject_cast<HbLabel*> (mLoader->findWidget("dialog_6"));
|
39
|
93 |
Q_ASSERT(mLabel != NULL);
|
31
|
94 |
|
|
95 |
// Connect document loading to main window orientation changes.
|
61
|
96 |
ok = connect(
|
|
97 |
mWizard->mainWindow(),
|
|
98 |
SIGNAL(orientationChanged(Qt::Orientation)),
|
|
99 |
this,
|
39
|
100 |
SLOT(loadDocmlSection(Qt::Orientation)));
|
|
101 |
Q_ASSERT(ok);
|
|
102 |
|
31
|
103 |
// Connect a function to a radio button selection.
|
61
|
104 |
ok = connect(
|
|
105 |
mList,
|
|
106 |
SIGNAL(itemSelected(int)),
|
|
107 |
this,
|
39
|
108 |
SLOT(itemSelected()));
|
|
109 |
Q_ASSERT(ok);
|
31
|
110 |
|
|
111 |
mLabel->setPlainText(hbTrId(
|
|
112 |
"txt_occ_dialog_select_network_mode_and_status"));
|
|
113 |
}
|
39
|
114 |
|
61
|
115 |
QStringList items;
|
39
|
116 |
populateRadioButtonList(items);
|
61
|
117 |
|
|
118 |
// Do not override the list, if it didn't change, because setItems()
|
|
119 |
// clears the possible selected item.
|
|
120 |
if (items != mList->items()) {
|
|
121 |
mList->setItems(items);
|
|
122 |
}
|
39
|
123 |
|
43
|
124 |
OstTraceFunctionExit0( WLANWIZARDPAGENETWORKMODE_INITIALIZEPAGE_EXIT );
|
31
|
125 |
return mWidget;
|
|
126 |
}
|
|
127 |
|
|
128 |
/*!
|
39
|
129 |
* Evaluates the network mode selection and sets the configuration in
|
|
130 |
* the wlanwizard.
|
|
131 |
* @param [out] removeFromStack always returns false.
|
|
132 |
* @return WlanWizardPageSecurityMode page id.
|
31
|
133 |
*/
|
|
134 |
int WlanWizardPageNetworkMode::nextId(bool &removeFromStack) const
|
|
135 |
{
|
43
|
136 |
OstTraceFunctionEntry0( WLANWIZARDPAGENETWORKMODE_NEXTID_ENTRY );
|
31
|
137 |
removeFromStack = false;
|
39
|
138 |
WlanNetworkSetting setting;
|
43
|
139 |
int index = mList->selected();
|
|
140 |
int nextPage = WlanWizardPageInternal::PageNetworkSecurity;
|
31
|
141 |
|
43
|
142 |
if (mWpsSupported.at(index)) {
|
|
143 |
nextPage = WlanWizardPageInternal::PageWpsStart;
|
61
|
144 |
} else {
|
43
|
145 |
setting.mode = mNetworkModes.at(index);
|
|
146 |
setting.hidden = mIsHidden.at(index);
|
|
147 |
setting.wpsSupported = mWpsSupported.at(index);
|
|
148 |
|
53
|
149 |
mWizard->setConfiguration(
|
|
150 |
WlanWizardPrivate::ConfNetworkMode,
|
43
|
151 |
setting.mode);
|
31
|
152 |
|
53
|
153 |
mWizard->setConfiguration(
|
|
154 |
WlanWizardPrivate::ConfWlanScanSSID,
|
43
|
155 |
setting.hidden);
|
|
156 |
|
53
|
157 |
mWizard->setConfiguration(
|
|
158 |
WlanWizardPrivate::ConfWpsSupported,
|
43
|
159 |
setting.wpsSupported);
|
|
160 |
|
|
161 |
if (mWizard->configurationExists(WlanWizardPrivate::ConfAvailableNetworkOptions)) {
|
|
162 |
nextPage = selectNextPage(setting);
|
|
163 |
}
|
39
|
164 |
}
|
43
|
165 |
OstTraceFunctionExit0( WLANWIZARDPAGENETWORKMODE_NEXTID_EXIT );
|
|
166 |
return nextPage;
|
31
|
167 |
}
|
|
168 |
|
|
169 |
/*!
|
39
|
170 |
* This method is overrides the default implementation from WlanWizardPage.
|
61
|
171 |
* @return Should the Next-button be enabled or not.
|
31
|
172 |
*/
|
|
173 |
bool WlanWizardPageNetworkMode::showPage()
|
|
174 |
{
|
43
|
175 |
OstTraceFunctionEntry0( WLANWIZARDPAGENETWORKMODE_SHOWPAGE_ENTRY );
|
|
176 |
OstTraceFunctionExit0( WLANWIZARDPAGENETWORKMODE_SHOWPAGE_EXIT );
|
61
|
177 |
// Next-button is enabled whenever the radio button list has some value
|
|
178 |
// selected.
|
|
179 |
return mList->selected() != -1;
|
31
|
180 |
}
|
|
181 |
|
|
182 |
/*!
|
39
|
183 |
* This function is invoked when user selects a mode from the radio button list.
|
|
184 |
* (HbRadioButtonList's itemSelected-signal)
|
31
|
185 |
*/
|
39
|
186 |
void WlanWizardPageNetworkMode::itemSelected()
|
31
|
187 |
{
|
43
|
188 |
OstTraceFunctionEntry0( WLANWIZARDPAGENETWORKMODE_ITEMSELECTED_ENTRY );
|
31
|
189 |
OstTrace0( TRACE_BORDER, WLANWIZARDPAGENETWORKMODE_ITEMSELECTED,
|
|
190 |
"WlanWizardPageNetworkMode::itemSelected" );
|
|
191 |
|
61
|
192 |
mWizard->enableNextButton(true);
|
43
|
193 |
OstTraceFunctionExit0( WLANWIZARDPAGENETWORKMODE_ITEMSELECTED_EXIT );
|
31
|
194 |
}
|
|
195 |
|
|
196 |
/*!
|
39
|
197 |
* Loads the document orientation information from occ_add_wlan_02_03.docml.
|
|
198 |
* This is called each time phone orientation changes.
|
|
199 |
* @param [in] orientation indicates whether the phone is in portrait or
|
|
200 |
* landscape mode.
|
31
|
201 |
*/
|
39
|
202 |
void WlanWizardPageNetworkMode::loadDocmlSection(Qt::Orientation orientation)
|
31
|
203 |
{
|
43
|
204 |
OstTraceFunctionEntry0( WLANWIZARDPAGENETWORKMODE_LOADDOCMLSECTION_ENTRY );
|
31
|
205 |
OstTrace1( TRACE_NORMAL, WLANWIZARDPAGENETWORKMODE_LOADDOCML,
|
|
206 |
"WlanWizardPageNetworkMode::loadDocml - Orientation;orientation=%x",
|
|
207 |
( TUint )( orientation ) );
|
|
208 |
|
39
|
209 |
WlanWizardPageInternal::loadDocmlSection(
|
|
210 |
mLoader,
|
|
211 |
orientation,
|
|
212 |
":/docml/occ_add_wlan_02_03.docml",
|
|
213 |
"portrait_section",
|
|
214 |
"landscape_section");
|
43
|
215 |
OstTraceFunctionExit0( WLANWIZARDPAGENETWORKMODE_LOADDOCMLSECTION_EXIT );
|
39
|
216 |
}
|
|
217 |
|
|
218 |
/*!
|
|
219 |
* A support function to map the radio button list to a generic network
|
|
220 |
* mode list. This enables the changing of button order without it
|
|
221 |
* affecting the entire class.
|
|
222 |
* In case previous scan has revealed multiple results with the same ssid, only
|
|
223 |
* available network mode options are shown in the radio button list.
|
|
224 |
* @param [out] list is the list of captions used for the radio buttons.
|
|
225 |
* @param [in] item is the caption to be added.
|
|
226 |
* @param [in] mode is the network mode to be added.
|
|
227 |
* @param [in] isHidden is the visibility status of the network.
|
43
|
228 |
* @param [in] wpsSupported is the possibility for wps support.
|
39
|
229 |
*/
|
43
|
230 |
void WlanWizardPageNetworkMode::addToList(
|
|
231 |
QStringList &list,
|
|
232 |
const QString &item,
|
|
233 |
int mode,
|
|
234 |
bool isHidden,
|
|
235 |
bool wpsSupported)
|
39
|
236 |
{
|
43
|
237 |
OstTraceFunctionEntry0( WLANWIZARDPAGENETWORKMODE_ADDTOLIST_ENTRY );
|
39
|
238 |
|
|
239 |
if (mWizard->configurationExists(WlanWizardHelper::ConfAvailableNetworkOptions)) {
|
|
240 |
WlanWizardScanList networkOptions = mWizard->configuration(
|
|
241 |
WlanWizardHelper::ConfAvailableNetworkOptions).value<WlanWizardScanList> ();
|
|
242 |
|
|
243 |
QList<WlanNetworkSetting> modes = networkOptions.getNetModes();
|
|
244 |
|
|
245 |
for (int i = 0; i < modes.size(); i++) {
|
43
|
246 |
if ( (modes[i].mode == mode
|
|
247 |
&& modes[i].hidden == isHidden
|
|
248 |
&& modes[i].wpsSupported == wpsSupported)
|
|
249 |
|| (modes[i].wpsSupported && wpsSupported) ) {
|
39
|
250 |
list << item;
|
|
251 |
mNetworkModes.append(mode);
|
|
252 |
mIsHidden.append(isHidden);
|
43
|
253 |
mWpsSupported.append(wpsSupported);
|
39
|
254 |
}
|
|
255 |
}
|
61
|
256 |
} else {
|
39
|
257 |
list << item;
|
|
258 |
mNetworkModes.append(mode);
|
|
259 |
mIsHidden.append(isHidden);
|
43
|
260 |
// If there are no known network options, WPS is not allowed to be
|
|
261 |
// selected.
|
|
262 |
mWpsSupported.append(false);
|
31
|
263 |
}
|
43
|
264 |
OstTraceFunctionExit0( WLANWIZARDPAGENETWORKMODE_ADDTOLIST_EXIT );
|
31
|
265 |
}
|
|
266 |
|
|
267 |
/*!
|
39
|
268 |
* This function checks the sets up the radio button list for user input.
|
|
269 |
* @param [out] list is the list of captions used for the radio buttons.
|
31
|
270 |
*/
|
39
|
271 |
void WlanWizardPageNetworkMode::populateRadioButtonList(QStringList &list)
|
31
|
272 |
{
|
43
|
273 |
OstTraceFunctionEntry0( WLANWIZARDPAGENETWORKMODE_POPULATERADIOBUTTONLIST_ENTRY );
|
39
|
274 |
list.clear();
|
|
275 |
mNetworkModes.clear();
|
|
276 |
mIsHidden.clear();
|
43
|
277 |
mWpsSupported.clear();
|
39
|
278 |
|
61
|
279 |
addToList(
|
|
280 |
list,
|
|
281 |
hbTrId("txt_occ_dblist_val_infrastructure_public"),
|
|
282 |
CMManagerShim::Infra,
|
|
283 |
false,
|
|
284 |
false);
|
39
|
285 |
|
61
|
286 |
addToList(
|
|
287 |
list,
|
|
288 |
hbTrId("txt_occ_list_infrastructure_hidden"),
|
|
289 |
CMManagerShim::Infra,
|
|
290 |
true,
|
|
291 |
false);
|
39
|
292 |
|
61
|
293 |
addToList(
|
|
294 |
list,
|
|
295 |
hbTrId("txt_occ_list_adhoc_1"),
|
|
296 |
CMManagerShim::Adhoc,
|
|
297 |
false,
|
|
298 |
false);
|
43
|
299 |
|
|
300 |
if (mWizard->configurationExists(WlanWizardHelper::ConfAvailableNetworkOptions)) {
|
|
301 |
// addToList with wpsSupported=true is only called, when there are available
|
|
302 |
// scan result options. If no network options exist, the user can not get to
|
|
303 |
// wps wizard from this view. Also, mode and isHidden are "don't care".
|
|
304 |
addToList(list, hbTrId("txt_occ_list_wifi_protected_setup"), NetworkModeNone, false, true);
|
|
305 |
}
|
|
306 |
OstTraceFunctionExit0( WLANWIZARDPAGENETWORKMODE_POPULATERADIOBUTTONLIST_EXIT );
|
31
|
307 |
}
|
|
308 |
|
39
|
309 |
/*!
|
|
310 |
* This function selects the next page. Security mode may be skipped in case
|
|
311 |
* scan results exist and only single option remains.
|
|
312 |
* @param [in] setting indicates the selected network mode.
|
|
313 |
* @return Security mode query page identifier unless it can be skipped.
|
|
314 |
*/
|
|
315 |
int WlanWizardPageNetworkMode::selectNextPage(const WlanNetworkSetting &setting) const
|
|
316 |
{
|
43
|
317 |
OstTraceFunctionEntry0( WLANWIZARDPAGENETWORKMODE_SELECTNEXTPAGE_ENTRY );
|
|
318 |
|
|
319 |
int nextPage = WlanWizardPageInternal::PageNetworkSecurity;
|
|
320 |
|
39
|
321 |
WlanWizardScanList networkOptions = mWizard->configuration(
|
|
322 |
WlanWizardHelper::ConfAvailableNetworkOptions).value<WlanWizardScanList>();
|
43
|
323 |
|
39
|
324 |
if (networkOptions.secModes(setting) == SingleResult) {
|
|
325 |
WlanSecuritySetting secMode = networkOptions.getSecMode(setting);
|
|
326 |
mWizard->setConfiguration(WlanWizardHelper::ConfSecurityMode, secMode.mode);
|
|
327 |
mWizard->setConfiguration(WlanWizardHelper::ConfUsePsk, secMode.usePsk);
|
43
|
328 |
nextPage = secMode.nextPageId;
|
39
|
329 |
}
|
|
330 |
|
43
|
331 |
OstTraceFunctionExit0( DUP1_WLANWIZARDPAGENETWORKMODE_SELECTNEXTPAGE_EXIT );
|
|
332 |
return nextPage;
|
39
|
333 |
}
|