26
|
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
|
34
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
26
|
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 |
* Private Implementation for Control Panel QT UI for WPA/WPA2/802_Dot_1x configuration
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
/*
|
47
|
20 |
* %version: tr1cfwln#14 %
|
26
|
21 |
*/
|
|
22 |
|
|
23 |
// User Includes
|
|
24 |
#include "cpwpacmnui_p.h"
|
|
25 |
#include "wpakeyvalidator.h"
|
|
26 |
#include "cpwpacmneapui.h"
|
|
27 |
|
|
28 |
// System Includes
|
|
29 |
#include <QStringList>
|
|
30 |
#include <cpsettingformitemdata.h>
|
|
31 |
#include <cpitemdatahelper.h>
|
|
32 |
#include <cmconnectionmethod_shim.h>
|
|
33 |
#include <eapqtplugininfo.h>
|
|
34 |
#include <eapqtpluginhandle.h>
|
|
35 |
#include <eapqtconfiginterface.h>
|
|
36 |
#include <HbLineEdit>
|
|
37 |
#include <HbEditorInterface>
|
|
38 |
|
|
39 |
// Trace Definition
|
|
40 |
#include "OstTraceDefinitions.h"
|
|
41 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
42 |
#include "cpwpacmnui_pTraces.h"
|
|
43 |
#endif
|
|
44 |
|
|
45 |
|
|
46 |
/*!
|
|
47 |
\class CpWpaCmnUiPrivate
|
|
48 |
\brief CpWpaCmnUiPrivate is a private class implementation the common Ui for WPA/WPA2/802.1x/WPA2 only
|
|
49 |
Security Settings Control Panel Plugins,
|
|
50 |
which will allow viewing/editing of WPA/WPA2/802.1x/WPA2 Security Settings.
|
|
51 |
*/
|
|
52 |
/*!
|
|
53 |
* Constructor Common Ui (WPA/WPA2/802.1x/WPA2only) object
|
|
54 |
*
|
|
55 |
* \param securityMode chosen by user , for which Ui is constructed and returned
|
|
56 |
* \param dataHelpper Control Panel Item data helpper object
|
|
57 |
* \param commonUi Pointer To public class for CpWpaCmnUiPrivate
|
|
58 |
*/
|
|
59 |
CpWpaCmnUiPrivate::CpWpaCmnUiPrivate(CMManagerShim::WlanSecMode securityMode,
|
|
60 |
CpItemDataHelper &dataHelpper) :
|
|
61 |
mDataHelper(dataHelpper),
|
|
62 |
mCmnUi(NULL),
|
|
63 |
mPskKeyText(NULL),
|
|
64 |
mEapPlugins(NULL),
|
|
65 |
mUnencryptedConnection(NULL),
|
|
66 |
mWpaEapItem(NULL),
|
|
67 |
mEapEntry(NULL),
|
|
68 |
mEapQtConfigInterface(NULL),
|
|
69 |
mSecurityMode(securityMode),
|
|
70 |
mConnMethod(NULL),
|
|
71 |
mEnablePskMode(true),
|
|
72 |
mCurrentEapPlugin(0),
|
|
73 |
mUnencryptState(false)
|
|
74 |
{
|
|
75 |
Q_ASSERT(
|
|
76 |
mSecurityMode == CMManagerShim::WlanSecModeWpa ||
|
|
77 |
mSecurityMode == CMManagerShim::WlanSecModeWpa2 ||
|
|
78 |
mSecurityMode == CMManagerShim::WlanSecMode802_1x);
|
|
79 |
OstTrace1( TRACE_FLOW, DUP1_CPWPACMNUIPRIVATE_CPWPACMNUIPRIVATE, "CpWpaCmnUiPrivate::CpWpaCmnUiPrivate;mSecurityMode=%u", mSecurityMode );
|
|
80 |
|
|
81 |
}
|
|
82 |
|
|
83 |
/*!
|
|
84 |
* Destructor - Deletes objects owned by Common Ui
|
|
85 |
*/
|
|
86 |
CpWpaCmnUiPrivate::~CpWpaCmnUiPrivate()
|
|
87 |
{
|
|
88 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_CPWPACMNUIPRIVATE_ENTRY, this );
|
|
89 |
//delete all dynamically allocated objects
|
|
90 |
|
|
91 |
mCmnUi = NULL;
|
|
92 |
mConnMethod = NULL;
|
|
93 |
|
|
94 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_CPWPACMNUIPRIVATE_EXIT, this );
|
|
95 |
}
|
|
96 |
|
|
97 |
// ======== MEMBER FUNCTIONS ========
|
|
98 |
|
|
99 |
/*!
|
|
100 |
* Creates the Ui instance based on the security mode;WPAWPA2/802.1x/WPA2 only
|
|
101 |
* Owns the Ui instance
|
|
102 |
*
|
|
103 |
* \param eapQtConfigInterface to list all eap plugins
|
|
104 |
* \param mCmCM Connection MethoD Qt interface
|
|
105 |
*
|
|
106 |
* \return Ui instance for the security mode set
|
|
107 |
*/
|
|
108 |
|
|
109 |
CpSettingFormItemData* CpWpaCmnUiPrivate::createUi(
|
|
110 |
EapQtConfigInterface *eapQtConfigInterface,
|
|
111 |
CmConnectionMethodShim *cmCM)
|
|
112 |
{
|
|
113 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_CREATEUI_ENTRY, this );
|
|
114 |
|
|
115 |
// NOT OWNED
|
|
116 |
mConnMethod = cmCM;
|
|
117 |
mEapQtConfigInterface = eapQtConfigInterface;
|
|
118 |
mPlugins.append(mEapQtConfigInterface->supportedOuterTypes());
|
|
119 |
qSort(mPlugins.begin(), mPlugins.end(), CpWpaCmnUiPrivate::pluginLessThan);
|
|
120 |
|
|
121 |
mCmnUi = new CpSettingFormItemData(HbDataFormModelItem::GroupItem,
|
|
122 |
hbTrId("txt_occ_subhead_security_settings"));
|
|
123 |
|
47
|
124 |
mCmnUi->setContentWidgetData("objectName", "CpWpaCmUi");
|
|
125 |
|
26
|
126 |
//LoadUi based on the security mode
|
|
127 |
loadUi();
|
|
128 |
|
|
129 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_CREATEUI_EXIT, this );
|
|
130 |
return mCmnUi;
|
|
131 |
}
|
|
132 |
|
|
133 |
/*!
|
|
134 |
Load the CpSettingFormItemData components,for the
|
|
135 |
EAP mode
|
|
136 |
*/
|
|
137 |
CpBaseSettingView* CpWpaCmnUiPrivate::eapUiInstance()
|
|
138 |
{
|
|
139 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_EAPUIINSTANCE_ENTRY, this );
|
|
140 |
|
|
141 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_EAPUIINSTANCE_EXIT, this );
|
|
142 |
return mEapQtConfigInterface->uiInstance(EapQtPluginHandle::PluginUndefined,
|
|
143 |
mPlugins.at(mCurrentEapPlugin).pluginHandle());
|
|
144 |
}
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
/*!
|
|
149 |
* Creates Combo box for PSK and EAP mode selection.
|
|
150 |
*
|
|
151 |
* @return CompoBox object.
|
|
152 |
*/
|
|
153 |
CpSettingFormItemData* CpWpaCmnUiPrivate::createWpaTypeSelector()
|
|
154 |
{
|
|
155 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_CREATEWPATYPESELECTOR_ENTRY, this );
|
|
156 |
|
|
157 |
// In case of the object exists just update the data
|
|
158 |
if (!mWpaEapItem) {
|
|
159 |
mWpaEapItem = new CpSettingFormItemData(
|
47
|
160 |
HbDataFormModelItem::ComboBoxItem,
|
|
161 |
hbTrId("txt_occ_setlabel_wpawpa2"));
|
26
|
162 |
|
|
163 |
QStringList wpatype;
|
|
164 |
wpatype.append(hbTrId("txt_occ_setlabel_wpawpa2_val_eap"));
|
|
165 |
wpatype.append(hbTrId("txt_occ_setlabel_wpawpa2_val_preshared_key"));
|
|
166 |
|
47
|
167 |
mWpaEapItem->setContentWidgetData("objectName", "CpWpaCmnUiTypeSelector");
|
26
|
168 |
mWpaEapItem->setContentWidgetData("items", wpatype);
|
|
169 |
|
|
170 |
mDataHelper.addConnection(mWpaEapItem,
|
47
|
171 |
SIGNAL(currentIndexChanged(int)), this,
|
|
172 |
SLOT(wpaTypeChanged(int)));
|
26
|
173 |
|
|
174 |
mCmnUi->appendChild(mWpaEapItem);
|
|
175 |
}
|
|
176 |
|
|
177 |
mWpaEapItem->setContentWidgetData("currentIndex", mEnablePskMode ? 1 : 0);
|
|
178 |
|
|
179 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_CREATEWPATYPESELECTOR_EXIT, this );
|
|
180 |
return mWpaEapItem;
|
|
181 |
}
|
|
182 |
|
|
183 |
/*!
|
|
184 |
* Creates LineEditor for WPA-PSK
|
|
185 |
*
|
|
186 |
* @return LineEdit object.
|
|
187 |
*/
|
|
188 |
CpSettingFormItemData* CpWpaCmnUiPrivate::createPskEditor()
|
|
189 |
{
|
|
190 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_CREATEPSKEDITOR_ENTRY, this );
|
|
191 |
|
|
192 |
if (!mPskKeyText) {
|
|
193 |
mPskKeyText = new CpSettingFormItemData(
|
47
|
194 |
HbDataFormModelItem::TextItem,
|
|
195 |
hbTrId("txt_occ_setlabel_preshared_key"));
|
26
|
196 |
|
47
|
197 |
mPskKeyText->setContentWidgetData("objectName", "CpWpaCmnUiPskEditor");
|
26
|
198 |
mPskKeyText->setContentWidgetData("echoMode", HbLineEdit::PasswordEchoOnEdit);
|
|
199 |
mPskKeyText->setContentWidgetData("smileysEnabled", "false");
|
47
|
200 |
mDataHelper.addConnection(
|
|
201 |
mPskKeyText, SIGNAL( editingFinished ()),
|
|
202 |
this, SLOT(pskKeyChanged() ));
|
26
|
203 |
|
47
|
204 |
mDataHelper.connectToForm(
|
|
205 |
SIGNAL(itemShown (const QModelIndex &) ),
|
|
206 |
this, SLOT(setEditorPreferences(const QModelIndex &)));
|
26
|
207 |
|
|
208 |
mCmnUi->appendChild(mPskKeyText);
|
|
209 |
}
|
|
210 |
|
|
211 |
mPskKeyText->setContentWidgetData("text", mKeyData);
|
|
212 |
|
|
213 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_CREATEPSKEDITOR_EXIT, this );
|
|
214 |
return mPskKeyText;
|
|
215 |
}
|
|
216 |
|
|
217 |
/*!
|
|
218 |
* Creates Combo box for EAP outer type selection
|
|
219 |
*
|
|
220 |
* @return CompoBox object.
|
|
221 |
*/
|
|
222 |
CpSettingFormItemData* CpWpaCmnUiPrivate::createEapSelector()
|
|
223 |
{
|
|
224 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_CREATEEAPSELECTOR_ENTRY, this );
|
|
225 |
|
|
226 |
if (!mEapPlugins) {
|
|
227 |
mEapPlugins = new CpSettingFormItemData(
|
|
228 |
HbDataFormModelItem::ComboBoxItem,
|
|
229 |
hbTrId("txt_occ_setlabel_eap_type"));
|
|
230 |
|
|
231 |
QStringList list;
|
|
232 |
QList<EapQtPluginInfo>::iterator i;
|
|
233 |
for (i = mPlugins.begin() ; i != mPlugins.end() ; ++i){
|
|
234 |
list << i->localizationId();
|
|
235 |
}
|
|
236 |
|
47
|
237 |
mEapPlugins->setContentWidgetData("objectName", "CpWpaCmnUiEapTypeSelector");
|
26
|
238 |
mEapPlugins->setContentWidgetData("items", list);
|
|
239 |
|
|
240 |
mDataHelper.addConnection(mEapPlugins,
|
|
241 |
SIGNAL(currentIndexChanged(int)), this,
|
|
242 |
SLOT(eapTypeChanged(int)));
|
|
243 |
|
|
244 |
mCmnUi->appendChild(mEapPlugins);
|
|
245 |
}
|
|
246 |
|
|
247 |
mEapPlugins->setContentWidgetData("currentIndex", mCurrentEapPlugin);
|
|
248 |
|
|
249 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_CREATEEAPSELECTOR_EXIT, this );
|
|
250 |
return mEapPlugins;
|
|
251 |
}
|
|
252 |
|
|
253 |
/*!
|
|
254 |
* Creates a button for EAP configurations
|
|
255 |
*
|
|
256 |
* @return EntryItem for EAP
|
|
257 |
*/
|
|
258 |
EapEntryItemData* CpWpaCmnUiPrivate::createEapEntryItem()
|
|
259 |
{
|
|
260 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_CREATEEAPENTRYITEM_ENTRY, this );
|
|
261 |
|
|
262 |
if (!mEapEntry) {
|
47
|
263 |
mEapEntry = new EapEntryItemData(
|
|
264 |
this,
|
|
265 |
mDataHelper,
|
|
266 |
hbTrId("txt_occ_button_eap_type_settings"));
|
26
|
267 |
|
47
|
268 |
mEapEntry->setContentWidgetData("objectName", "CpWpaCmnUiEapEntryItem");
|
26
|
269 |
mCmnUi->appendChild(mEapEntry);
|
|
270 |
}
|
|
271 |
|
|
272 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_CREATEEAPENTRYITEM_EXIT, this );
|
|
273 |
return mEapEntry;
|
|
274 |
}
|
|
275 |
|
|
276 |
/*!
|
|
277 |
* Creates Combo box for Unencrypted selection
|
|
278 |
*
|
|
279 |
* @return CompoBox object.
|
|
280 |
*/
|
|
281 |
CpSettingFormItemData* CpWpaCmnUiPrivate::createUnencryptedBox()
|
|
282 |
{
|
|
283 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_CREATEUNENCRYPTEDBOX_ENTRY, this );
|
|
284 |
|
|
285 |
if (!mUnencryptedConnection) {
|
|
286 |
mUnencryptedConnection = new CpSettingFormItemData(
|
47
|
287 |
HbDataFormModelItem::CheckBoxItem,
|
|
288 |
hbTrId("txt_occ_setlabel_unencrypted_connection"));
|
26
|
289 |
|
47
|
290 |
mUnencryptedConnection->setContentWidgetData(
|
|
291 |
"objectName",
|
|
292 |
"CpWpaCmnUiUnencryptedConnection");
|
26
|
293 |
mUnencryptedConnection->setContentWidgetData("text", hbTrId(
|
|
294 |
"txt_occ_setlabel_unencrypted_connection_val_allowe"));
|
|
295 |
|
|
296 |
mDataHelper.addConnection(mUnencryptedConnection,
|
|
297 |
SIGNAL( stateChanged(int)), this,
|
|
298 |
SLOT(unencryptConnStateChanged(int)));
|
|
299 |
|
|
300 |
mCmnUi->appendChild(mUnencryptedConnection);
|
|
301 |
}
|
|
302 |
|
|
303 |
mUnencryptedConnection->setContentWidgetData("checkState",
|
|
304 |
mUnencryptState ? Qt::Checked : Qt::Unchecked);
|
|
305 |
|
|
306 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_CREATEUNENCRYPTEDBOX_EXIT, this );
|
|
307 |
return mUnencryptedConnection;
|
|
308 |
}
|
|
309 |
|
|
310 |
/*!
|
|
311 |
Removes provided object from the UI if it exists there and sets the pointer
|
|
312 |
to NULL.
|
|
313 |
|
|
314 |
@param object object to be removed and nulled.
|
|
315 |
*/
|
|
316 |
void CpWpaCmnUiPrivate::removeObjectFromView(CpSettingFormItemData *&object)
|
|
317 |
{
|
|
318 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_REMOVEOBJECTFROMVIEW_ENTRY, this );
|
|
319 |
|
|
320 |
if (object) {
|
|
321 |
mCmnUi->removeChild(mCmnUi->indexOf(object));
|
|
322 |
object = NULL;
|
|
323 |
}
|
|
324 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_REMOVEOBJECTFROMVIEW_EXIT, this );
|
|
325 |
}
|
|
326 |
|
|
327 |
|
|
328 |
/*!
|
|
329 |
Load the CpSettingFormItemData components, based on the security
|
|
330 |
mode chosen. Only those components that are required by that security
|
|
331 |
mode are loaded
|
|
332 |
*/
|
|
333 |
void CpWpaCmnUiPrivate::loadUi()
|
|
334 |
{
|
|
335 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_LOADUI_ENTRY, this );
|
|
336 |
|
|
337 |
//Read values From CommsDatbase
|
|
338 |
int err;
|
|
339 |
QT_TRYCATCH_ERROR(err, ( readValues()));
|
|
340 |
if (err != KErrNone) {
|
|
341 |
OstTrace1( TRACE_ERROR, CPWPACMNUIPRIVATE_CREATEUI, "CPWPACMNUI ReadValues returned %d", err );
|
|
342 |
}
|
|
343 |
|
|
344 |
switch (mSecurityMode)
|
|
345 |
{
|
|
346 |
case CMManagerShim::WlanSecModeWpa:
|
|
347 |
case CMManagerShim::WlanSecModeWpa2:
|
|
348 |
createWpaTypeSelector();
|
|
349 |
if (mEnablePskMode) {
|
|
350 |
loadWPAPskView();
|
|
351 |
}
|
|
352 |
else {
|
|
353 |
loadWPAEapView();
|
|
354 |
}
|
|
355 |
break;
|
|
356 |
|
|
357 |
case CMManagerShim::WlanSecMode802_1x:
|
|
358 |
default:
|
|
359 |
Q_ASSERT(mSecurityMode == CMManagerShim::WlanSecMode802_1x);
|
|
360 |
createEapSelector();
|
|
361 |
createEapEntryItem();
|
34
|
362 |
#if 0 /* not supported for now */
|
26
|
363 |
createUnencryptedBox();
|
34
|
364 |
#endif /* #if 0 */
|
26
|
365 |
break;
|
|
366 |
}
|
|
367 |
|
|
368 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_LOADUI_EXIT, this );
|
|
369 |
}
|
|
370 |
|
|
371 |
/*!
|
|
372 |
Load the CpSettingFormItemData components,for the
|
|
373 |
Pre-Shared key mode
|
|
374 |
*/
|
|
375 |
void CpWpaCmnUiPrivate::loadWPAPskView()
|
|
376 |
{
|
|
377 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_LOADWPAPSKVIEW_ENTRY, this );
|
|
378 |
|
|
379 |
removeObjectFromView(mEapPlugins);
|
|
380 |
|
|
381 |
if (mEapEntry) {
|
|
382 |
mCmnUi->removeChild(mCmnUi->indexOf(mEapEntry));
|
|
383 |
mEapEntry = NULL;
|
|
384 |
}
|
|
385 |
createPskEditor();
|
|
386 |
|
|
387 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_LOADWPAPSKVIEW_EXIT, this );
|
|
388 |
}
|
|
389 |
|
|
390 |
/*!
|
|
391 |
Load the CpSettingFormItemData components,for the
|
|
392 |
EAP mode
|
|
393 |
*/
|
|
394 |
void CpWpaCmnUiPrivate::loadWPAEapView()
|
|
395 |
{
|
|
396 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_LOADWPAEAPVIEW_ENTRY, this );
|
|
397 |
|
|
398 |
removeObjectFromView(mPskKeyText);
|
|
399 |
createEapSelector();
|
|
400 |
createEapEntryItem();
|
|
401 |
|
|
402 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_LOADWPAEAPVIEW_EXIT, this );
|
|
403 |
}
|
|
404 |
|
|
405 |
/*!
|
|
406 |
* Reads the wlan security wpa/wpa2 related fields from CommsDb
|
|
407 |
*/
|
|
408 |
void CpWpaCmnUiPrivate::loadWPA_WPA2Fields()
|
|
409 |
{
|
|
410 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_LOADWPA_WPA2FIELDS_ENTRY, this );
|
|
411 |
|
|
412 |
mEnablePskMode = mConnMethod->getBoolAttribute(
|
|
413 |
CMManagerShim::WlanEnableWpaPsk);
|
|
414 |
|
|
415 |
mKeyData = mConnMethod->getString8Attribute(
|
|
416 |
CMManagerShim::WlanWpaPreSharedKey);
|
|
417 |
|
|
418 |
loadEapConfigurations();
|
|
419 |
|
|
420 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_LOADWPA_WPA2FIELDS_EXIT, this );
|
|
421 |
}
|
|
422 |
|
|
423 |
/*!
|
|
424 |
Reads the WLAN security eap related fields from CommsDb and from EAP Qt
|
|
425 |
Configuration Interface
|
|
426 |
*/
|
|
427 |
void CpWpaCmnUiPrivate::load802Dot1xFields()
|
|
428 |
{
|
|
429 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_LOAD802DOT1XFIELDS_ENTRY, this );
|
|
430 |
|
|
431 |
loadEapConfigurations();
|
|
432 |
|
|
433 |
mUnencryptState
|
|
434 |
= mConnMethod->getBoolAttribute(CMManagerShim::Wlan802_1xAllowUnencrypted);
|
|
435 |
|
|
436 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_LOAD802DOT1XFIELDS_EXIT, this );
|
|
437 |
}
|
|
438 |
|
|
439 |
/*!
|
|
440 |
Loads selected EAP method.
|
|
441 |
*/
|
|
442 |
void CpWpaCmnUiPrivate::loadEapConfigurations()
|
|
443 |
{
|
|
444 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_LOADEAPCONFIGURATIONS_ENTRY, this );
|
|
445 |
|
|
446 |
QList<EapQtPluginHandle> types = mEapQtConfigInterface->selectedOuterTypes();
|
|
447 |
mCurrentEapPlugin = 0;
|
|
448 |
if (types.length() > 0) {
|
|
449 |
for (int i = 0; i < mPlugins.length(); ++i)
|
|
450 |
{
|
|
451 |
if (mPlugins.at(i).pluginHandle() == types.at(0)) {
|
|
452 |
mCurrentEapPlugin = i;
|
|
453 |
break;
|
|
454 |
}
|
|
455 |
}
|
|
456 |
}
|
|
457 |
|
|
458 |
else {
|
|
459 |
types.append(mPlugins.at(0).pluginHandle());
|
|
460 |
mEapQtConfigInterface->setSelectedOuterTypes(types);
|
|
461 |
}
|
|
462 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_LOADEAPCONFIGURATIONS_EXIT, this );
|
|
463 |
}
|
|
464 |
|
|
465 |
|
|
466 |
/*!
|
|
467 |
* Reads the wlan security fields from CommsDb
|
|
468 |
*/
|
|
469 |
void CpWpaCmnUiPrivate::readValues()
|
|
470 |
{
|
|
471 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_READVALUES_ENTRY, this );
|
|
472 |
|
|
473 |
switch (mSecurityMode)
|
|
474 |
{
|
|
475 |
case CMManagerShim::WlanSecModeWpa:
|
|
476 |
case CMManagerShim::WlanSecModeWpa2:
|
|
477 |
loadWPA_WPA2Fields();
|
|
478 |
break;
|
|
479 |
|
|
480 |
case CMManagerShim::WlanSecMode802_1x:
|
|
481 |
default:
|
|
482 |
Q_ASSERT(mSecurityMode == CMManagerShim::WlanSecMode802_1x);
|
|
483 |
load802Dot1xFields();
|
|
484 |
break;
|
|
485 |
}
|
|
486 |
|
|
487 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_READVALUES_EXIT, this );
|
|
488 |
}
|
|
489 |
|
|
490 |
|
|
491 |
|
|
492 |
/*!
|
|
493 |
* Tries an Update on Comms Db for the latest settings.
|
|
494 |
* Catches and handles any exception while updating.
|
|
495 |
*/
|
|
496 |
bool CpWpaCmnUiPrivate::tryUpdate()
|
|
497 |
{
|
|
498 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_TRYUPDATE_ENTRY, this );
|
|
499 |
int ret(true);
|
|
500 |
// Try update
|
|
501 |
try {
|
|
502 |
mConnMethod->update();
|
|
503 |
}
|
|
504 |
catch (const std::exception&) {
|
|
505 |
// Handle error
|
|
506 |
handleUpdateError();
|
|
507 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_TRYUPDATE_EXIT, this );
|
|
508 |
ret = false;
|
|
509 |
}
|
|
510 |
OstTraceFunctionExit1( DUP1_CPWPACMNUIPRIVATE_TRYUPDATE_EXIT, this );
|
|
511 |
return ret;
|
|
512 |
}
|
|
513 |
|
|
514 |
/*!
|
|
515 |
Handles failed CommsDat update.
|
|
516 |
*/
|
|
517 |
void CpWpaCmnUiPrivate::handleUpdateError()
|
|
518 |
{
|
|
519 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_HANDLEUPDATEERROR_ENTRY, this );
|
|
520 |
// Show error note to user
|
|
521 |
showMessageBox(HbMessageBox::MessageTypeWarning, hbTrId(
|
|
522 |
"txt_occ_info_unable_to_save_setting"));
|
|
523 |
// Reload settings from CommsDat and update UI
|
|
524 |
try {
|
|
525 |
mConnMethod->refresh();
|
|
526 |
}
|
|
527 |
catch (const std::exception&) {
|
|
528 |
// Ignore error from refresh. Most likely this will not happen, but
|
|
529 |
// if it does, there isn't very much we can do.
|
|
530 |
OstTrace0( TRACE_ERROR, CPWPACMNUIPRIVATE_HANDLEUPDATEERROR, "CpWpaCmnUiPrivate::handleUpdateError" );
|
|
531 |
|
|
532 |
};
|
|
533 |
|
|
534 |
//Call reset on Ui elements
|
|
535 |
reset();
|
|
536 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_HANDLEUPDATEERROR_EXIT, this );
|
|
537 |
}
|
|
538 |
|
|
539 |
/*!
|
|
540 |
Shows message box with "OK" button using given text.
|
|
541 |
*/
|
|
542 |
void CpWpaCmnUiPrivate::showMessageBox(HbMessageBox::MessageBoxType type,
|
|
543 |
const QString &text)
|
|
544 |
{
|
|
545 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_SHOWMESSAGEBOX_ENTRY, this );
|
|
546 |
// Create a message box
|
|
547 |
mMessageBox = QSharedPointer<HbMessageBox> (new HbMessageBox(type));
|
47
|
548 |
mMessageBox->setObjectName("CpWpaCmnUiMessageBox");
|
26
|
549 |
mMessageBox->setText(text);
|
|
550 |
mMessageBox->open();
|
|
551 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_SHOWMESSAGEBOX_EXIT, this );
|
|
552 |
}
|
|
553 |
|
|
554 |
/*!
|
|
555 |
* Resets all the Ui elements to their previous values,
|
|
556 |
* by reading values from DB
|
|
557 |
*/
|
|
558 |
void CpWpaCmnUiPrivate::reset()
|
|
559 |
{
|
|
560 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_RESET_ENTRY, this );
|
|
561 |
|
|
562 |
//Reload Ui with the previous settings (read from Comms )
|
|
563 |
loadUi();
|
|
564 |
|
|
565 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_RESET_EXIT, this );
|
|
566 |
}
|
|
567 |
|
|
568 |
/*!
|
|
569 |
Method to handle change in wpa mode :- PSK /EAP,
|
|
570 |
Update Key in Comms
|
|
571 |
|
|
572 |
\param pskEnable the current mode chosen
|
|
573 |
*/
|
|
574 |
void CpWpaCmnUiPrivate::updateWpaType(int pskEnable)
|
|
575 |
{
|
|
576 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_UPDATEWPATYPE_ENTRY, this );
|
|
577 |
int err;
|
|
578 |
bool PskEnable = pskEnable ? true : false;
|
|
579 |
|
|
580 |
QT_TRYCATCH_ERROR(err,mConnMethod->setBoolAttribute(CMManagerShim::WlanEnableWpaPsk, PskEnable));
|
|
581 |
|
|
582 |
if (err != KErrNone) {
|
|
583 |
OstTrace1( TRACE_ERROR, CPWPACMNUIPRIVATE_UPDATEWPATYPE, "CpWpaCmnUiPrivate::updateWpaType;err=%d", err );
|
|
584 |
}
|
|
585 |
tryUpdate();
|
|
586 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_UPDATEWPATYPE_EXIT, this );
|
|
587 |
}
|
|
588 |
|
|
589 |
/*!
|
|
590 |
Slot to handle change in pre-shared key string
|
|
591 |
|
|
592 |
\param key changed string for PSK
|
|
593 |
*/
|
|
594 |
void CpWpaCmnUiPrivate::updatePskKey(QString &key)
|
|
595 |
{
|
|
596 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_UPDATEPSKKEY_ENTRY, this );
|
|
597 |
int err;
|
|
598 |
//Check for Validity of Pre-shared Key
|
|
599 |
WpaKeyValidator::KeyStatus keystatus = WpaKeyValidator::validateWpaKey(key);
|
|
600 |
|
|
601 |
if (keystatus == WpaKeyValidator::KeyStatusOk) {
|
|
602 |
QT_TRYCATCH_ERROR(err, mConnMethod->setString8Attribute(CMManagerShim::WlanWpaPreSharedKey, key));
|
|
603 |
if (err != KErrNone) {
|
|
604 |
OstTrace1( TRACE_ERROR, CPWPACMNUIPRIVATE_UPDATEPSKKEY, "CpWpaCmnUiPrivate::updatePskKey;err=%d", err );
|
|
605 |
}
|
|
606 |
tryUpdate();
|
|
607 |
|
|
608 |
//Store the String that was just set
|
|
609 |
mKeyData = key;
|
|
610 |
}
|
|
611 |
else {
|
|
612 |
showMessageBox(HbMessageBox::MessageTypeWarning, hbTrId(
|
|
613 |
"txt_occ_info_invalid_input"));
|
|
614 |
}
|
|
615 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_UPDATEPSKKEY_EXIT, this );
|
|
616 |
}
|
|
617 |
|
|
618 |
|
|
619 |
|
|
620 |
//====================== PRIVATE SLOTS===================================
|
|
621 |
|
|
622 |
|
|
623 |
/*!
|
|
624 |
Slot to handle change in wpa mode :- PSK /EAP
|
|
625 |
Emits a mode change signal to the security plugin
|
|
626 |
to indicate the change
|
|
627 |
|
|
628 |
\param pskEnable the current mode chosen
|
|
629 |
*/
|
|
630 |
void CpWpaCmnUiPrivate::wpaTypeChanged(int pskEnable)
|
|
631 |
{
|
|
632 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_WPATYPECHANGED_ENTRY, this );
|
|
633 |
|
|
634 |
mEnablePskMode = pskEnable == 0 ? false : true;
|
|
635 |
|
|
636 |
if (mEnablePskMode) {
|
|
637 |
loadWPAPskView();
|
|
638 |
}
|
|
639 |
else {
|
|
640 |
loadWPAEapView();
|
|
641 |
}
|
|
642 |
|
|
643 |
//Update pskEnable flag in DB
|
|
644 |
updateWpaType(pskEnable);
|
|
645 |
|
|
646 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_WPATYPECHANGED_EXIT, this );
|
|
647 |
}
|
|
648 |
|
|
649 |
/*!
|
|
650 |
Slot to handle change in eap method in use.
|
|
651 |
Emits signal back to the security plugin to indicate
|
|
652 |
the change
|
|
653 |
\param currentplugin plugin number to indicate the
|
|
654 |
eap method in use
|
|
655 |
*/
|
|
656 |
void CpWpaCmnUiPrivate::eapTypeChanged(int eapPlugin)
|
|
657 |
{
|
|
658 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_EAPTYPECHANGED_ENTRY, this );
|
|
659 |
|
|
660 |
mCurrentEapPlugin = eapPlugin;
|
|
661 |
QList<EapQtPluginHandle> outerHandles;
|
|
662 |
outerHandles.append(mPlugins.at(mCurrentEapPlugin).pluginHandle());
|
|
663 |
mEapQtConfigInterface->setSelectedOuterTypes(outerHandles);
|
|
664 |
|
|
665 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_EAPTYPECHANGED_EXIT, this );
|
|
666 |
}
|
|
667 |
|
|
668 |
/*!
|
|
669 |
Slot to handle change in pre-shared key string
|
|
670 |
Emits signal back to the security plugin to indicate
|
|
671 |
the change
|
|
672 |
|
|
673 |
*/
|
|
674 |
void CpWpaCmnUiPrivate::pskKeyChanged()
|
|
675 |
{
|
|
676 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_PSKKEYCHANGED_ENTRY, this );
|
|
677 |
|
|
678 |
QVariant keyValue = mPskKeyText->contentWidgetData("text");
|
|
679 |
QString keyString = keyValue.toString();
|
|
680 |
|
|
681 |
//Update Pre Shared key in DB
|
|
682 |
updatePskKey(keyString);
|
|
683 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_PSKKEYCHANGED_EXIT, this );
|
|
684 |
}
|
|
685 |
|
|
686 |
/*!
|
|
687 |
Slot to handle change in the state of unencrypted connection;
|
|
688 |
to indicate if such a connection is allowed.
|
|
689 |
Emits signal back to the security plugin to indicate
|
|
690 |
the change
|
|
691 |
\param state checked-Allowed / Unchecked-Not allowed
|
|
692 |
*/
|
|
693 |
void CpWpaCmnUiPrivate::unencryptConnStateChanged(int state)
|
|
694 |
{
|
|
695 |
OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_UNENCRYPTCONNSTATECHANGED_ENTRY, this );
|
|
696 |
|
|
697 |
bool checked = (state == Qt::Checked) ? true : false;
|
|
698 |
mConnMethod->setBoolAttribute(
|
|
699 |
CMManagerShim::Wlan802_1xAllowUnencrypted,checked);
|
|
700 |
|
|
701 |
tryUpdate();
|
|
702 |
|
|
703 |
//store the Unencrypted Connection State
|
|
704 |
mUnencryptState = checked;
|
|
705 |
|
|
706 |
OstTraceFunctionExit1( CPWPACMNUIPRIVATE_UNENCRYPTCONNSTATECHANGED_EXIT, this );
|
|
707 |
}
|
|
708 |
|
|
709 |
/*!
|
|
710 |
* Slot that configures the editor settings for Pre-Shared Key Field.
|
|
711 |
* This slot is invoked whenever a new item(s) are shown in the current view
|
|
712 |
*
|
|
713 |
* \param modelIndex Index of the current item in the model
|
|
714 |
*/
|
|
715 |
void CpWpaCmnUiPrivate::setEditorPreferences(const QModelIndex &modelIndex)
|
|
716 |
{
|
|
717 |
|
|
718 |
HbDataFormModelItem *item = mDataHelper.modelItemFromModelIndex(modelIndex);
|
|
719 |
|
|
720 |
/* Configure settings only for text fields*/
|
|
721 |
if(item->type() == HbDataFormModelItem::TextItem) {
|
|
722 |
HbLineEdit *edit = qobject_cast<HbLineEdit*>(mDataHelper.widgetFromModelIndex(modelIndex));
|
|
723 |
HbEditorInterface editInterface(edit);
|
|
724 |
editInterface.setInputConstraints(HbEditorConstraintLatinAlphabetOnly);
|
|
725 |
edit->setInputMethodHints(Qt::ImhNoPredictiveText);
|
|
726 |
}
|
|
727 |
}
|
|
728 |
|
|
729 |
/*!
|
|
730 |
Validates current security settings. This function is called whenever
|
|
731 |
user tries to exit from the settings view. If the plugin determines
|
|
732 |
that some settings need editing before considered valid, it shall
|
|
733 |
return false. A dialog will be shown to the user indicating that
|
|
734 |
settings are still incomplete and asking if he/she wishes to exit
|
|
735 |
anyway.
|
|
736 |
|
|
737 |
\return True if security settings fpr WPA/WPA2 , WPA2 only are valid,
|
|
738 |
false if not.
|
|
739 |
*/
|
|
740 |
bool CpWpaCmnUiPrivate::validateSettings()
|
|
741 |
{
|
|
742 |
bool ret(false);
|
|
743 |
if(mEnablePskMode) {
|
|
744 |
//Check the latest string entered for the Pre-Shared key in the text box
|
|
745 |
QVariant keyValue = mPskKeyText->contentWidgetData("text");
|
|
746 |
QString keyString = keyValue.toString();
|
|
747 |
WpaKeyValidator::KeyStatus keystatus = WpaKeyValidator::validateWpaKey(keyString);
|
|
748 |
|
|
749 |
if (keystatus == WpaKeyValidator::KeyStatusOk && (!keyString.isEmpty())) {
|
|
750 |
ret= true;
|
|
751 |
}
|
|
752 |
}
|
|
753 |
else{
|
|
754 |
//return true if EAP mode
|
|
755 |
ret = true;
|
|
756 |
}
|
|
757 |
return ret;
|
|
758 |
}
|
|
759 |
|
|
760 |
/*!
|
|
761 |
comparator for qSort() method to sort Eap plugins based on ordernumber.
|
|
762 |
|
|
763 |
@param plugin1 Plugin1
|
|
764 |
@param plugin2 Plugin2
|
|
765 |
*/
|
|
766 |
bool CpWpaCmnUiPrivate::pluginLessThan(
|
|
767 |
const EapQtPluginInfo &plugin1,
|
|
768 |
const EapQtPluginInfo &plugin2)
|
|
769 |
{
|
|
770 |
return plugin1.orderNumber() < plugin2.orderNumber();
|
|
771 |
}
|
|
772 |
|
|
773 |
|