15 * Control Panel QT UI for WEP configuration |
15 * Control Panel QT UI for WEP configuration |
16 * |
16 * |
17 */ |
17 */ |
18 |
18 |
19 /* |
19 /* |
20 * %version: tr1cfwln#25 % |
20 * %version: tr1cfwln#28 % |
21 */ |
21 */ |
|
22 |
22 |
23 |
23 //User Includes |
24 //User Includes |
24 #include "cpwepui.h" |
25 #include "cpwepui.h" |
25 #include "wepkeyvalidator.h" |
26 #include "wepkeyvalidator.h" |
26 |
|
27 |
27 |
28 // System includes |
28 // System includes |
29 #include <QStringList> |
29 #include <QStringList> |
30 #include <cpitemdatahelper.h> |
30 #include <cpitemdatahelper.h> |
31 #include <cmconnectionmethod_shim.h> |
31 #include <cmconnectionmethod_shim.h> |
32 #include <cmmanagerdefines_shim.h> |
32 #include <cmmanagerdefines_shim.h> |
33 #include <HbLineEdit> |
33 #include <HbLineEdit> |
34 #include <HbTranslator> |
|
35 #include <HbEditorInterface> |
34 #include <HbEditorInterface> |
36 |
35 |
37 //Trace Definition |
36 //Trace Definition |
38 #include "OstTraceDefinitions.h" |
37 #include "OstTraceDefinitions.h" |
39 #ifdef OST_TRACE_COMPILER_IN_USE |
38 #ifdef OST_TRACE_COMPILER_IN_USE |
40 #include "cpwepuiTraces.h" |
39 #include "cpwepuiTraces.h" |
41 #endif |
40 #endif |
42 |
41 |
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 //! Index of first WEP key |
|
49 static const int KFirstKey = 0; |
|
50 |
|
51 //! Index of second WEP key |
|
52 static const int KSecondKey = 1; |
|
53 |
|
54 //! Index of third WEP key |
|
55 static const int KThirdKey = 2; |
|
56 |
|
57 //! Index of fourth WEP key |
|
58 static const int KFourthKey = 3; |
|
59 |
|
60 //!Maximum allowed length for WEP keys, in hex mode |
|
61 static const int KMaxKeyLength = 26; |
|
62 |
|
63 |
|
64 |
|
65 /*! |
42 /*! |
66 \class CpWepUi |
43 \class CpWepUi |
67 \brief CpWepUi implements the WEP Security Settings Control Panel Plugin |
44 \brief CpWepUi implements the WEP Security Settings Control Panel Plugin |
68 which will allow viewing/editing of WEP Security Settings. |
45 which will allow viewing/editing of WEP Security Settings. |
69 */ |
46 */ |
70 //Contructs WEP object |
47 |
71 CpWepUi::CpWepUi() : |
48 // External function prototypes |
72 mUi(NULL), |
49 |
|
50 // Local constants |
|
51 |
|
52 //! Index of first WEP key |
|
53 static const int KFirstKey = 0; |
|
54 |
|
55 //! Index of second WEP key |
|
56 static const int KSecondKey = 1; |
|
57 |
|
58 //! Index of third WEP key |
|
59 static const int KThirdKey = 2; |
|
60 |
|
61 //! Index of fourth WEP key |
|
62 static const int KFourthKey = 3; |
|
63 |
|
64 //!Maximum allowed length for WEP keys, in hex mode |
|
65 static const int KMaxKeyLength = 26; |
|
66 |
|
67 |
|
68 |
|
69 // ======== LOCAL FUNCTIONS ======== |
|
70 |
|
71 |
|
72 // ======== MEMBER FUNCTIONS ======== |
|
73 |
|
74 /*! |
|
75 Contructs WEP object |
|
76 */ |
|
77 CpWepUi::CpWepUi( |
|
78 CpItemDataHelper* dataHelper, |
|
79 CmConnectionMethodShim* cmCM) : |
|
80 CpSettingFormItemData( |
|
81 HbDataFormModelItem::GroupItem, |
|
82 hbTrId("txt_occ_subhead_security_settings")), |
73 mNewKeySelected(0), |
83 mNewKeySelected(0), |
74 mTranslator(new HbTranslator("cpwlansecsettingsplugin")), |
84 mCmCM(cmCM), |
75 mCmCM(NULL), |
85 mItemDataHelper(dataHelper) |
76 mCmId(0) |
86 { |
77 { |
87 OstTraceExt1( TRACE_FLOW, CPWEPUI_CPWEPUI, "CpWepUi::CpWepUi - entry;cmCM=%p", cmCM ); |
|
88 |
78 //Initialize array members |
89 //Initialize array members |
79 for(int index=0;index<KMaxNumberofKeys;index++) |
90 for(int index=0;index<KMaxNumberofKeys;index++) { |
80 { |
|
81 mWepKey[index] = NULL; |
91 mWepKey[index] = NULL; |
82 mWepKeyText[index] = NULL; |
92 mWepKeyText[index] = NULL; |
83 mkeyFormat[index] = EFormatHex; |
93 mkeyFormat[index] = EFormatHex; |
84 } |
94 } |
85 |
95 |
86 } |
96 createUi(); |
87 |
97 |
88 //Deletes all objects WEP owns |
98 OstTraceExt1( TRACE_FLOW, DUP1_CPWEPUI_CPWEPUI, "CpWepUi::CpWepUi - exit;this=%p", this ); |
|
99 } |
|
100 |
|
101 /*! |
|
102 Deletes all objects WEP owns |
|
103 */ |
89 CpWepUi::~CpWepUi() |
104 CpWepUi::~CpWepUi() |
90 { |
105 { |
91 OstTraceFunctionEntry1(CPWEPUI_CPWEPUI_ENTRY,this); |
106 OstTraceExt1( TRACE_FLOW, DUP2_CPWEPUI_CPWEPUI, "CpWepUi::~CpWepUi - entry;this=%p", this ); |
92 //Elements like mUi and components that belong to it |
107 OstTrace0( TRACE_FLOW, DUP3_CPWEPUI_CPWEPUI, "CpWepUi::~CpWepUi - exit" ); |
93 //, are taken care by the parent |
108 } |
94 delete mTranslator; |
109 |
95 OstTraceFunctionExit1(CPWEPUI_CPWEPUI_EXIT,this); |
110 /*! |
96 } |
111 Returns the fully constructed Ui Group , for WEP security plugin |
97 |
112 */ |
98 // ======== MEMBER FUNCTIONS ======== |
113 void CpWepUi::createUi() |
99 |
|
100 |
|
101 /*! |
|
102 Getter for security mode. |
|
103 |
|
104 \return Security mode identifier |
|
105 */ |
|
106 CMManagerShim::WlanSecMode CpWepUi::securityMode() const |
|
107 { |
|
108 OstTraceFunctionEntry1(CPWEPUI_SECURITYMODE_ENTRY,this); |
|
109 OstTraceFunctionExit1(CPWEPUI_SECURITYMODE_EXIT,this); |
|
110 //return security mode |
|
111 return CMManagerShim::WlanSecModeWep; |
|
112 } |
|
113 |
|
114 /*! |
|
115 Getter for localization text identifier for the security mode, |
|
116 f.ex. "txt_occ_setlabel_wlan_security_mode_val_wep". This localized |
|
117 text will be shown in the UI. |
|
118 |
|
119 \return Localization text ID |
|
120 */ |
|
121 QString CpWepUi::securityModeTextId() const |
|
122 { |
|
123 OstTraceFunctionEntry1( CPWEPUI_SECURITYMODETEXTID_ENTRY, this ); |
|
124 OstTraceFunctionExit1( CPWEPUI_SECURITYMODETEXTID_EXIT, this ); |
|
125 return "txt_occ_setlabel_wlan_security_mode_val_wep"; |
|
126 } |
|
127 |
|
128 /*! |
|
129 Sets the database reference Iap id. |
|
130 |
|
131 \param id Database reference |
|
132 */ |
|
133 void CpWepUi::setReference(CmConnectionMethodShim *cmCm, uint id) |
|
134 { |
|
135 OstTraceFunctionEntry1(CPWEPUI_SETREFERENCE_ENTRY,this); |
|
136 mCmId = id; |
|
137 |
|
138 //mCmCM is not deleted assuming CmManager owns it. |
|
139 mCmCM = cmCm; |
|
140 OstTraceFunctionExit1(CPWEPUI_SETREFERENCE_EXIT,this); |
|
141 } |
|
142 |
|
143 /*! |
|
144 Getter for order number. This order number is used by the client of |
|
145 this interface to put the security modes in correct order in the list. |
|
146 |
|
147 \return An order number |
|
148 */ |
|
149 int CpWepUi::orderNumber() const |
|
150 { |
|
151 OstTraceFunctionEntry1(CPWEPUI_ORDERNUMBER_ENTRY,this); |
|
152 OstTraceFunctionExit1(CPWEPUI_ORDERNUMBER_EXIT,this); |
|
153 return UI_ORDER_WEP; |
|
154 } |
|
155 |
|
156 /*! |
|
157 * Returns the fully constructed Ui Group , for WEP security plugin |
|
158 * |
|
159 * \param dataHelper to add Connections |
|
160 * |
|
161 * \return The WEP UI |
|
162 */ |
|
163 CpSettingFormItemData* CpWepUi::uiInstance(CpItemDataHelper &dataHelpper) |
|
164 { |
114 { |
165 int err; |
115 int err; |
166 OstTraceFunctionEntry1(CPWEPUI_UIINSTANCE_ENTRY,this); |
116 |
167 |
117 OstTrace0( TRACE_FLOW, DUP1_CPWEPUI_CREATEUI, "CpWepUi::createUi - entry" ); |
|
118 |
168 //Read values From CommsDatbase |
119 //Read values From CommsDatbase |
169 QT_TRYCATCH_ERROR(err, loadFieldsFromDataBase()); |
120 QT_TRYCATCH_ERROR(err, loadFieldsFromDataBase()); |
170 if (err != KErrNone) { |
121 if (err != KErrNone) { |
171 OstTrace1( TRACE_ERROR, CPWEPUI_UIINSTANCE, "LoadFromDataBase returned %d", err ); |
122 OstTrace1( TRACE_ERROR, CPWEPUI_CREATEUI, "CpWepUi::createUi - [ERROR]: loadFromDataBase failed;err=%d", err ); |
172 } |
123 } |
173 |
124 |
174 //Store the address of the Data Helper |
125 setContentWidgetData("objectName", "CpWepUi"); |
175 mItemDataHelper = &dataHelpper; |
|
176 |
|
177 mUi = new CpSettingFormItemData(HbDataFormModelItem::GroupItem, hbTrId( |
|
178 "txt_occ_subhead_security_settings")); |
|
179 |
|
180 mUi->setContentWidgetData("objectName", "CpWepUi"); |
|
181 |
126 |
182 CpSettingFormItemData *wepKeyInUse = new CpSettingFormItemData( |
127 CpSettingFormItemData *wepKeyInUse = new CpSettingFormItemData( |
183 HbDataFormModelItem::ComboBoxItem, hbTrId( |
128 HbDataFormModelItem::ComboBoxItem, hbTrId( |
184 "txt_occ_setlabel_wep_key_in_use")); |
129 "txt_occ_setlabel_wep_key_in_use")); |
185 QStringList wepKeys; |
130 QStringList wepKeys; |
186 wepKeys.append(hbTrId("txt_occ_setlabel_wep_key_in_val_1")); |
131 wepKeys.append(hbTrId("txt_occ_setlabel_wep_key_in_val_1")); |
187 wepKeys.append(hbTrId("txt_occ_setlabel_wep_key_in_val_2")); |
132 wepKeys.append(hbTrId("txt_occ_setlabel_wep_key_in_val_2")); |
188 wepKeys.append(hbTrId("txt_occ_setlabel_wep_key_in_val_3")); |
133 wepKeys.append(hbTrId("txt_occ_setlabel_wep_key_in_val_3")); |
189 wepKeys.append(hbTrId("txt_occ_setlabel_wep_key_in_val_4")); |
134 wepKeys.append(hbTrId("txt_occ_setlabel_wep_key_in_val_4")); |
190 |
135 |
191 wepKeyInUse->setContentWidgetData("items", wepKeys); |
136 wepKeyInUse->setContentWidgetData("items", wepKeys); |
192 wepKeyInUse->setContentWidgetData("currentIndex", mNewKeySelected); |
137 wepKeyInUse->setContentWidgetData("currentIndex", mNewKeySelected); |
193 wepKeyInUse->setContentWidgetData("objectName", "CpWepUiKeyInUse"); |
138 wepKeyInUse->setContentWidgetData("objectName", "CpWepUiKeyInUse"); |
194 |
139 |
195 dataHelpper.addConnection(wepKeyInUse, SIGNAL(currentIndexChanged(int)), |
140 mItemDataHelper->addConnection(wepKeyInUse, SIGNAL(currentIndexChanged(int)), |
196 this, SLOT(wepKeyInUseChanged(int))); |
141 this, SLOT(wepKeyInUseChanged(int))); |
197 mUi->appendChild(wepKeyInUse); |
142 appendChild(wepKeyInUse); |
198 |
143 |
199 //Create Ui for all 4 WEP keys |
144 //Create Ui for all 4 WEP keys |
200 createWEPKeyGroup(KFirstKey); |
145 createWEPKeyGroup(KFirstKey); |
201 |
146 |
202 createWEPKeyGroup(KSecondKey); |
147 createWEPKeyGroup(KSecondKey); |
281 QString objectName; |
224 QString objectName; |
282 objectName.setNum(index); |
225 objectName.setNum(index); |
283 objectName.prepend("CpWepUiKeyEditor"); |
226 objectName.prepend("CpWepUiKeyEditor"); |
284 mWepKeyText[index]->setContentWidgetData("objectName", objectName); |
227 mWepKeyText[index]->setContentWidgetData("objectName", objectName); |
285 |
228 |
286 mUi->appendChild(mWepKeyText[index]); |
229 appendChild(mWepKeyText[index]); |
287 OstTraceFunctionExit1(CPWEPUI_CREATEWEPKEYGROUP_EXIT,this); |
230 |
288 } |
231 OstTrace0( TRACE_FLOW, DUP1_CPWEPUI_CREATEWEPKEYGROUP, "CpWepUi::createWEPKeyGroup - exit" ); |
289 |
232 } |
290 |
233 |
291 /*! |
234 |
292 * Add signals to all the text Edit of WEP key groups. |
235 /*! |
293 * |
236 Add signals to all the text Edit of WEP key groups. |
294 * \param dataHelper ; to add Connections |
237 |
295 */ |
238 \param dataHelper ; to add Connections |
296 void CpWepUi::addConnections(CpItemDataHelper &dataHelpper) |
239 */ |
297 { |
240 void CpWepUi::addConnections(CpItemDataHelper* dataHelper) |
298 OstTraceFunctionEntry1( CPWEPUI_ADDCONNECTIONS_ENTRY, this ); |
241 { |
299 |
242 OstTrace0( TRACE_FLOW, CPWEPUI_ADDCONNECTIONS, "CpWepUi::addConnections - entry" ); |
300 dataHelpper.addConnection(mWepKeyText[KFirstKey], |
243 |
301 SIGNAL( editingFinished ()), this, SLOT(wepKeyOneChanged() )); |
244 dataHelper->addConnection(mWepKeyText[KFirstKey], |
302 |
245 SIGNAL( editingFinished ()), this, SLOT(wepKeyOneChanged() )); |
303 dataHelpper.addConnection(mWepKeyText[KSecondKey], |
246 |
304 SIGNAL( editingFinished ()), this, SLOT(wepKeyTwoChanged() )); |
247 dataHelper->addConnection(mWepKeyText[KSecondKey], |
305 |
248 SIGNAL( editingFinished ()), this, SLOT(wepKeyTwoChanged() )); |
306 dataHelpper.addConnection(mWepKeyText[KThirdKey], |
249 |
307 SIGNAL( editingFinished ()), this, SLOT(wepKeyThreeChanged() )); |
250 dataHelper->addConnection(mWepKeyText[KThirdKey], |
308 |
251 SIGNAL( editingFinished ()), this, SLOT(wepKeyThreeChanged() )); |
309 dataHelpper.addConnection(mWepKeyText[KFourthKey], |
252 |
310 SIGNAL( editingFinished ()), this, SLOT(wepKeyFourChanged() )); |
253 dataHelper->addConnection(mWepKeyText[KFourthKey], |
311 |
254 SIGNAL( editingFinished ()), this, SLOT(wepKeyFourChanged() )); |
312 dataHelpper.connectToForm(SIGNAL(itemShown (const QModelIndex &) ), |
255 |
313 this, SLOT(setEditorPreferences(const QModelIndex &))); |
256 dataHelper->connectToForm(SIGNAL(itemShown (const QModelIndex &) ), |
|
257 this, SLOT(setEditorPreferences(const QModelIndex &))); |
|
258 |
|
259 OstTrace0( TRACE_FLOW, DUP1_CPWEPUI_ADDCONNECTIONS, "CpWepUi::addConnections - exit" ); |
|
260 } |
|
261 |
|
262 /*! |
|
263 General method for handling WEP key string change |
|
264 |
|
265 \param index of the WEP key that changed |
|
266 */ |
|
267 void CpWepUi::wepKeyTextChanged(int index) |
|
268 { |
|
269 OstTrace1( TRACE_FLOW, DUP1_CPWEPUI_WEPKEYTEXTCHANGED, "CpWepUi::wepKeyTextChanged - entry;index=%d", index ); |
|
270 |
|
271 QVariant value = mWepKeyText[index]->contentWidgetData("text"); |
|
272 QString key = value.toString(); |
|
273 |
|
274 WepKeyValidator::KeyStatus keystatus = WepKeyValidator::validateWepKey(key); |
|
275 |
|
276 // allow storing an empty key to enable clearing WEP keys |
|
277 if (keystatus == WepKeyValidator::KeyStatusOk || key.length() == 0) { |
|
278 //If key is valid set the format of the key |
|
279 setKeyFormat(key, index); |
|
280 |
|
281 //Get the right field to store |
|
282 CMManagerShim::ConnectionMethodAttribute keyEnum = getWEPKeyEnum(index); |
|
283 |
|
284 //Store the WEP key |
|
285 storeWEPKey(keyEnum, key); |
|
286 |
|
287 //Update the latest key into array |
|
288 mKeyData[index] = key; |
|
289 |
|
290 /* |
|
291 * Commit All 4 WEP keys , anyways |
|
292 */ |
|
293 commitWEPkeys(index); |
|
294 } else { |
|
295 OstTrace0( TRACE_ERROR, CPWEPUI_WEPKEYTEXTCHANGED, "CpWepUi::wepKeyTextChanged - [ERROR]: invalid WEP key input" ); |
|
296 |
|
297 showMessageBox(HbMessageBox::MessageTypeWarning, hbTrId( |
|
298 "txt_occ_info_invalid_input")); |
|
299 } |
|
300 |
|
301 OstTrace0( TRACE_FLOW, DUP2_CPWEPUI_WEPKEYTEXTCHANGED, "CpWepUi::wepKeyTextChanged - exit" ); |
|
302 } |
|
303 |
|
304 /*! |
|
305 Store the WEP key in Comms |
314 |
306 |
315 OstTraceFunctionExit1( CPWEPUI_ADDCONNECTIONS_EXIT, this ); |
307 \param enumValue the right field represented by the enum value |
316 } |
308 \param key the WEP key String to store |
317 |
309 */ |
318 |
310 void CpWepUi::storeWEPKey(CMManagerShim::ConnectionMethodAttribute enumValue, |
319 /*! |
311 QString& key) |
320 * Slot to handle , if a different wep key (index) |
312 { |
321 * is made active |
313 OstTrace1( TRACE_FLOW, CPWEPUI_STOREWEPKEY, "CpWepUi::storeWEPKey - entry;enumValue=%d", enumValue ); |
322 * \param wepKeyInUse index of the chosen wep key |
314 |
|
315 mCmCM->setString8Attribute(enumValue, key); |
|
316 tryUpdate(); |
|
317 |
|
318 OstTrace0( TRACE_FLOW, DUP1_CPWEPUI_STOREWEPKEY, "CpWepUi::storeWEPKey - exit" ); |
|
319 } |
|
320 |
|
321 /*! |
|
322 Set the WEP key format |
|
323 |
|
324 \param key string to identify format |
|
325 \param index of the WEP key |
|
326 */ |
|
327 void CpWepUi::setKeyFormat(QString& key, int index) |
|
328 { |
|
329 OstTrace1( TRACE_FLOW, CPWEPUI_SETKEYFORMAT, "CpWepUi::setKeyFormat - entry;index=%d", index ); |
|
330 |
|
331 if (key.length() == WepKeyValidator::WepHex64BitMaxLength || |
|
332 key.length() == WepKeyValidator::WepHex128BitMaxLength) { |
|
333 OstTrace0( TRACE_FLOW, DUP2_CPWEPUI_SETKEYFORMAT, "CpWepUi::setKeyFormat - format HEX" ); |
|
334 mkeyFormat[index] = EFormatHex; |
|
335 } else if (key.length() == WepKeyValidator::WepAscii64BitMaxLength || |
|
336 key.length() == WepKeyValidator::WepAscii128BitMaxLength) { |
|
337 OstTrace0( TRACE_FLOW, DUP3_CPWEPUI_SETKEYFORMAT, "CpWepUi::setKeyFormat - format ASCII" ); |
|
338 mkeyFormat[index] = EFormatAscii; |
|
339 } |
|
340 |
|
341 OstTrace0( TRACE_FLOW, DUP1_CPWEPUI_SETKEYFORMAT, "CpWepUi::setKeyFormat - exit" ); |
|
342 } |
|
343 |
|
344 /*!Get the right field in DB |
|
345 |
|
346 \param index of the WEP key |
|
347 */ |
|
348 CMManagerShim::ConnectionMethodAttribute CpWepUi::getWEPKeyEnum(int index) |
|
349 { |
|
350 OstTrace1( TRACE_FLOW, CPWEPUI_GETWEPKEYENUM, "CpWepUi::getWEPKeyEnum - entry;index=%d", index ); |
|
351 |
|
352 CMManagerShim::ConnectionMethodAttribute keyenum( |
|
353 CMManagerShim::WlanWepKey1InHex); |
|
354 |
|
355 switch (index) { |
|
356 case KFirstKey: |
|
357 { |
|
358 if (mkeyFormat[index] == EFormatHex) { |
|
359 keyenum = CMManagerShim::WlanWepKey1InHex; |
|
360 } else { |
|
361 keyenum = CMManagerShim::WlanWepKey1InAscii; |
|
362 } |
|
363 } |
|
364 break; |
|
365 |
|
366 case KSecondKey: |
|
367 { |
|
368 if (mkeyFormat[index] == EFormatHex) { |
|
369 keyenum = CMManagerShim::WlanWepKey2InHex; |
|
370 } else { |
|
371 keyenum = CMManagerShim::WlanWepKey2InAscii; |
|
372 } |
|
373 } |
|
374 break; |
|
375 |
|
376 case KThirdKey: |
|
377 { |
|
378 if (mkeyFormat[index] == EFormatHex) { |
|
379 keyenum = CMManagerShim::WlanWepKey3InHex; |
|
380 } else { |
|
381 keyenum = CMManagerShim::WlanWepKey3InAscii; |
|
382 } |
|
383 } |
|
384 break; |
|
385 |
|
386 case KFourthKey: |
|
387 { |
|
388 if (mkeyFormat[index] == EFormatHex) { |
|
389 keyenum = CMManagerShim::WlanWepKey4InHex; |
|
390 } else { |
|
391 keyenum = CMManagerShim::WlanWepKey4InAscii; |
|
392 } |
|
393 } |
|
394 break; |
|
395 |
|
396 default: |
|
397 break; |
|
398 } |
|
399 |
|
400 OstTrace1( TRACE_FLOW, DUP1_CPWEPUI_GETWEPKEYENUM, "CpWepUi::getWEPKeyEnum - exit;keyenum=%d", keyenum ); |
|
401 |
|
402 return keyenum; |
|
403 } |
|
404 |
|
405 /*! |
|
406 Read all security settings from the Comms |
|
407 */ |
|
408 void CpWepUi::loadFieldsFromDataBase() |
|
409 { |
|
410 OstTrace0( TRACE_FLOW, CPWEPUI_LOADFIELDSFROMDATABASE, "CpWepUi::loadFieldsFromDataBase - entry" ); |
|
411 |
|
412 //Wep Key in Use |
|
413 mNewKeySelected = mCmCM->getIntAttribute(CMManagerShim::WlanWepKeyIndex); |
|
414 |
|
415 //All data fetched in Hex Format |
|
416 mKeyData.insert(KFirstKey, mCmCM->getString8Attribute( |
|
417 CMManagerShim::WlanWepKey1InHex)); |
|
418 |
|
419 OstTrace0( TRACE_FLOW, DUP2_CPWEPUI_LOADFIELDSFROMDATABASE, "CpWepUi::loadFieldsFromDataBase - 1st key fetched" ); |
|
420 |
|
421 mKeyData.insert(KSecondKey,mCmCM->getString8Attribute( |
|
422 CMManagerShim::WlanWepKey2InHex)); |
|
423 |
|
424 OstTrace0( TRACE_FLOW, DUP3_CPWEPUI_LOADFIELDSFROMDATABASE, "CpWepUi::loadFieldsFromDataBase - 2nd key fetched" ); |
|
425 |
|
426 mKeyData.insert(KThirdKey, mCmCM->getString8Attribute( |
|
427 CMManagerShim::WlanWepKey3InHex)); |
|
428 |
|
429 OstTrace0( TRACE_FLOW, DUP4_CPWEPUI_LOADFIELDSFROMDATABASE, "CpWepUi::loadFieldsFromDataBase - 3rd key fetched" ); |
|
430 |
|
431 mKeyData.insert(KFourthKey, mCmCM->getString8Attribute( |
|
432 CMManagerShim::WlanWepKey4InHex)); |
|
433 |
|
434 OstTrace0( TRACE_FLOW, DUP5_CPWEPUI_LOADFIELDSFROMDATABASE, "CpWepUi::loadFieldsFromDataBase - 4th key fetched" ); |
|
435 |
|
436 /*Set all key formats to Hex by default; because all keys are read in Hex from DB*/ |
|
437 for (int count = 0; count < KMaxNumberofKeys; count++) { |
|
438 mkeyFormat[count] = EFormatHex; |
|
439 } |
|
440 |
|
441 OstTrace0( TRACE_FLOW, DUP1_CPWEPUI_LOADFIELDSFROMDATABASE, "CpWepUi::loadFieldsFromDataBase - exit" ); |
|
442 } |
|
443 |
|
444 /*! |
|
445 Tries to update connection method changes to CommsDat. |
|
446 Returns "true" if success, "false" if some error happened. |
|
447 */ |
|
448 bool CpWepUi::tryUpdate() |
|
449 { |
|
450 OstTrace0( TRACE_FLOW, CPWEPUI_TRYUPDATE, "CpWepUi::tryUpdate - entry" ); |
|
451 |
|
452 bool ret(true); |
|
453 // Try update |
|
454 try { |
|
455 mCmCM->update(); |
|
456 } |
|
457 catch (const std::exception&) { |
|
458 OstTrace0( TRACE_ERROR, DUP2_CPWEPUI_TRYUPDATE, "CpWepUi::tryUpdate - [ERROR]: updating settings into database failed" ); |
|
459 |
|
460 // Handle error |
|
461 handleUpdateError(); |
|
462 ret = false; |
|
463 } |
|
464 |
|
465 OstTrace1( TRACE_FLOW, DUP1_CPWEPUI_TRYUPDATE, "CpWepUi::tryUpdate - exit;ret=%d", ret ); |
|
466 |
|
467 return ret; |
|
468 } |
|
469 |
|
470 /*! |
|
471 Handles failed CommsDat update. |
|
472 */ |
|
473 void CpWepUi::handleUpdateError() |
|
474 { |
|
475 OstTrace0( TRACE_FLOW, DUP1_CPWEPUI_HANDLEUPDATEERROR, "CpWepUi::handleUpdateError - entry" ); |
|
476 |
|
477 // Show error note to user |
|
478 showMessageBox(HbMessageBox::MessageTypeWarning, hbTrId( |
|
479 "txt_occ_info_unable_to_save_setting")); |
|
480 |
|
481 // Reload settings from CommsDat and update UI |
|
482 try { |
|
483 mCmCM->refresh(); |
|
484 } |
|
485 catch (const std::exception&) { |
|
486 // Ignore error from refresh. Most likely this will not happen, but |
|
487 // if it does, there isn't very much we can do. |
|
488 OstTrace0( TRACE_ERROR, CPWEPUI_HANDLEUPDATEERROR, "CpWepUi::handleUpdateError - [ERROR]: refreshing settings from database failed" ); |
|
489 } |
|
490 |
|
491 updateWepSettings(); |
|
492 |
|
493 OstTrace0( TRACE_FLOW, DUP2_CPWEPUI_HANDLEUPDATEERROR, "CpWepUi::handleUpdateError - exit" ); |
|
494 } |
|
495 |
|
496 /*! |
|
497 Shows message box with "OK" button using given text. |
|
498 */ |
|
499 void CpWepUi::showMessageBox(HbMessageBox::MessageBoxType type, |
|
500 const QString &text) |
|
501 { |
|
502 OstTrace0( TRACE_FLOW, CPWEPUI_SHOWMESSAGEBOX, "CpWepUi::showMessageBox - entry" ); |
|
503 |
|
504 // Create a message box |
|
505 mMessageBox = QSharedPointer<HbMessageBox> (new HbMessageBox(type)); |
|
506 mMessageBox->setObjectName("CpWepUiMessageBox"); |
|
507 mMessageBox->setText(text); |
|
508 mMessageBox->open(); |
|
509 |
|
510 OstTrace0( TRACE_FLOW, DUP1_CPWEPUI_SHOWMESSAGEBOX, "CpWepUi::showMessageBox - exit" ); |
|
511 } |
|
512 |
|
513 /*! |
|
514 * Reset the Key Items on the Ui, by reading the previously set value from Comms |
|
515 */ |
|
516 void CpWepUi::updateWepSettings() |
|
517 { |
|
518 OstTrace0( TRACE_FLOW, CPWEPUI_UPDATEWEPSETTINGS, "CpWepUi::updateWepSettings - entry" ); |
|
519 |
|
520 //Read values from Comms and update the Ui items; |
|
521 loadFieldsFromDataBase(); |
|
522 |
|
523 mWepKeyText[KFirstKey]->setContentWidgetData("text", mKeyData[KFirstKey]); |
|
524 |
|
525 mWepKeyText[KSecondKey]->setContentWidgetData("text", |
|
526 mKeyData[KSecondKey]); |
|
527 |
|
528 mWepKeyText[KThirdKey]->setContentWidgetData("text", mKeyData[KThirdKey]); |
|
529 |
|
530 mWepKeyText[KFourthKey]->setContentWidgetData("text", |
|
531 mKeyData[KFourthKey]); |
|
532 |
|
533 OstTrace0( TRACE_FLOW, DUP1_CPWEPUI_UPDATEWEPSETTINGS, "CpWepUi::updateWepSettings - exit" ); |
|
534 } |
|
535 |
|
536 /*! |
|
537 Commit all WEP keys , except the one which was just set |
|
538 |
|
539 \param index ; the index of the key that was just set |
|
540 */ |
|
541 void CpWepUi::commitWEPkeys(int index) |
|
542 { |
|
543 OstTrace0( TRACE_FLOW, CPWEPUI_COMMITWEPKEYS, "CpWepUi::commitWEPkeys - entry" ); |
|
544 |
|
545 //We have all data in Hex, so setting all WEP keys in hex |
|
546 |
|
547 if (index != KFirstKey) { |
|
548 //Get the right field to store |
|
549 CMManagerShim::ConnectionMethodAttribute keyEnumOne = getWEPKeyEnum( |
|
550 KFirstKey); |
|
551 |
|
552 //Store the WEP key |
|
553 storeWEPKey(keyEnumOne, mKeyData[KFirstKey]); |
|
554 } |
|
555 |
|
556 if (index != KSecondKey) { |
|
557 //Get the right field to store |
|
558 CMManagerShim::ConnectionMethodAttribute keyEnumTwo = getWEPKeyEnum( |
|
559 KSecondKey); |
|
560 |
|
561 //Store the WEP key |
|
562 storeWEPKey(keyEnumTwo, mKeyData[KSecondKey]); |
|
563 } |
|
564 |
|
565 if (index != KThirdKey) { |
|
566 //Get the right field to store |
|
567 CMManagerShim::ConnectionMethodAttribute keyEnumThree = |
|
568 getWEPKeyEnum(KThirdKey); |
|
569 |
|
570 //Store the WEP key |
|
571 storeWEPKey(keyEnumThree, mKeyData[KThirdKey]); |
|
572 } |
|
573 |
|
574 if (index != KFourthKey) { |
|
575 //Get the right field to store |
|
576 CMManagerShim::ConnectionMethodAttribute keyEnumFour = getWEPKeyEnum( |
|
577 KFourthKey); |
|
578 |
|
579 //Store the WEP key |
|
580 storeWEPKey(keyEnumFour, mKeyData[KFourthKey]); |
|
581 } |
|
582 |
|
583 OstTrace0( TRACE_FLOW, DUP1_CPWEPUI_COMMITWEPKEYS, "CpWepUi::commitWEPkeys - exit" ); |
|
584 } |
|
585 |
|
586 /*! |
|
587 Slot to handle , if a different wep key (index) |
|
588 is made active |
|
589 |
|
590 \param wepKeyInUse index of the chosen wep key |
323 */ |
591 */ |
324 void CpWepUi::wepKeyInUseChanged(int wepKeyInUse) |
592 void CpWepUi::wepKeyInUseChanged(int wepKeyInUse) |
325 { |
593 { |
326 OstTraceFunctionEntry1(CPWEPUI_WEPKEYINUSECHANGED_ENTRY,this); |
594 OstTrace1( TRACE_BORDER, CPWEPUI_WEPKEYINUSECHANGED, "CpWepUi::wepKeyInUseChanged - entry [SLOT];wepKeyInUse=%d", wepKeyInUse ); |
327 |
595 |
328 int err; |
596 int err; |
329 //Update CommsDat |
597 //Update CommsDat |
330 QT_TRYCATCH_ERROR(err, mCmCM->setIntAttribute(CMManagerShim::WlanWepKeyIndex, wepKeyInUse)); |
598 QT_TRYCATCH_ERROR(err, mCmCM->setIntAttribute(CMManagerShim::WlanWepKeyIndex, wepKeyInUse)); |
331 if (err != KErrNone) { |
599 if (err != KErrNone) { |
332 OstTrace1( TRACE_ERROR, CPWEPUI_WEPKEYINUSECHANGED, "Error wepKeyInUse returned %d", err ); |
600 OstTrace1( TRACE_ERROR, DUP1_CPWEPUI_WEPKEYINUSECHANGED, "CpWepUi::wepKeyInUseChanged - [ERROR]: writing settings to database failed;err=%d", err ); |
333 } |
601 } |
334 tryUpdate(); |
602 tryUpdate(); |
335 |
603 |
336 //Store the wep key in use |
604 //Store the wep key in use |
337 mNewKeySelected = wepKeyInUse; |
605 mNewKeySelected = wepKeyInUse; |
338 OstTraceFunctionExit1(CPWEPUI_WEPKEYINUSECHANGED_EXIT,this); |
606 |
339 } |
607 OstTrace0( TRACE_BORDER, DUP2_CPWEPUI_WEPKEYINUSECHANGED, "CpWepUi::wepKeyInUseChanged - exit [SLOT]" ); |
340 |
608 } |
341 /*! |
609 |
342 * Slot to handle ,when the |
610 /*! |
343 * wep key one string gets changed |
611 Slot for handling WEP key one string changes |
344 * |
|
345 * |
|
346 */ |
612 */ |
347 void CpWepUi::wepKeyOneChanged() |
613 void CpWepUi::wepKeyOneChanged() |
348 { |
614 { |
|
615 OstTrace0( TRACE_BORDER, CPWEPUI_WEPKEYONECHANGED, "CpWepUi::wepKeyOneChanged - entry [SLOT]" ); |
|
616 |
349 int err; |
617 int err; |
350 OstTraceFunctionEntry1(CPWEPUI_WEPKEY1STRINGCHANGED_ENTRY,this); |
|
351 QT_TRYCATCH_ERROR(err, wepKeyTextChanged(KFirstKey)); |
618 QT_TRYCATCH_ERROR(err, wepKeyTextChanged(KFirstKey)); |
352 if (err != KErrNone) { |
619 if (err != KErrNone) { |
353 OstTrace1( TRACE_ERROR,CPWEPUI_WEPKEYONECHANGED, "Error wepKeyOneChanged returned %d", err ); |
620 OstTrace1( TRACE_ERROR, DUP1_CPWEPUI_WEPKEYONECHANGED, "CpWepUi::wepKeyOneChanged - [ERROR]: wepKeyTextChanged failed;err=%d", err ); |
354 } |
621 } |
355 OstTraceFunctionExit1(CPWEPUI_WEPKEY1STRINGCHANGED_EXIT,this); |
622 |
356 } |
623 OstTrace0( TRACE_BORDER, DUP2_CPWEPUI_WEPKEYONECHANGED, "CpWepUi::wepKeyOneChanged - exit [SLOT]" ); |
357 |
624 } |
358 /*! |
625 |
359 * Slot to handle ,when the |
626 /*! |
360 * wep key two string gets changed |
627 Slot for handling WEP key two string changes |
361 * |
|
362 * |
|
363 */ |
628 */ |
364 void CpWepUi::wepKeyTwoChanged() |
629 void CpWepUi::wepKeyTwoChanged() |
365 { |
630 { |
|
631 OstTrace0( TRACE_BORDER, CPWEPUI_WEPKEYTWOCHANGED, "CpWepUi::wepKeyTwoChanged - entry [SLOT]" ); |
|
632 |
366 int err; |
633 int err; |
367 OstTraceFunctionEntry1(CPWEPUI_WEPKEY2STRINGCHANGED_ENTRY,this); |
|
368 QT_TRYCATCH_ERROR(err, wepKeyTextChanged(KSecondKey)); |
634 QT_TRYCATCH_ERROR(err, wepKeyTextChanged(KSecondKey)); |
369 if (err != KErrNone) { |
635 if (err != KErrNone) { |
370 OstTrace1( TRACE_ERROR, CPWEPUI_WEPKEYTWOCHANGED, "Error wepKeyTwoChanged returned %d", err ); |
636 OstTrace1( TRACE_ERROR, DUP1_CPWEPUI_WEPKEYTWOCHANGED, "CpWepUi::wepKeyTwoChanged - [ERROR]: wepKeyTextChanged failed;err=%d", err ); |
371 } |
637 } |
372 OstTraceFunctionExit1(CPWEPUI_WEPKEY2STRINGCHANGED_EXIT,this); |
638 |
373 } |
639 OstTrace0( TRACE_BORDER, DUP2_CPWEPUI_WEPKEYTWOCHANGED, "CpWepUi::wepKeyTwoChanged - exit [SLOT]" ); |
374 |
640 } |
375 /*! |
641 |
376 * Slot to handle ,when the |
642 /*! |
377 * wep key three string gets changed |
643 Slot for handling WEP key three string changes |
378 * |
|
379 * |
|
380 */ |
644 */ |
381 void CpWepUi::wepKeyThreeChanged() |
645 void CpWepUi::wepKeyThreeChanged() |
382 { |
646 { |
|
647 OstTrace0( TRACE_BORDER, CPWEPUI_WEPKEYTHREECHANGED, "CpWepUi::wepKeyThreeChanged - entry [SLOT]" ); |
|
648 |
383 int err; |
649 int err; |
384 OstTraceFunctionEntry1(CPWEPUI_WEPKEY3STRINGCHANGED_ENTRY,this); |
|
385 QT_TRYCATCH_ERROR(err, wepKeyTextChanged(KThirdKey)); |
650 QT_TRYCATCH_ERROR(err, wepKeyTextChanged(KThirdKey)); |
386 if (err != KErrNone) { |
651 if (err != KErrNone) { |
387 OstTrace1( TRACE_ERROR,CPWEPUI_WEPKEYTHREECHANGED, "Error wepKeyThreeChanged returned %d", err ); |
652 OstTrace1( TRACE_ERROR, DUP1_CPWEPUI_WEPKEYTHREECHANGED, "CpWepUi::wepKeyThreeChanged - [ERROR]: wepKeyTextChanged failed;err=%d", err ); |
388 } |
653 } |
389 OstTraceFunctionExit1(CPWEPUI_WEPKEY3STRINGCHANGED_EXIT,this); |
654 |
390 } |
655 OstTrace0( TRACE_BORDER, DUP2_CPWEPUI_WEPKEYTHREECHANGED, "CpWepUi::wepKeyThreeChanged - exit [SLOT]" ); |
391 |
656 } |
392 /*! |
657 |
393 * Slot to handle ,when the |
658 /*! |
394 * wep key four string gets changed |
659 Slot for handling WEP key four string changes |
395 * |
|
396 * |
|
397 */ |
660 */ |
398 void CpWepUi::wepKeyFourChanged() |
661 void CpWepUi::wepKeyFourChanged() |
399 { |
662 { |
|
663 OstTrace0( TRACE_BORDER, DUP1_CPWEPUI_WEPKEYFOURCHANGED, "CpWepUi::wepKeyFourChanged - entry [SLOT]" ); |
|
664 |
400 int err; |
665 int err; |
401 OstTraceFunctionEntry1(CPWEPUI_WEPKEY4STRINGCHANGED_ENTRY,this); |
|
402 QT_TRYCATCH_ERROR(err, wepKeyTextChanged(KFourthKey)); |
666 QT_TRYCATCH_ERROR(err, wepKeyTextChanged(KFourthKey)); |
403 if (err != KErrNone) { |
667 if (err != KErrNone) { |
404 OstTrace1( TRACE_ERROR, CPWEPUI_WEPKEYFOURCHANGED, "Error wepKeyFourChanged returned %d", err ); |
668 OstTrace1( TRACE_ERROR, CPWEPUI_WEPKEYFOURCHANGED, "CpWepUi::wepKeyFourChanged - [ERROR]: wepKeyTextChanged failed;err=%d", err ); |
405 }OstTraceFunctionExit1(CPWEPUI_WEPKEY4STRINGCHANGED_EXIT,this); |
669 } |
406 } |
670 |
407 |
671 OstTrace0( TRACE_BORDER, DUP2_CPWEPUI_WEPKEYFOURCHANGED, "CpWepUi::wepKeyFourChanged - exit [SLOT]" ); |
408 /*! |
672 } |
409 * Slot to handle change in either of the 4 WEP key strings |
673 |
410 * |
674 |
411 * \param index of the WEP key that changed |
675 /*! |
412 */ |
676 Slot that configures the editor settings for all WEP key fields. |
413 void CpWepUi::wepKeyTextChanged(int index) |
677 This method is invoken whenever a new item(s) are shown in the current view |
414 { |
678 |
415 OstTraceFunctionEntry1(CPWEPUI_WEPKEYTEXTCHANGED_ENTRY,this); |
679 \param modelIndex Index of the current item in the model |
416 |
|
417 QVariant value = mWepKeyText[index]->contentWidgetData("text"); |
|
418 QString key = value.toString(); |
|
419 |
|
420 WepKeyValidator::KeyStatus keystatus = WepKeyValidator::validateWepKey(key); |
|
421 |
|
422 // allow storing an empty key to enable clearing WEP keys |
|
423 if (keystatus == WepKeyValidator::KeyStatusOk || key.length() == 0) { |
|
424 |
|
425 //If key is valid set the format of the key |
|
426 setKeyFormat(key, index); |
|
427 |
|
428 //Get the right field to store |
|
429 CMManagerShim::ConnectionMethodAttribute keyEnum = getWEPKeyEnum(index); |
|
430 |
|
431 //Store the WEP key |
|
432 storeWEPKey(keyEnum, key); |
|
433 |
|
434 //Update the latest key into array |
|
435 mKeyData[index] = key; |
|
436 |
|
437 /* |
|
438 * Commit All 4 WEP keys , anyways |
|
439 */ |
|
440 commitWEPkeys(index); |
|
441 } |
|
442 else { |
|
443 OstTrace0( TRACE_ERROR, CPWEPUI_WEPKEYTEXTCHANGED_ERROR, "CpWepUi::wepKeyTextChanged Invalid WEP Key Input" ); |
|
444 showMessageBox(HbMessageBox::MessageTypeWarning, hbTrId( |
|
445 "txt_occ_info_invalid_input")); |
|
446 } |
|
447 OstTraceFunctionExit1(CPWEPUI_WEPKEYTEXTCHANGED_EXIT,this); |
|
448 } |
|
449 |
|
450 /*! |
|
451 * Slot that configures the editor settings for all WEP key fields. |
|
452 * This slot is invoked whenever a new item(s) are shown in the current view |
|
453 * |
|
454 * \param modelIndex Index of the current item in the model |
|
455 */ |
680 */ |
456 void CpWepUi::setEditorPreferences(const QModelIndex &modelIndex) |
681 void CpWepUi::setEditorPreferences(const QModelIndex &modelIndex) |
457 { |
682 { |
|
683 OstTrace0( TRACE_BORDER, CPWEPUI_SETEDITORPREFERENCES, "CpWepUi::setEditorPreferences - entry [SLOT]" ); |
458 |
684 |
459 HbDataFormModelItem *item = mItemDataHelper->modelItemFromModelIndex(modelIndex); |
685 HbDataFormModelItem *item = mItemDataHelper->modelItemFromModelIndex(modelIndex); |
460 |
686 |
461 HbSmileyTheme smiley; |
687 HbSmileyTheme smiley; |
462 /* Configure settings only for text fields*/ |
688 /* Configure settings only for text fields*/ |
464 HbLineEdit *edit = qobject_cast<HbLineEdit*>(mItemDataHelper->widgetFromModelIndex(modelIndex)); |
690 HbLineEdit *edit = qobject_cast<HbLineEdit*>(mItemDataHelper->widgetFromModelIndex(modelIndex)); |
465 HbEditorInterface editInterface(edit); |
691 HbEditorInterface editInterface(edit); |
466 editInterface.setInputConstraints(HbEditorConstraintLatinAlphabetOnly); |
692 editInterface.setInputConstraints(HbEditorConstraintLatinAlphabetOnly); |
467 edit->setInputMethodHints(Qt::ImhNoPredictiveText); |
693 edit->setInputMethodHints(Qt::ImhNoPredictiveText); |
468 edit->setMaxLength(KMaxKeyLength); |
694 edit->setMaxLength(KMaxKeyLength); |
469 } |
695 } |
470 } |
696 |
471 |
697 OstTrace0( TRACE_BORDER, DUP1_CPWEPUI_SETEDITORPREFERENCES, "CpWepUi::setEditorPreferences - exit [SLOT]" ); |
472 |
698 } |
473 /*! |
699 |
474 * Store the WEP key in Comms |
|
475 * \enumValue the right field represented by the enum value |
|
476 * \key the WEP key String to store |
|
477 */ |
|
478 void CpWepUi::storeWEPKey(CMManagerShim::ConnectionMethodAttribute enumValue, |
|
479 QString& key) |
|
480 { |
|
481 mCmCM->setString8Attribute(enumValue, key); |
|
482 tryUpdate(); |
|
483 } |
|
484 |
|
485 /*! |
|
486 * Set the WEP key format |
|
487 * \key string to identify format |
|
488 * \index of the WEP key |
|
489 */ |
|
490 void CpWepUi::setKeyFormat(QString& key, int index) |
|
491 { |
|
492 if (key.length() == WepKeyValidator::WepHex64BitMaxLength || key.length() |
|
493 == WepKeyValidator::WepHex128BitMaxLength) { |
|
494 mkeyFormat[index] = EFormatHex; |
|
495 } |
|
496 |
|
497 else if (key.length() == WepKeyValidator::WepAscii64BitMaxLength |
|
498 || key.length() == WepKeyValidator::WepAscii128BitMaxLength) { |
|
499 mkeyFormat[index] = EFormatAscii; |
|
500 } |
|
501 } |
|
502 |
|
503 /*!Get the right field in DB |
|
504 * \index of the WEP key |
|
505 */ |
|
506 CMManagerShim::ConnectionMethodAttribute CpWepUi::getWEPKeyEnum(int index) |
|
507 { |
|
508 CMManagerShim::ConnectionMethodAttribute keyenum( |
|
509 CMManagerShim::WlanWepKey1InHex); |
|
510 switch (index) |
|
511 { |
|
512 case KFirstKey: |
|
513 { |
|
514 if (mkeyFormat[index] == EFormatHex) { |
|
515 keyenum = CMManagerShim::WlanWepKey1InHex; |
|
516 } |
|
517 else { |
|
518 keyenum = CMManagerShim::WlanWepKey1InAscii; |
|
519 } |
|
520 } |
|
521 break; |
|
522 |
|
523 case KSecondKey: |
|
524 { |
|
525 if (mkeyFormat[index] == EFormatHex) { |
|
526 keyenum = CMManagerShim::WlanWepKey2InHex; |
|
527 } |
|
528 else { |
|
529 keyenum = CMManagerShim::WlanWepKey2InAscii; |
|
530 } |
|
531 } |
|
532 break; |
|
533 |
|
534 case KThirdKey: |
|
535 { |
|
536 if (mkeyFormat[index] == EFormatHex) { |
|
537 keyenum = CMManagerShim::WlanWepKey3InHex; |
|
538 } |
|
539 else { |
|
540 keyenum = CMManagerShim::WlanWepKey3InAscii; |
|
541 } |
|
542 } |
|
543 break; |
|
544 |
|
545 case KFourthKey: |
|
546 { |
|
547 if (mkeyFormat[index] == EFormatHex) { |
|
548 keyenum = CMManagerShim::WlanWepKey4InHex; |
|
549 } |
|
550 else { |
|
551 keyenum = CMManagerShim::WlanWepKey4InAscii; |
|
552 } |
|
553 } |
|
554 break; |
|
555 |
|
556 default: |
|
557 break; |
|
558 } |
|
559 return keyenum; |
|
560 } |
|
561 /* |
|
562 * Read all security settings from the Comms |
|
563 */ |
|
564 void CpWepUi::loadFieldsFromDataBase() |
|
565 { |
|
566 OstTraceFunctionEntry1(CPWEPUI_LOADFIELDSFROMDATABASE_ENTRY,this); |
|
567 |
|
568 //Wep Key in Use |
|
569 mNewKeySelected = mCmCM->getIntAttribute(CMManagerShim::WlanWepKeyIndex); |
|
570 |
|
571 //All data fetched in Hex Format |
|
572 mKeyData.insert(KFirstKey, mCmCM->getString8Attribute( |
|
573 CMManagerShim::WlanWepKey1InHex)); |
|
574 |
|
575 mKeyData.insert(KSecondKey,mCmCM->getString8Attribute( |
|
576 CMManagerShim::WlanWepKey2InHex)); |
|
577 |
|
578 mKeyData.insert(KThirdKey, mCmCM->getString8Attribute( |
|
579 CMManagerShim::WlanWepKey3InHex)); |
|
580 |
|
581 mKeyData.insert(KFourthKey, mCmCM->getString8Attribute( |
|
582 CMManagerShim::WlanWepKey4InHex)); |
|
583 |
|
584 /*Set all key formats to Hex by default; because all keys are read in Hex from DB*/ |
|
585 for (int count = 0; count < KMaxNumberofKeys; count++) |
|
586 { |
|
587 mkeyFormat[count] = EFormatHex; |
|
588 } |
|
589 |
|
590 OstTraceFunctionExit1(CPWEPUI_LOADFIELDSFROMDATABASE_EXIT,this); |
|
591 } |
|
592 |
|
593 /*! |
|
594 Tries to update connection method changes to CommsDat. |
|
595 Returns "true" if success, "false" if some error happened. |
|
596 */ |
|
597 bool CpWepUi::tryUpdate() |
|
598 { |
|
599 OstTraceFunctionEntry1(CPWEPUI_TRYUPDATE_ENTRY,this); |
|
600 |
|
601 bool ret(true); |
|
602 // Try update |
|
603 try { |
|
604 mCmCM->update(); |
|
605 } |
|
606 catch (const std::exception&) { |
|
607 // Handle error |
|
608 handleUpdateError(); |
|
609 ret = false; |
|
610 } |
|
611 |
|
612 OstTraceFunctionExit1(DUP1_CPWEPUI_TRYUPDATE_EXIT,this); |
|
613 return ret; |
|
614 } |
|
615 |
|
616 /*! |
|
617 Handles failed CommsDat update. |
|
618 */ |
|
619 void CpWepUi::handleUpdateError() |
|
620 { |
|
621 OstTraceFunctionEntry1(CPWEPUI_HANDLEUPDATEERROR_ENTRY,this); |
|
622 |
|
623 // Show error note to user |
|
624 showMessageBox(HbMessageBox::MessageTypeWarning, hbTrId( |
|
625 "txt_occ_info_unable_to_save_setting")); |
|
626 // Reload settings from CommsDat and update UI |
|
627 try { |
|
628 mCmCM->refresh(); |
|
629 } |
|
630 catch (const std::exception&) { |
|
631 // Ignore error from refresh. Most likely this will not happen, but |
|
632 // if it does, there isn't very much we can do. |
|
633 OstTrace0( |
|
634 TRACE_ERROR, |
|
635 CPWEPPLUGIN_HANDLEUPDATEERROR, |
|
636 "Refresh failed"); |
|
637 }; |
|
638 updateWepSettings(); |
|
639 |
|
640 OstTraceFunctionExit1(CPWEPUI_HANDLEUPDATEERROR_EXIT,this); |
|
641 } |
|
642 |
|
643 /*! |
|
644 Shows message box with "OK" button using given text. |
|
645 */ |
|
646 void CpWepUi::showMessageBox(HbMessageBox::MessageBoxType type, |
|
647 const QString &text) |
|
648 { |
|
649 OstTraceFunctionEntry1(CPWEPUI_SHOWMESSAGEBOX_ENTRY,this); |
|
650 |
|
651 // Create a message box |
|
652 mMessageBox = QSharedPointer<HbMessageBox> (new HbMessageBox(type)); |
|
653 mMessageBox->setObjectName("CpWepUiMessageBox"); |
|
654 mMessageBox->setText(text); |
|
655 mMessageBox->open(); |
|
656 |
|
657 OstTraceFunctionExit1(CPWEPUI_SHOWMESSAGEBOX_EXIT,this); |
|
658 } |
|
659 |
|
660 /*! |
|
661 * Reset the Key Items on the Ui, by reading the previously set value from Comms |
|
662 */ |
|
663 void CpWepUi::updateWepSettings() |
|
664 { |
|
665 OstTraceFunctionEntry1(CPWEPUI_UPDATEWEPSETTINGS_ENTRY,this); |
|
666 //Read values from Comms and update the Ui items; |
|
667 loadFieldsFromDataBase(); |
|
668 |
|
669 mWepKeyText[KFirstKey]->setContentWidgetData("text", mKeyData[KFirstKey]); |
|
670 |
|
671 mWepKeyText[KSecondKey]->setContentWidgetData("text", |
|
672 mKeyData[KSecondKey]); |
|
673 |
|
674 mWepKeyText[KThirdKey]->setContentWidgetData("text", mKeyData[KThirdKey]); |
|
675 |
|
676 mWepKeyText[KFourthKey]->setContentWidgetData("text", |
|
677 mKeyData[KFourthKey]); |
|
678 |
|
679 OstTraceFunctionExit1(CPWEPUI_UPDATEWEPSETTINGS_EXIT,this); |
|
680 } |
|
681 |
|
682 /*! |
|
683 * Commit all WEP keys , except the one which was just set |
|
684 * |
|
685 * \param index ; the index of the key that was just set |
|
686 */ |
|
687 void CpWepUi::commitWEPkeys(int index) |
|
688 { |
|
689 OstTraceFunctionEntry1(CPWEPUI_COMMITWEPKEYS_ENTRY,this); |
|
690 //We have all data in Hex, so setting all WEP keys in hex |
|
691 |
|
692 if (index != KFirstKey) { |
|
693 //Get the right field to store |
|
694 CMManagerShim::ConnectionMethodAttribute keyEnumOne = getWEPKeyEnum( |
|
695 KFirstKey); |
|
696 |
|
697 //Store the WEP key |
|
698 storeWEPKey(keyEnumOne, mKeyData[KFirstKey]); |
|
699 } |
|
700 |
|
701 if (index != KSecondKey) { |
|
702 //Get the right field to store |
|
703 CMManagerShim::ConnectionMethodAttribute keyEnumTwo = getWEPKeyEnum( |
|
704 KSecondKey); |
|
705 |
|
706 //Store the WEP key |
|
707 storeWEPKey(keyEnumTwo, mKeyData[KSecondKey]); |
|
708 } |
|
709 |
|
710 if (index != KThirdKey) { |
|
711 //Get the right field to store |
|
712 CMManagerShim::ConnectionMethodAttribute keyEnumThree = |
|
713 getWEPKeyEnum(KThirdKey); |
|
714 |
|
715 //Store the WEP key |
|
716 storeWEPKey(keyEnumThree, mKeyData[KThirdKey]); |
|
717 } |
|
718 |
|
719 if (index != KFourthKey) { |
|
720 //Get the right field to store |
|
721 CMManagerShim::ConnectionMethodAttribute keyEnumFour = getWEPKeyEnum( |
|
722 KFourthKey); |
|
723 |
|
724 //Store the WEP key |
|
725 storeWEPKey(keyEnumFour, mKeyData[KFourthKey]); |
|
726 } |
|
727 |
|
728 OstTraceFunctionExit1(CPWEPUI_COMMITWEPKEYS_EXIT,this); |
|
729 } |
|
730 |
|
731 Q_EXPORT_PLUGIN2(CpWepUi, CpWepUi) |
|
732 ; |
|