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