|
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 the License "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#11 % |
|
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 createUnencryptedBox(); |
|
350 break; |
|
351 } |
|
352 |
|
353 OstTraceFunctionExit1( CPWPACMNUIPRIVATE_LOADUI_EXIT, this ); |
|
354 } |
|
355 |
|
356 /*! |
|
357 Load the CpSettingFormItemData components,for the |
|
358 Pre-Shared key mode |
|
359 */ |
|
360 void CpWpaCmnUiPrivate::loadWPAPskView() |
|
361 { |
|
362 OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_LOADWPAPSKVIEW_ENTRY, this ); |
|
363 |
|
364 removeObjectFromView(mEapPlugins); |
|
365 |
|
366 if (mEapEntry) { |
|
367 mCmnUi->removeChild(mCmnUi->indexOf(mEapEntry)); |
|
368 mEapEntry = NULL; |
|
369 } |
|
370 createPskEditor(); |
|
371 |
|
372 OstTraceFunctionExit1( CPWPACMNUIPRIVATE_LOADWPAPSKVIEW_EXIT, this ); |
|
373 } |
|
374 |
|
375 /*! |
|
376 Load the CpSettingFormItemData components,for the |
|
377 EAP mode |
|
378 */ |
|
379 void CpWpaCmnUiPrivate::loadWPAEapView() |
|
380 { |
|
381 OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_LOADWPAEAPVIEW_ENTRY, this ); |
|
382 |
|
383 removeObjectFromView(mPskKeyText); |
|
384 createEapSelector(); |
|
385 createEapEntryItem(); |
|
386 |
|
387 OstTraceFunctionExit1( CPWPACMNUIPRIVATE_LOADWPAEAPVIEW_EXIT, this ); |
|
388 } |
|
389 |
|
390 /*! |
|
391 * Reads the wlan security wpa/wpa2 related fields from CommsDb |
|
392 */ |
|
393 void CpWpaCmnUiPrivate::loadWPA_WPA2Fields() |
|
394 { |
|
395 OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_LOADWPA_WPA2FIELDS_ENTRY, this ); |
|
396 |
|
397 mEnablePskMode = mConnMethod->getBoolAttribute( |
|
398 CMManagerShim::WlanEnableWpaPsk); |
|
399 |
|
400 mKeyData = mConnMethod->getString8Attribute( |
|
401 CMManagerShim::WlanWpaPreSharedKey); |
|
402 |
|
403 loadEapConfigurations(); |
|
404 |
|
405 OstTraceFunctionExit1( CPWPACMNUIPRIVATE_LOADWPA_WPA2FIELDS_EXIT, this ); |
|
406 } |
|
407 |
|
408 /*! |
|
409 Reads the WLAN security eap related fields from CommsDb and from EAP Qt |
|
410 Configuration Interface |
|
411 */ |
|
412 void CpWpaCmnUiPrivate::load802Dot1xFields() |
|
413 { |
|
414 OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_LOAD802DOT1XFIELDS_ENTRY, this ); |
|
415 |
|
416 loadEapConfigurations(); |
|
417 |
|
418 mUnencryptState |
|
419 = mConnMethod->getBoolAttribute(CMManagerShim::Wlan802_1xAllowUnencrypted); |
|
420 |
|
421 OstTraceFunctionExit1( CPWPACMNUIPRIVATE_LOAD802DOT1XFIELDS_EXIT, this ); |
|
422 } |
|
423 |
|
424 /*! |
|
425 Loads selected EAP method. |
|
426 */ |
|
427 void CpWpaCmnUiPrivate::loadEapConfigurations() |
|
428 { |
|
429 OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_LOADEAPCONFIGURATIONS_ENTRY, this ); |
|
430 |
|
431 QList<EapQtPluginHandle> types = mEapQtConfigInterface->selectedOuterTypes(); |
|
432 mCurrentEapPlugin = 0; |
|
433 if (types.length() > 0) { |
|
434 for (int i = 0; i < mPlugins.length(); ++i) |
|
435 { |
|
436 if (mPlugins.at(i).pluginHandle() == types.at(0)) { |
|
437 mCurrentEapPlugin = i; |
|
438 break; |
|
439 } |
|
440 } |
|
441 } |
|
442 |
|
443 else { |
|
444 types.append(mPlugins.at(0).pluginHandle()); |
|
445 mEapQtConfigInterface->setSelectedOuterTypes(types); |
|
446 } |
|
447 OstTraceFunctionExit1( CPWPACMNUIPRIVATE_LOADEAPCONFIGURATIONS_EXIT, this ); |
|
448 } |
|
449 |
|
450 |
|
451 /*! |
|
452 * Reads the wlan security fields from CommsDb |
|
453 */ |
|
454 void CpWpaCmnUiPrivate::readValues() |
|
455 { |
|
456 OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_READVALUES_ENTRY, this ); |
|
457 |
|
458 switch (mSecurityMode) |
|
459 { |
|
460 case CMManagerShim::WlanSecModeWpa: |
|
461 case CMManagerShim::WlanSecModeWpa2: |
|
462 loadWPA_WPA2Fields(); |
|
463 break; |
|
464 |
|
465 case CMManagerShim::WlanSecMode802_1x: |
|
466 default: |
|
467 Q_ASSERT(mSecurityMode == CMManagerShim::WlanSecMode802_1x); |
|
468 load802Dot1xFields(); |
|
469 break; |
|
470 } |
|
471 |
|
472 OstTraceFunctionExit1( CPWPACMNUIPRIVATE_READVALUES_EXIT, this ); |
|
473 } |
|
474 |
|
475 |
|
476 |
|
477 /*! |
|
478 * Tries an Update on Comms Db for the latest settings. |
|
479 * Catches and handles any exception while updating. |
|
480 */ |
|
481 bool CpWpaCmnUiPrivate::tryUpdate() |
|
482 { |
|
483 OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_TRYUPDATE_ENTRY, this ); |
|
484 int ret(true); |
|
485 // Try update |
|
486 try { |
|
487 mConnMethod->update(); |
|
488 } |
|
489 catch (const std::exception&) { |
|
490 // Handle error |
|
491 handleUpdateError(); |
|
492 OstTraceFunctionExit1( CPWPACMNUIPRIVATE_TRYUPDATE_EXIT, this ); |
|
493 ret = false; |
|
494 } |
|
495 OstTraceFunctionExit1( DUP1_CPWPACMNUIPRIVATE_TRYUPDATE_EXIT, this ); |
|
496 return ret; |
|
497 } |
|
498 |
|
499 /*! |
|
500 Handles failed CommsDat update. |
|
501 */ |
|
502 void CpWpaCmnUiPrivate::handleUpdateError() |
|
503 { |
|
504 OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_HANDLEUPDATEERROR_ENTRY, this ); |
|
505 // Show error note to user |
|
506 showMessageBox(HbMessageBox::MessageTypeWarning, hbTrId( |
|
507 "txt_occ_info_unable_to_save_setting")); |
|
508 // Reload settings from CommsDat and update UI |
|
509 try { |
|
510 mConnMethod->refresh(); |
|
511 } |
|
512 catch (const std::exception&) { |
|
513 // Ignore error from refresh. Most likely this will not happen, but |
|
514 // if it does, there isn't very much we can do. |
|
515 OstTrace0( TRACE_ERROR, CPWPACMNUIPRIVATE_HANDLEUPDATEERROR, "CpWpaCmnUiPrivate::handleUpdateError" ); |
|
516 |
|
517 }; |
|
518 |
|
519 //Call reset on Ui elements |
|
520 reset(); |
|
521 OstTraceFunctionExit1( CPWPACMNUIPRIVATE_HANDLEUPDATEERROR_EXIT, this ); |
|
522 } |
|
523 |
|
524 /*! |
|
525 Shows message box with "OK" button using given text. |
|
526 */ |
|
527 void CpWpaCmnUiPrivate::showMessageBox(HbMessageBox::MessageBoxType type, |
|
528 const QString &text) |
|
529 { |
|
530 OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_SHOWMESSAGEBOX_ENTRY, this ); |
|
531 // Create a message box |
|
532 mMessageBox = QSharedPointer<HbMessageBox> (new HbMessageBox(type)); |
|
533 mMessageBox->setText(text); |
|
534 mMessageBox->open(); |
|
535 OstTraceFunctionExit1( CPWPACMNUIPRIVATE_SHOWMESSAGEBOX_EXIT, this ); |
|
536 } |
|
537 |
|
538 /*! |
|
539 * Resets all the Ui elements to their previous values, |
|
540 * by reading values from DB |
|
541 */ |
|
542 void CpWpaCmnUiPrivate::reset() |
|
543 { |
|
544 OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_RESET_ENTRY, this ); |
|
545 |
|
546 //Reload Ui with the previous settings (read from Comms ) |
|
547 loadUi(); |
|
548 |
|
549 OstTraceFunctionExit1( CPWPACMNUIPRIVATE_RESET_EXIT, this ); |
|
550 } |
|
551 |
|
552 /*! |
|
553 Method to handle change in wpa mode :- PSK /EAP, |
|
554 Update Key in Comms |
|
555 |
|
556 \param pskEnable the current mode chosen |
|
557 */ |
|
558 void CpWpaCmnUiPrivate::updateWpaType(int pskEnable) |
|
559 { |
|
560 OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_UPDATEWPATYPE_ENTRY, this ); |
|
561 int err; |
|
562 bool PskEnable = pskEnable ? true : false; |
|
563 |
|
564 QT_TRYCATCH_ERROR(err,mConnMethod->setBoolAttribute(CMManagerShim::WlanEnableWpaPsk, PskEnable)); |
|
565 |
|
566 if (err != KErrNone) { |
|
567 OstTrace1( TRACE_ERROR, CPWPACMNUIPRIVATE_UPDATEWPATYPE, "CpWpaCmnUiPrivate::updateWpaType;err=%d", err ); |
|
568 } |
|
569 tryUpdate(); |
|
570 OstTraceFunctionExit1( CPWPACMNUIPRIVATE_UPDATEWPATYPE_EXIT, this ); |
|
571 } |
|
572 |
|
573 /*! |
|
574 Slot to handle change in pre-shared key string |
|
575 |
|
576 \param key changed string for PSK |
|
577 */ |
|
578 void CpWpaCmnUiPrivate::updatePskKey(QString &key) |
|
579 { |
|
580 OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_UPDATEPSKKEY_ENTRY, this ); |
|
581 int err; |
|
582 //Check for Validity of Pre-shared Key |
|
583 WpaKeyValidator::KeyStatus keystatus = WpaKeyValidator::validateWpaKey(key); |
|
584 |
|
585 if (keystatus == WpaKeyValidator::KeyStatusOk) { |
|
586 QT_TRYCATCH_ERROR(err, mConnMethod->setString8Attribute(CMManagerShim::WlanWpaPreSharedKey, key)); |
|
587 if (err != KErrNone) { |
|
588 OstTrace1( TRACE_ERROR, CPWPACMNUIPRIVATE_UPDATEPSKKEY, "CpWpaCmnUiPrivate::updatePskKey;err=%d", err ); |
|
589 } |
|
590 tryUpdate(); |
|
591 |
|
592 //Store the String that was just set |
|
593 mKeyData = key; |
|
594 } |
|
595 else { |
|
596 showMessageBox(HbMessageBox::MessageTypeWarning, hbTrId( |
|
597 "txt_occ_info_invalid_input")); |
|
598 } |
|
599 OstTraceFunctionExit1( CPWPACMNUIPRIVATE_UPDATEPSKKEY_EXIT, this ); |
|
600 } |
|
601 |
|
602 |
|
603 |
|
604 //====================== PRIVATE SLOTS=================================== |
|
605 |
|
606 |
|
607 /*! |
|
608 Slot to handle change in wpa mode :- PSK /EAP |
|
609 Emits a mode change signal to the security plugin |
|
610 to indicate the change |
|
611 |
|
612 \param pskEnable the current mode chosen |
|
613 */ |
|
614 void CpWpaCmnUiPrivate::wpaTypeChanged(int pskEnable) |
|
615 { |
|
616 OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_WPATYPECHANGED_ENTRY, this ); |
|
617 |
|
618 mEnablePskMode = pskEnable == 0 ? false : true; |
|
619 |
|
620 if (mEnablePskMode) { |
|
621 loadWPAPskView(); |
|
622 } |
|
623 else { |
|
624 loadWPAEapView(); |
|
625 } |
|
626 |
|
627 //Update pskEnable flag in DB |
|
628 updateWpaType(pskEnable); |
|
629 |
|
630 OstTraceFunctionExit1( CPWPACMNUIPRIVATE_WPATYPECHANGED_EXIT, this ); |
|
631 } |
|
632 |
|
633 /*! |
|
634 Slot to handle change in eap method in use. |
|
635 Emits signal back to the security plugin to indicate |
|
636 the change |
|
637 \param currentplugin plugin number to indicate the |
|
638 eap method in use |
|
639 */ |
|
640 void CpWpaCmnUiPrivate::eapTypeChanged(int eapPlugin) |
|
641 { |
|
642 OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_EAPTYPECHANGED_ENTRY, this ); |
|
643 |
|
644 mCurrentEapPlugin = eapPlugin; |
|
645 QList<EapQtPluginHandle> outerHandles; |
|
646 outerHandles.append(mPlugins.at(mCurrentEapPlugin).pluginHandle()); |
|
647 mEapQtConfigInterface->setSelectedOuterTypes(outerHandles); |
|
648 |
|
649 OstTraceFunctionExit1( CPWPACMNUIPRIVATE_EAPTYPECHANGED_EXIT, this ); |
|
650 } |
|
651 |
|
652 /*! |
|
653 Slot to handle change in pre-shared key string |
|
654 Emits signal back to the security plugin to indicate |
|
655 the change |
|
656 |
|
657 */ |
|
658 void CpWpaCmnUiPrivate::pskKeyChanged() |
|
659 { |
|
660 OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_PSKKEYCHANGED_ENTRY, this ); |
|
661 |
|
662 QVariant keyValue = mPskKeyText->contentWidgetData("text"); |
|
663 QString keyString = keyValue.toString(); |
|
664 |
|
665 //Update Pre Shared key in DB |
|
666 updatePskKey(keyString); |
|
667 OstTraceFunctionExit1( CPWPACMNUIPRIVATE_PSKKEYCHANGED_EXIT, this ); |
|
668 } |
|
669 |
|
670 /*! |
|
671 Slot to handle change in the state of unencrypted connection; |
|
672 to indicate if such a connection is allowed. |
|
673 Emits signal back to the security plugin to indicate |
|
674 the change |
|
675 \param state checked-Allowed / Unchecked-Not allowed |
|
676 */ |
|
677 void CpWpaCmnUiPrivate::unencryptConnStateChanged(int state) |
|
678 { |
|
679 OstTraceFunctionEntry1( CPWPACMNUIPRIVATE_UNENCRYPTCONNSTATECHANGED_ENTRY, this ); |
|
680 |
|
681 bool checked = (state == Qt::Checked) ? true : false; |
|
682 mConnMethod->setBoolAttribute( |
|
683 CMManagerShim::Wlan802_1xAllowUnencrypted,checked); |
|
684 |
|
685 tryUpdate(); |
|
686 |
|
687 //store the Unencrypted Connection State |
|
688 mUnencryptState = checked; |
|
689 |
|
690 OstTraceFunctionExit1( CPWPACMNUIPRIVATE_UNENCRYPTCONNSTATECHANGED_EXIT, this ); |
|
691 } |
|
692 |
|
693 /*! |
|
694 * Slot that configures the editor settings for Pre-Shared Key Field. |
|
695 * This slot is invoked whenever a new item(s) are shown in the current view |
|
696 * |
|
697 * \param modelIndex Index of the current item in the model |
|
698 */ |
|
699 void CpWpaCmnUiPrivate::setEditorPreferences(const QModelIndex &modelIndex) |
|
700 { |
|
701 |
|
702 HbDataFormModelItem *item = mDataHelper.modelItemFromModelIndex(modelIndex); |
|
703 |
|
704 /* Configure settings only for text fields*/ |
|
705 if(item->type() == HbDataFormModelItem::TextItem) { |
|
706 HbLineEdit *edit = qobject_cast<HbLineEdit*>(mDataHelper.widgetFromModelIndex(modelIndex)); |
|
707 HbEditorInterface editInterface(edit); |
|
708 editInterface.setInputConstraints(HbEditorConstraintLatinAlphabetOnly); |
|
709 edit->setInputMethodHints(Qt::ImhNoPredictiveText); |
|
710 } |
|
711 } |
|
712 |
|
713 /*! |
|
714 Validates current security settings. This function is called whenever |
|
715 user tries to exit from the settings view. If the plugin determines |
|
716 that some settings need editing before considered valid, it shall |
|
717 return false. A dialog will be shown to the user indicating that |
|
718 settings are still incomplete and asking if he/she wishes to exit |
|
719 anyway. |
|
720 |
|
721 \return True if security settings fpr WPA/WPA2 , WPA2 only are valid, |
|
722 false if not. |
|
723 */ |
|
724 bool CpWpaCmnUiPrivate::validateSettings() |
|
725 { |
|
726 bool ret(false); |
|
727 if(mEnablePskMode) { |
|
728 //Check the latest string entered for the Pre-Shared key in the text box |
|
729 QVariant keyValue = mPskKeyText->contentWidgetData("text"); |
|
730 QString keyString = keyValue.toString(); |
|
731 WpaKeyValidator::KeyStatus keystatus = WpaKeyValidator::validateWpaKey(keyString); |
|
732 |
|
733 if (keystatus == WpaKeyValidator::KeyStatusOk && (!keyString.isEmpty())) { |
|
734 ret= true; |
|
735 } |
|
736 } |
|
737 else{ |
|
738 //return true if EAP mode |
|
739 ret = true; |
|
740 } |
|
741 return ret; |
|
742 } |
|
743 |
|
744 /*! |
|
745 comparator for qSort() method to sort Eap plugins based on ordernumber. |
|
746 |
|
747 @param plugin1 Plugin1 |
|
748 @param plugin2 Plugin2 |
|
749 */ |
|
750 bool CpWpaCmnUiPrivate::pluginLessThan( |
|
751 const EapQtPluginInfo &plugin1, |
|
752 const EapQtPluginInfo &plugin2) |
|
753 { |
|
754 return plugin1.orderNumber() < plugin2.orderNumber(); |
|
755 } |
|
756 |
|
757 |