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: Network 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 "wlanwizardpagenetworkmode.h"
|
39
|
31 |
#include "wlanwizardscanlist.h"
|
31
|
32 |
#include "OstTraceDefinitions.h"
|
|
33 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
34 |
#include "wlanwizardpagenetworkmodeTraces.h"
|
|
35 |
#endif
|
|
36 |
|
39
|
37 |
// Local constants
|
|
38 |
|
31
|
39 |
/*!
|
39
|
40 |
* Constructor method for the network mode view object
|
|
41 |
* @param parent [in] pointer to parent object.
|
31
|
42 |
*/
|
|
43 |
WlanWizardPageNetworkMode::WlanWizardPageNetworkMode(
|
|
44 |
WlanWizardPrivate* parent) :
|
|
45 |
WlanWizardPageInternal(parent),
|
|
46 |
mWidget(NULL),
|
|
47 |
mList(NULL),
|
|
48 |
mLabel(NULL),
|
|
49 |
mLoader(NULL),
|
|
50 |
mValid(false)
|
|
51 |
{
|
|
52 |
}
|
|
53 |
|
|
54 |
/*!
|
|
55 |
* Destructor. Loader widget is deleted.
|
|
56 |
* All document widgets are deleted by wlanwizard_p destructor.
|
|
57 |
*/
|
|
58 |
WlanWizardPageNetworkMode::~WlanWizardPageNetworkMode()
|
|
59 |
{
|
|
60 |
delete mLoader;
|
|
61 |
}
|
|
62 |
|
|
63 |
/*!
|
|
64 |
* Page initialization. If view is already loaded, does nothing.
|
39
|
65 |
* Inherited from WlanWizardPage.
|
31
|
66 |
*/
|
|
67 |
HbWidget* WlanWizardPageNetworkMode::initializePage()
|
|
68 |
{
|
|
69 |
OstTrace0( TRACE_NORMAL, WLANWIZARDPAGENETWORKMODE_INITIALIZEPAGE,
|
|
70 |
"WlanWizardPageNetworkMode::initializePage" );
|
|
71 |
|
|
72 |
if (mWidget == NULL) {
|
|
73 |
mLoader = new HbDocumentLoader(mWizard->mainWindow());
|
|
74 |
|
|
75 |
bool ok;
|
|
76 |
|
|
77 |
mLoader->load(":/docml/occ_add_wlan_02_03.docml", &ok);
|
39
|
78 |
Q_ASSERT(ok);
|
31
|
79 |
|
39
|
80 |
loadDocmlSection(mWizard->mainWindow()->orientation());
|
31
|
81 |
|
|
82 |
mWidget = qobject_cast<HbWidget*> (mLoader->findWidget(
|
|
83 |
"occ_add_wlan_02"));
|
39
|
84 |
Q_ASSERT(mWidget != NULL);
|
31
|
85 |
|
|
86 |
mList = qobject_cast<HbRadioButtonList*> (mLoader->findWidget("list"));
|
39
|
87 |
Q_ASSERT(mList != NULL);
|
31
|
88 |
|
|
89 |
mLabel = qobject_cast<HbLabel*> (mLoader->findWidget("dialog_6"));
|
39
|
90 |
Q_ASSERT(mLabel != NULL);
|
31
|
91 |
|
|
92 |
// Connect document loading to main window orientation changes.
|
39
|
93 |
ok = connect(mWizard->mainWindow(),
|
31
|
94 |
SIGNAL(orientationChanged(Qt::Orientation)), this,
|
39
|
95 |
SLOT(loadDocmlSection(Qt::Orientation)));
|
|
96 |
Q_ASSERT(ok);
|
|
97 |
|
31
|
98 |
// Connect a function to a radio button selection.
|
39
|
99 |
ok = connect(mList, SIGNAL(itemSelected(int)), this,
|
|
100 |
SLOT(itemSelected()));
|
|
101 |
Q_ASSERT(ok);
|
31
|
102 |
|
|
103 |
mLabel->setPlainText(hbTrId(
|
|
104 |
"txt_occ_dialog_select_network_mode_and_status"));
|
|
105 |
}
|
39
|
106 |
|
|
107 |
QStringList items;
|
|
108 |
|
|
109 |
populateRadioButtonList(items);
|
|
110 |
|
|
111 |
mList->setItems(items);
|
|
112 |
|
31
|
113 |
return mWidget;
|
|
114 |
}
|
|
115 |
|
|
116 |
/*!
|
39
|
117 |
* Evaluates the network mode selection and sets the configuration in
|
|
118 |
* the wlanwizard.
|
|
119 |
* @param [out] removeFromStack always returns false.
|
|
120 |
* @return WlanWizardPageSecurityMode page id.
|
31
|
121 |
*/
|
|
122 |
int WlanWizardPageNetworkMode::nextId(bool &removeFromStack) const
|
|
123 |
{
|
|
124 |
removeFromStack = false;
|
39
|
125 |
WlanNetworkSetting setting;
|
|
126 |
setting.mode = mNetworkModes.at(mList->selected());
|
|
127 |
setting.hidden = mIsHidden.at(mList->selected());
|
|
128 |
|
|
129 |
// TODO: Still no wps handling.
|
|
130 |
setting.wpsSupported = false;
|
|
131 |
|
31
|
132 |
mWizard->setConfiguration(WlanWizardPrivate::ConfNetworkMode,
|
39
|
133 |
setting.mode);
|
31
|
134 |
|
|
135 |
mWizard->setConfiguration(WlanWizardPrivate::ConfHiddenWlan,
|
39
|
136 |
setting.hidden);
|
31
|
137 |
|
39
|
138 |
if (mWizard->configurationExists(WlanWizardPrivate::ConfAvailableNetworkOptions)) {
|
|
139 |
return selectNextPage(setting);
|
|
140 |
}
|
|
141 |
|
31
|
142 |
return WlanWizardPageInternal::PageNetworkSecurity;
|
|
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 mValid, which is true if a radio button has been selected.
|
31
|
149 |
*/
|
|
150 |
bool WlanWizardPageNetworkMode::showPage()
|
|
151 |
{
|
|
152 |
return mValid;
|
|
153 |
}
|
|
154 |
|
|
155 |
/*!
|
39
|
156 |
* This function is invoked when user selects a mode from the radio button list.
|
|
157 |
* (HbRadioButtonList's itemSelected-signal)
|
31
|
158 |
*/
|
39
|
159 |
void WlanWizardPageNetworkMode::itemSelected()
|
31
|
160 |
{
|
|
161 |
OstTrace0( TRACE_BORDER, WLANWIZARDPAGENETWORKMODE_ITEMSELECTED,
|
|
162 |
"WlanWizardPageNetworkMode::itemSelected" );
|
|
163 |
|
|
164 |
mValid = true;
|
|
165 |
mWizard->enableNextButton(mValid);
|
|
166 |
}
|
|
167 |
|
|
168 |
/*!
|
39
|
169 |
* Loads the document orientation information from occ_add_wlan_02_03.docml.
|
|
170 |
* This is called each time phone orientation changes.
|
|
171 |
* @param [in] orientation indicates whether the phone is in portrait or
|
|
172 |
* landscape mode.
|
31
|
173 |
*/
|
39
|
174 |
void WlanWizardPageNetworkMode::loadDocmlSection(Qt::Orientation orientation)
|
31
|
175 |
{
|
|
176 |
OstTrace1( TRACE_NORMAL, WLANWIZARDPAGENETWORKMODE_LOADDOCML,
|
|
177 |
"WlanWizardPageNetworkMode::loadDocml - Orientation;orientation=%x",
|
|
178 |
( TUint )( orientation ) );
|
|
179 |
|
39
|
180 |
WlanWizardPageInternal::loadDocmlSection(
|
|
181 |
mLoader,
|
|
182 |
orientation,
|
|
183 |
":/docml/occ_add_wlan_02_03.docml",
|
|
184 |
"portrait_section",
|
|
185 |
"landscape_section");
|
|
186 |
}
|
|
187 |
|
|
188 |
/*!
|
|
189 |
* A support function to map the radio button list to a generic network
|
|
190 |
* mode list. This enables the changing of button order without it
|
|
191 |
* affecting the entire class.
|
|
192 |
* In case previous scan has revealed multiple results with the same ssid, only
|
|
193 |
* available network mode options are shown in the radio button list.
|
|
194 |
* @param [out] list is the list of captions used for the radio buttons.
|
|
195 |
* @param [in] item is the caption to be added.
|
|
196 |
* @param [in] mode is the network mode to be added.
|
|
197 |
* @param [in] isHidden is the visibility status of the network.
|
|
198 |
*/
|
|
199 |
void WlanWizardPageNetworkMode::addToList(QStringList &list,
|
|
200 |
const QString &item, int mode, bool isHidden)
|
|
201 |
{
|
|
202 |
|
|
203 |
if (mWizard->configurationExists(WlanWizardHelper::ConfAvailableNetworkOptions)) {
|
|
204 |
WlanWizardScanList networkOptions = mWizard->configuration(
|
|
205 |
WlanWizardHelper::ConfAvailableNetworkOptions).value<WlanWizardScanList> ();
|
|
206 |
|
|
207 |
QList<WlanNetworkSetting> modes = networkOptions.getNetModes();
|
|
208 |
|
|
209 |
for (int i = 0; i < modes.size(); i++) {
|
|
210 |
if (modes[i].mode == mode && modes[i].hidden == isHidden) {
|
|
211 |
list << item;
|
|
212 |
mNetworkModes.append(mode);
|
|
213 |
mIsHidden.append(isHidden);
|
|
214 |
}
|
|
215 |
}
|
31
|
216 |
}
|
39
|
217 |
else {
|
|
218 |
list << item;
|
|
219 |
mNetworkModes.append(mode);
|
|
220 |
mIsHidden.append(isHidden);
|
31
|
221 |
}
|
|
222 |
}
|
|
223 |
|
|
224 |
/*!
|
39
|
225 |
* This function checks the sets up the radio button list for user input.
|
|
226 |
* @param [out] list is the list of captions used for the radio buttons.
|
31
|
227 |
*/
|
39
|
228 |
void WlanWizardPageNetworkMode::populateRadioButtonList(QStringList &list)
|
31
|
229 |
{
|
39
|
230 |
list.clear();
|
|
231 |
mNetworkModes.clear();
|
|
232 |
mIsHidden.clear();
|
|
233 |
|
|
234 |
// A list is created. Since there is no practical way of knowing whether
|
|
235 |
// the new contents are different from the previous contents (if there
|
|
236 |
// even were any in the first place) the validity is always reset.
|
|
237 |
mValid = false;
|
|
238 |
|
|
239 |
addToList(list, hbTrId("txt_occ_dblist_val_infrastructure_public"),
|
|
240 |
CMManagerShim::Infra, false);
|
|
241 |
|
|
242 |
addToList(list, hbTrId("txt_occ_list_infrastructure_hidden"),
|
|
243 |
CMManagerShim::Infra, true);
|
|
244 |
|
|
245 |
addToList(list, hbTrId("txt_occ_list_adhoc_1"), CMManagerShim::Adhoc,
|
|
246 |
false);
|
31
|
247 |
}
|
|
248 |
|
39
|
249 |
/*!
|
|
250 |
* This function selects the next page. Security mode may be skipped in case
|
|
251 |
* scan results exist and only single option remains.
|
|
252 |
* @param [in] setting indicates the selected network mode.
|
|
253 |
* @return Security mode query page identifier unless it can be skipped.
|
|
254 |
*/
|
|
255 |
int WlanWizardPageNetworkMode::selectNextPage(const WlanNetworkSetting &setting) const
|
|
256 |
{
|
|
257 |
WlanWizardScanList networkOptions = mWizard->configuration(
|
|
258 |
WlanWizardHelper::ConfAvailableNetworkOptions).value<WlanWizardScanList>();
|
|
259 |
|
|
260 |
if (networkOptions.secModes(setting) == SingleResult) {
|
|
261 |
WlanSecuritySetting secMode = networkOptions.getSecMode(setting);
|
|
262 |
|
|
263 |
mWizard->setConfiguration(WlanWizardHelper::ConfSecurityMode, secMode.mode);
|
|
264 |
mWizard->setConfiguration(WlanWizardHelper::ConfUsePsk, secMode.usePsk);
|
|
265 |
return secMode.nextPageId;
|
|
266 |
}
|
|
267 |
|
|
268 |
return WlanWizardPageInternal::PageNetworkSecurity;
|
|
269 |
}
|
|
270 |
|