|
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 * Control Panel QT UI for WEP configuration |
|
16 * |
|
17 */ |
|
18 |
|
19 /* |
|
20 * %version: 16 % |
|
21 */ |
|
22 |
|
23 //User Includes |
|
24 #include "cpwepui.h" |
|
25 |
|
26 // System includes |
|
27 #include <QStringList> |
|
28 #include <cpsettingformentryitemdata.h> |
|
29 #include <cpitemdatahelper.h> |
|
30 #include <HbDataForm> |
|
31 #include <HbDeviceNotificationDialog> |
|
32 #include <QLocale> |
|
33 #include <QCoreApplication> |
|
34 #include <cmconnectionmethod_shim.h> |
|
35 #include <cmpluginwlandef.h> |
|
36 #include <cmmanagerdefines_shim.h> |
|
37 |
|
38 #include "OstTraceDefinitions.h" |
|
39 #ifdef OST_TRACE_COMPILER_IN_USE |
|
40 #include "cpwepuiTraces.h" |
|
41 #endif |
|
42 |
|
43 // Constants |
|
44 //The order in which WEP only mode appears in the list of available |
|
45 //security mode |
|
46 static const int UI_ORDER_WEP = 10; |
|
47 |
|
48 /*! |
|
49 \class CpWepUi |
|
50 \brief CpWepUi implements the WEP Security Settings Control Panel Plugin |
|
51 which will allow viewing/editing of WEP Security Settings. |
|
52 */ |
|
53 //Contructs WEP object |
|
54 CpWepUi::CpWepUi() : |
|
55 mUi(NULL), mNewKeySelected(0), mTranslator(NULL), mCmCM(NULL), mCmId(0) |
|
56 { |
|
57 mTranslator = new QTranslator(this); |
|
58 mTranslator->load(":/loc/wlan_en_GB.qm"); |
|
59 qApp->installTranslator(mTranslator); |
|
60 |
|
61 /* Install localization |
|
62 mTranslator = QSharedPointer<HbTranslator> ( |
|
63 new HbTranslator("wlan_en_GB"));*/ |
|
64 } |
|
65 |
|
66 //Deletes all objects WEP owns |
|
67 CpWepUi::~CpWepUi() |
|
68 { |
|
69 OstTraceFunctionEntry1(CPWEPUI_CPWEPUI_ENTRY,this); |
|
70 //Elements like mUi and components that belong to it |
|
71 //, are taken care by the parent |
|
72 OstTraceFunctionExit1(CPWEPUI_CPWEPUI_EXIT,this); |
|
73 } |
|
74 |
|
75 // ======== MEMBER FUNCTIONS ======== |
|
76 |
|
77 |
|
78 /*! |
|
79 Getter for security mode. |
|
80 |
|
81 \return Security mode identifier |
|
82 */ |
|
83 CMManagerShim::WlanSecMode CpWepUi::securityMode() const |
|
84 { |
|
85 OstTraceFunctionEntry1(CPWEPUI_MODE_ENTRY,this); |
|
86 OstTraceFunctionExit1(CPWEPUI_MODE_EXIT,this); |
|
87 //return security mode |
|
88 return CMManagerShim::WlanSecModeWep; |
|
89 } |
|
90 |
|
91 /*! |
|
92 Getter for localization text identifier for the security mode, |
|
93 f.ex. "txt_occ_setlabel_wlan_security_mode_val_wep". This localized |
|
94 text will be shown in the UI. |
|
95 |
|
96 \return Localization text ID |
|
97 */ |
|
98 QString CpWepUi::securityModeTextId() const |
|
99 { |
|
100 OstTraceFunctionEntry1(CPWEPUI_LOCALIZATION_ID_ENTRY,this); |
|
101 OstTraceFunctionExit1(CPWEPUI_LOCALIZATION_ID_EXIT,this); |
|
102 return "txt_occ_setlabel_wlan_security_mode_val_wep"; |
|
103 } |
|
104 |
|
105 /*! |
|
106 Sets the database reference (WLAN Service Table ID). |
|
107 |
|
108 \param id Database reference |
|
109 */ |
|
110 void CpWepUi::setReference(CmConnectionMethodShim *cmCm, uint id) |
|
111 { |
|
112 OstTraceFunctionEntry1(CPWEPUI_SETREFERENCE_ENTRY,this); |
|
113 |
|
114 // Assuming that id is the connection method Id/IAP Id. |
|
115 //mCmId - Not used currently |
|
116 mCmId = id; |
|
117 |
|
118 //mCmCM is not deleted assuming CmManager owns it. |
|
119 mCmCM = cmCm; |
|
120 OstTraceFunctionExit1(CPWEPUI_SETREFERENCE_EXIT,this); |
|
121 } |
|
122 |
|
123 /*! |
|
124 Getter for order number. This order number is used by the client of |
|
125 this interface to put the security modes in correct order in the list. |
|
126 |
|
127 \return An order number |
|
128 */ |
|
129 int CpWepUi::orderNumber() const |
|
130 { |
|
131 OstTraceFunctionEntry1(CPWEPUI_ORDERNUMBER_ENTRY,this); |
|
132 OstTraceFunctionExit1(CPWEPUI_ORDERNUMBER_EXIT,this); |
|
133 return UI_ORDER_WEP; |
|
134 } |
|
135 |
|
136 /*! |
|
137 * Returns the fully constructed Ui Group , for WEP security plugin |
|
138 * |
|
139 * \param \param dataHelper to add Connections |
|
140 * |
|
141 * \return The WEP UI |
|
142 */ |
|
143 CpSettingFormItemData* CpWepUi::uiInstance(CpItemDataHelper &dataHelpper) |
|
144 { |
|
145 int err; |
|
146 OstTraceFunctionEntry1(CPWEPUI_UIINSTANCE_ENTRY,this); |
|
147 |
|
148 //Read values From CommsDatbase |
|
149 QT_TRYCATCH_ERROR(err, loadFieldsFromDataBase()); |
|
150 if (err != KErrNone) { |
|
151 OstTrace1( TRACE_ERROR, CPWEPUI_UIINSTANCE, "LoadFromDataBase returned %d", err ); |
|
152 } |
|
153 |
|
154 mUi = new CpSettingFormItemData(HbDataFormModelItem::GroupItem, hbTrId( |
|
155 "txt_occ_subhead_security_settings")); |
|
156 |
|
157 CpSettingFormItemData *wepKeyInUse = new CpSettingFormItemData( |
|
158 HbDataFormModelItem::ComboBoxItem, hbTrId( |
|
159 "txt_occ_setlabel_wep_key_in_use"), mUi); |
|
160 QStringList wepKeys; |
|
161 wepKeys.append(hbTrId("txt_occ_setlabel_wep_key_in_val_1")); |
|
162 wepKeys.append(hbTrId("txt_occ_setlabel_wep_key_in_val_2")); |
|
163 wepKeys.append(hbTrId("txt_occ_setlabel_wep_key_in_val_3")); |
|
164 wepKeys.append(hbTrId("txt_occ_setlabel_wep_key_in_val_4")); |
|
165 |
|
166 wepKeyInUse->setContentWidgetData("items", wepKeys); |
|
167 wepKeyInUse->setContentWidgetData("currentIndex", mNewKeySelected); |
|
168 dataHelpper.addConnection(wepKeyInUse, SIGNAL(currentIndexChanged(int)), |
|
169 this, SLOT(wepKeyInUseChanged(int))); |
|
170 mUi->appendChild(wepKeyInUse); |
|
171 |
|
172 createWEPKeyOneGroup(dataHelpper); |
|
173 |
|
174 createWEPKeyTwoGroup(dataHelpper); |
|
175 |
|
176 createWEPKeyThreeGroup(dataHelpper); |
|
177 |
|
178 createWEPKeyFourGroup(dataHelpper); |
|
179 |
|
180 OstTraceFunctionExit1(CPWEPUI_UIINSTANCE_EXIT,this); |
|
181 return mUi; |
|
182 } |
|
183 |
|
184 /*! |
|
185 * Create Ui element with text edit for WEP KEY One |
|
186 * |
|
187 * \param dataHelper to add Connections |
|
188 */ |
|
189 void CpWepUi::createWEPKeyOneGroup(CpItemDataHelper &dataHelpper) |
|
190 { |
|
191 OstTraceFunctionEntry1(CPWEPUI_CREATEWEPKEYONEGROUP_ENTRY,this); |
|
192 mWepKeyText[KFirstKey] = new CpSettingFormItemData( |
|
193 HbDataFormModelItem::TextItem, |
|
194 hbTrId("txt_occ_subhead_wep_key_1"), mUi); |
|
195 |
|
196 if (mKeyData[KFirstKey].length() != 0) { |
|
197 mWepKeyText[KFirstKey]->setContentWidgetData("text", |
|
198 mKeyData[KFirstKey]); |
|
199 } |
|
200 mWepKeyText[KFirstKey]->setContentWidgetData("echoMode", 2); |
|
201 mWepKeyText[KFirstKey]->setContentWidgetData("smileysEnabled", "false"); |
|
202 |
|
203 dataHelpper.addConnection(mWepKeyText[KFirstKey], |
|
204 SIGNAL( editingFinished ()), this, SLOT(wepKeyOneChanged() )); |
|
205 |
|
206 mUi->appendChild(mWepKeyText[KFirstKey]); |
|
207 OstTraceFunctionExit1(CPWEPUI_CREATEWEPKEYONEGROUP_EXIT,this); |
|
208 } |
|
209 |
|
210 /*! |
|
211 * Create Ui element with text edit for WEP KEY Two |
|
212 * \param dataHelper to add Connections |
|
213 */ |
|
214 void CpWepUi::createWEPKeyTwoGroup(CpItemDataHelper &dataHelpper) |
|
215 { |
|
216 OstTraceFunctionEntry1(CPWEPUI_CREATEWEPKEYTWOGROUP_ENTRY,this); |
|
217 mWepKeyText[KSecondKey] = new CpSettingFormItemData( |
|
218 HbDataFormModelItem::TextItem, |
|
219 hbTrId("txt_occ_subhead_wep_key_2"), mUi); |
|
220 |
|
221 if (mKeyData[KSecondKey].length() != 0) { |
|
222 mWepKeyText[KSecondKey]->setContentWidgetData("text", |
|
223 mKeyData[KSecondKey]); |
|
224 } |
|
225 mWepKeyText[KSecondKey]->setContentWidgetData("echoMode", 2); |
|
226 mWepKeyText[KSecondKey]->setContentWidgetData("smileysEnabled", "false"); |
|
227 dataHelpper.addConnection(mWepKeyText[KSecondKey], |
|
228 SIGNAL( editingFinished ()), this, SLOT(wepKeyTwoChanged() )); |
|
229 |
|
230 mUi->appendChild(mWepKeyText[KSecondKey]); |
|
231 OstTraceFunctionExit1(CPWEPUI_CREATEWEPKEYTWOGROUP_EXIT,this); |
|
232 } |
|
233 |
|
234 /*! |
|
235 * Create Ui element with text edit for WEP KEY Three |
|
236 * \param dataHelper to add Connections |
|
237 */ |
|
238 void CpWepUi::createWEPKeyThreeGroup(CpItemDataHelper &dataHelpper) |
|
239 { |
|
240 OstTraceFunctionEntry1(CPWEPUI_CREATEWEPKEYTHREEGROUP_ENTRY,this); |
|
241 mWepKeyText[KThirdKey] = new CpSettingFormItemData( |
|
242 HbDataFormModelItem::TextItem, |
|
243 hbTrId("txt_occ_subhead_wep_key_3"), mUi); |
|
244 |
|
245 if (mKeyData[KThirdKey].length() != 0) { |
|
246 mWepKeyText[KThirdKey]->setContentWidgetData("text", |
|
247 mKeyData[KThirdKey]); |
|
248 } |
|
249 mWepKeyText[KThirdKey]->setContentWidgetData("echoMode", 2); |
|
250 mWepKeyText[KThirdKey]->setContentWidgetData("smileysEnabled", "false"); |
|
251 dataHelpper.addConnection(mWepKeyText[KThirdKey], |
|
252 SIGNAL( editingFinished ()), this, SLOT(wepKeyThreeChanged() )); |
|
253 |
|
254 mUi->appendChild(mWepKeyText[KThirdKey]); |
|
255 OstTraceFunctionExit1(CPWEPUI_CREATEWEPKEYTHREEGROUP_EXIT,this); |
|
256 } |
|
257 |
|
258 /*! |
|
259 * Create Ui element with text edit for WEP KEY Four |
|
260 * \param dataHelper to add Connections |
|
261 */ |
|
262 void CpWepUi::createWEPKeyFourGroup(CpItemDataHelper &dataHelpper) |
|
263 { |
|
264 OstTraceFunctionEntry1(CPWEPUI_CREATEWEPKEYFOURGROUP_ENTRY,this); |
|
265 mWepKeyText[KFourthKey] = new CpSettingFormItemData( |
|
266 HbDataFormModelItem::TextItem, |
|
267 hbTrId("txt_occ_subhead_wep_key_4"), mUi); |
|
268 |
|
269 if (mKeyData[KFourthKey].length() != 0) { |
|
270 mWepKeyText[KFourthKey]->setContentWidgetData("text", |
|
271 mKeyData[KFourthKey]); |
|
272 } |
|
273 mWepKeyText[KFourthKey]->setContentWidgetData("echoMode", 2); |
|
274 mWepKeyText[KFourthKey]->setContentWidgetData("smileysEnabled", "false"); |
|
275 dataHelpper.addConnection(mWepKeyText[KFourthKey], |
|
276 SIGNAL( editingFinished ()), this, SLOT(wepKeyFourChanged() )); |
|
277 |
|
278 mUi->appendChild(mWepKeyText[KFourthKey]); |
|
279 OstTraceFunctionExit1(CPWEPUI_CREATEWEPKEYFOURGROUP_EXIT,this); |
|
280 } |
|
281 |
|
282 /*! |
|
283 * Slot to handle , if a different wep key (index) |
|
284 * is made active |
|
285 * \param wepKeyInUse index of the chosen wep key |
|
286 */ |
|
287 void CpWepUi::wepKeyInUseChanged(int wepKeyInUse) |
|
288 { |
|
289 OstTraceFunctionEntry1(CPWEPUI_WEPKEYINUSECHANGED_ENTRY,this); |
|
290 |
|
291 int err; |
|
292 //Update CommsDat |
|
293 QT_TRYCATCH_ERROR(err, mCmCM->setIntAttribute(CMManagerShim::WlanWepKeyIndex, wepKeyInUse)); |
|
294 if (err != KErrNone) { |
|
295 OstTrace1( TRACE_ERROR, CPWEPUI_WEPKEYINUSECHANGED, "Error wepKeyInUse returned %d", err ); |
|
296 } |
|
297 tryUpdate(); |
|
298 OstTraceFunctionExit1(CPWEPUI_WEPKEYINUSECHANGED_EXIT,this); |
|
299 } |
|
300 |
|
301 /*! |
|
302 * Slot to handle ,when the |
|
303 * wep key one string gets changed |
|
304 * |
|
305 * |
|
306 */ |
|
307 void CpWepUi::wepKeyOneChanged() |
|
308 { |
|
309 int err; |
|
310 OstTraceFunctionEntry1(CPWEPUI_WEPKEY1STRINGCHANGED_ENTRY,this); |
|
311 QT_TRYCATCH_ERROR(err, wepKeyTextChanged(KFirstKey)); |
|
312 if (err != KErrNone) { |
|
313 OstTrace1( TRACE_ERROR,CPWEPUI_WEPKEYONECHANGED, "Error wepKeyOneChanged returned %d", err ); |
|
314 } |
|
315 OstTraceFunctionExit1(CPWEPUI_WEPKEY1STRINGCHANGED_EXIT,this); |
|
316 } |
|
317 |
|
318 /*! |
|
319 * Slot to handle ,when the |
|
320 * wep key two string gets changed |
|
321 * |
|
322 * |
|
323 */ |
|
324 void CpWepUi::wepKeyTwoChanged() |
|
325 { |
|
326 int err; |
|
327 OstTraceFunctionEntry1(CPWEPUI_WEPKEY2STRINGCHANGED_ENTRY,this); |
|
328 QT_TRYCATCH_ERROR(err, wepKeyTextChanged(KSecondKey)); |
|
329 if (err != KErrNone) { |
|
330 OstTrace1( TRACE_ERROR, CPWEPUI_WEPKEYTWOCHANGED, "Error wepKeyTwoChanged returned %d", err ); |
|
331 } |
|
332 OstTraceFunctionExit1(CPWEPUI_WEPKEY2STRINGCHANGED_EXIT,this); |
|
333 } |
|
334 |
|
335 /*! |
|
336 * Slot to handle ,when the |
|
337 * wep key three string gets changed |
|
338 * |
|
339 * |
|
340 */ |
|
341 void CpWepUi::wepKeyThreeChanged() |
|
342 { |
|
343 int err; |
|
344 OstTraceFunctionEntry1(CPWEPUI_WEPKEY3STRINGCHANGED_ENTRY,this); |
|
345 QT_TRYCATCH_ERROR(err, wepKeyTextChanged(KThirdKey)); |
|
346 if (err != KErrNone) { |
|
347 OstTrace1( TRACE_ERROR,CPWEPUI_WEPKEYTHREECHANGED, "Error wepKeyThreeChanged returned %d", err ); |
|
348 } |
|
349 OstTraceFunctionExit1(CPWEPUI_WEPKEY3STRINGCHANGED_EXIT,this); |
|
350 } |
|
351 |
|
352 /*! |
|
353 * Slot to handle ,when the |
|
354 * wep key four string gets changed |
|
355 * |
|
356 * |
|
357 */ |
|
358 void CpWepUi::wepKeyFourChanged() |
|
359 { |
|
360 int err; |
|
361 OstTraceFunctionEntry1(CPWEPUI_WEPKEY4STRINGCHANGED_ENTRY,this); |
|
362 QT_TRYCATCH_ERROR(err, wepKeyTextChanged(KFourthKey)); |
|
363 if (err != KErrNone) { |
|
364 OstTrace1( TRACE_ERROR, CPWEPUI_WEPKEYFOURCHANGED, "Error wepKeyFourChanged returned %d", err ); |
|
365 }OstTraceFunctionExit1(CPWEPUI_WEPKEY4STRINGCHANGED_EXIT,this); |
|
366 } |
|
367 |
|
368 /*! |
|
369 * Slot to handle change in either of the 4 WEP key strings |
|
370 * |
|
371 * \param index of the WEP key that changed |
|
372 */ |
|
373 void CpWepUi::wepKeyTextChanged(int index) |
|
374 { |
|
375 OstTraceFunctionEntry1(CPWEPUI_WEPKEYTEXTCHANGED_ENTRY,this); |
|
376 |
|
377 QVariant value = mWepKeyText[index]->contentWidgetData("text"); |
|
378 |
|
379 WepKeyValidator::KeyStatus keystatus = WepKeyValidator::validateWepKey( |
|
380 value.toString()); |
|
381 |
|
382 if (keystatus == WepKeyValidator::KeyStatusOk) { |
|
383 QString key = value.toString(); |
|
384 |
|
385 //If key is valid set the format of the key |
|
386 setKeyFormat(key, index); |
|
387 |
|
388 //Get the right field to store |
|
389 CMManagerShim::ConnectionMethodAttribute keyEnum = getWEPKeyEnum(index); |
|
390 |
|
391 //Store the WEP key |
|
392 storeWEPKey(keyEnum, key); |
|
393 |
|
394 //Update the latest key into array |
|
395 mKeyData[index] = key; |
|
396 |
|
397 /* |
|
398 * Commit All 4 WEP keys , anyways |
|
399 */ |
|
400 commitWEPkeys(index); |
|
401 } |
|
402 else { |
|
403 showMessageBox(HbMessageBox::MessageTypeWarning, hbTrId( |
|
404 "txt_occ_info_invalid_input")); |
|
405 } |
|
406 OstTraceFunctionExit1(CPWEPUI_WEPKEYTEXTCHANGED_EXIT,this); |
|
407 } |
|
408 |
|
409 /*! |
|
410 * Store the WEP key in Comms |
|
411 * \enumValue the right field represented by the enum value |
|
412 * \key the WEP key String to store |
|
413 */ |
|
414 void CpWepUi::storeWEPKey(CMManagerShim::ConnectionMethodAttribute enumValue, |
|
415 QString& key) |
|
416 { |
|
417 mCmCM->setString8Attribute(enumValue, key); |
|
418 tryUpdate(); |
|
419 } |
|
420 |
|
421 /*! |
|
422 * Set the WEP key format |
|
423 * \key string to identify format |
|
424 * \index of the WEP key |
|
425 */ |
|
426 void CpWepUi::setKeyFormat(QString& key, int index) |
|
427 { |
|
428 if (key.length() == WepKeyValidator::WepHex64BitMaxLength || key.length() |
|
429 == WepKeyValidator::WepHex128BitMaxLength) { |
|
430 mkeyFormat[index] = EFormatHex; |
|
431 } |
|
432 |
|
433 else if (key.length() == WepKeyValidator::WepAscii64BitMaxLength |
|
434 || key.length() == WepKeyValidator::WepAscii128BitMaxLength) { |
|
435 mkeyFormat[index] = EFormatAscii; |
|
436 } |
|
437 } |
|
438 |
|
439 /*!Get the right field in DB |
|
440 * \index of the WEP key |
|
441 */ |
|
442 CMManagerShim::ConnectionMethodAttribute CpWepUi::getWEPKeyEnum(int index) |
|
443 { |
|
444 CMManagerShim::ConnectionMethodAttribute keyenum( |
|
445 CMManagerShim::WlanWepKey1InHex); |
|
446 switch (index) |
|
447 { |
|
448 case KFirstKey: |
|
449 { |
|
450 if (mkeyFormat[index] == EFormatHex) { |
|
451 keyenum = CMManagerShim::WlanWepKey1InHex; |
|
452 } |
|
453 else { |
|
454 keyenum = CMManagerShim::WlanWepKey1InAscii; |
|
455 } |
|
456 } |
|
457 break; |
|
458 |
|
459 case KSecondKey: |
|
460 { |
|
461 if (mkeyFormat[index] == EFormatHex) { |
|
462 keyenum = CMManagerShim::WlanWepKey2InHex; |
|
463 } |
|
464 else { |
|
465 keyenum = CMManagerShim::WlanWepKey2InAscii; |
|
466 } |
|
467 } |
|
468 break; |
|
469 |
|
470 case KThirdKey: |
|
471 { |
|
472 if (mkeyFormat[index] == EFormatHex) { |
|
473 keyenum = CMManagerShim::WlanWepKey3InHex; |
|
474 } |
|
475 else { |
|
476 keyenum = CMManagerShim::WlanWepKey3InAscii; |
|
477 } |
|
478 } |
|
479 break; |
|
480 |
|
481 case KFourthKey: |
|
482 { |
|
483 if (mkeyFormat[index] == EFormatHex) { |
|
484 keyenum = CMManagerShim::WlanWepKey4InHex; |
|
485 } |
|
486 else { |
|
487 keyenum = CMManagerShim::WlanWepKey4InAscii; |
|
488 } |
|
489 } |
|
490 break; |
|
491 |
|
492 default: |
|
493 break; |
|
494 } |
|
495 return keyenum; |
|
496 } |
|
497 /* |
|
498 * Read all security settings from the Comms |
|
499 */ |
|
500 void CpWepUi::loadFieldsFromDataBase() |
|
501 { |
|
502 OstTraceFunctionEntry1(CPWEPUI_LOADFIELDSFROMDATABASE_ENTRY,this); |
|
503 |
|
504 //Wep Key in Use |
|
505 mNewKeySelected = mCmCM->getIntAttribute(CMManagerShim::WlanWepKeyIndex); |
|
506 |
|
507 //All data fetched in Hex Format |
|
508 mKeyData.insert(KFirstKey, mCmCM->getString8Attribute( |
|
509 CMManagerShim::WlanWepKey1InHex)); |
|
510 |
|
511 mKeyData.insert(KSecondKey, mCmCM->getString8Attribute( |
|
512 CMManagerShim::WlanWepKey2InHex)); |
|
513 |
|
514 mKeyData.insert(KThirdKey, mCmCM->getString8Attribute( |
|
515 CMManagerShim::WlanWepKey3InHex)); |
|
516 |
|
517 mKeyData.insert(KFourthKey, mCmCM->getString8Attribute( |
|
518 CMManagerShim::WlanWepKey4InHex)); |
|
519 |
|
520 /*Set all key formats to Hex by default; because all keys are read in Hex from DB*/ |
|
521 for (int count = 0; count < KMaxNumberofKeys; count++) |
|
522 { |
|
523 mkeyFormat[count] = EFormatHex; |
|
524 } |
|
525 |
|
526 OstTraceFunctionExit1(CPWEPUI_LOADFIELDSFROMDATABASE_EXIT,this); |
|
527 } |
|
528 |
|
529 /*! |
|
530 Tries to update connection method changes to CommsDat. |
|
531 Returns "true" if success, "false" if some error happened. |
|
532 */ |
|
533 bool CpWepUi::tryUpdate() |
|
534 { |
|
535 OstTraceFunctionEntry1(CPWEPUI_TRYUPDATE_ENTRY,this); |
|
536 |
|
537 bool ret(true); |
|
538 // Try update |
|
539 try { |
|
540 mCmCM->update(); |
|
541 } |
|
542 catch (const std::exception&) { |
|
543 // Handle error |
|
544 handleUpdateError(); |
|
545 ret = false; |
|
546 } |
|
547 |
|
548 OstTraceFunctionExit1(DUP1_CPWEPUI_TRYUPDATE_EXIT,this); |
|
549 return ret; |
|
550 } |
|
551 |
|
552 /*! |
|
553 Handles failed CommsDat update. |
|
554 */ |
|
555 void CpWepUi::handleUpdateError() |
|
556 { |
|
557 OstTraceFunctionEntry1(CPWEPUI_HANDLEUPDATEERROR_ENTRY,this); |
|
558 |
|
559 // Show error note to user |
|
560 showMessageBox(HbMessageBox::MessageTypeWarning, hbTrId( |
|
561 "txt_occ_info_unable_to_save_setting")); |
|
562 // Reload settings from CommsDat and update UI |
|
563 try { |
|
564 mCmCM->refresh(); |
|
565 } |
|
566 catch (const std::exception&) { |
|
567 // Ignore error from refresh. Most likely this will not happen, but |
|
568 // if it does, there isn't very much we can do. |
|
569 OstTrace0( |
|
570 TRACE_ERROR, |
|
571 CPWEPPLUGIN_HANDLEUPDATEERROR, |
|
572 "Refresh failed"); |
|
573 }; |
|
574 updateWepSettings(); |
|
575 |
|
576 OstTraceFunctionExit1(CPWEPUI_HANDLEUPDATEERROR_EXIT,this); |
|
577 } |
|
578 |
|
579 /*! |
|
580 Shows message box with "OK" button using given text. |
|
581 */ |
|
582 void CpWepUi::showMessageBox(HbMessageBox::MessageBoxType type, |
|
583 const QString &text) |
|
584 { |
|
585 OstTraceFunctionEntry1(CPWEPUI_SHOWMESSAGEBOX_ENTRY,this); |
|
586 |
|
587 // Create a message box |
|
588 mMessageBox = QSharedPointer<HbMessageBox> (new HbMessageBox(type)); |
|
589 mMessageBox->setText(text); |
|
590 mMessageBox->open(); |
|
591 |
|
592 OstTraceFunctionExit1(CPWEPUI_SHOWMESSAGEBOX_EXIT,this); |
|
593 } |
|
594 |
|
595 /*! |
|
596 * Reset the Key Items on the Ui, by reading the previously set value from Comms |
|
597 */ |
|
598 void CpWepUi::updateWepSettings() |
|
599 { |
|
600 OstTraceFunctionEntry1(CPWEPUI_UPDATEWEPSETTINGS_ENTRY,this); |
|
601 //Read values from Comms and update the Ui items; |
|
602 loadFieldsFromDataBase(); |
|
603 |
|
604 mWepKeyText[KFirstKey]->setContentWidgetData("text", mKeyData[KFirstKey]); |
|
605 |
|
606 mWepKeyText[KSecondKey]->setContentWidgetData("text", |
|
607 mKeyData[KSecondKey]); |
|
608 |
|
609 mWepKeyText[KThirdKey]->setContentWidgetData("text", mKeyData[KThirdKey]); |
|
610 |
|
611 mWepKeyText[KFourthKey]->setContentWidgetData("text", |
|
612 mKeyData[KFourthKey]); |
|
613 |
|
614 OstTraceFunctionExit1(CPWEPUI_UPDATEWEPSETTINGS_EXIT,this); |
|
615 } |
|
616 |
|
617 /*! |
|
618 * Commit all WEP keys , except the one which was just set |
|
619 * |
|
620 * \param index ; the index of the key that was just set |
|
621 */ |
|
622 void CpWepUi::commitWEPkeys(int index) |
|
623 { |
|
624 OstTraceFunctionEntry1(CPWEPUI_COMMITWEPKEYS_ENTRY,this); |
|
625 //We have all data in Hex, so setting all WEP keys in hex |
|
626 |
|
627 if (index != KFirstKey) { |
|
628 //Get the right field to store |
|
629 CMManagerShim::ConnectionMethodAttribute keyEnumOne = getWEPKeyEnum( |
|
630 KFirstKey); |
|
631 |
|
632 //Store the WEP key |
|
633 storeWEPKey(keyEnumOne, mKeyData[KFirstKey]); |
|
634 } |
|
635 |
|
636 if (index != KSecondKey) { |
|
637 //Get the right field to store |
|
638 CMManagerShim::ConnectionMethodAttribute keyEnumTwo = getWEPKeyEnum( |
|
639 KSecondKey); |
|
640 |
|
641 //Store the WEP key |
|
642 storeWEPKey(keyEnumTwo, mKeyData[KSecondKey]); |
|
643 } |
|
644 |
|
645 if (index != KThirdKey) { |
|
646 //Get the right field to store |
|
647 CMManagerShim::ConnectionMethodAttribute keyEnumThree = |
|
648 getWEPKeyEnum(KThirdKey); |
|
649 |
|
650 //Store the WEP key |
|
651 storeWEPKey(keyEnumThree, mKeyData[KThirdKey]); |
|
652 } |
|
653 |
|
654 if (index != KFourthKey) { |
|
655 //Get the right field to store |
|
656 CMManagerShim::ConnectionMethodAttribute keyEnumFour = getWEPKeyEnum( |
|
657 KFourthKey); |
|
658 |
|
659 //Store the WEP key |
|
660 storeWEPKey(keyEnumFour, mKeyData[KFourthKey]); |
|
661 } |
|
662 |
|
663 OstTraceFunctionExit1(CPWEPUI_COMMITWEPKEYS_EXIT,this); |
|
664 } |
|
665 |
|
666 Q_EXPORT_PLUGIN2(CpWepUi, CpWepUi) |
|
667 ; |