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: 16 % |
20 * %version: 22 % |
21 */ |
21 */ |
22 |
22 |
23 //User Includes |
23 //User Includes |
24 #include "cpwepui.h" |
24 #include "cpwepui.h" |
|
25 #include "wepkeyvalidator.h" |
|
26 |
25 |
27 |
26 // System includes |
28 // System includes |
27 #include <QStringList> |
29 #include <QStringList> |
28 #include <cpsettingformentryitemdata.h> |
|
29 #include <cpitemdatahelper.h> |
30 #include <cpitemdatahelper.h> |
30 #include <HbDataForm> |
|
31 #include <HbDeviceNotificationDialog> |
|
32 #include <QLocale> |
|
33 #include <QCoreApplication> |
|
34 #include <cmconnectionmethod_shim.h> |
31 #include <cmconnectionmethod_shim.h> |
35 #include <cmpluginwlandef.h> |
|
36 #include <cmmanagerdefines_shim.h> |
32 #include <cmmanagerdefines_shim.h> |
37 |
33 #include <HbLineEdit> |
|
34 #include <HbTranslator> |
|
35 #include <HbEditorInterface> |
|
36 |
|
37 //Trace Definition |
38 #include "OstTraceDefinitions.h" |
38 #include "OstTraceDefinitions.h" |
39 #ifdef OST_TRACE_COMPILER_IN_USE |
39 #ifdef OST_TRACE_COMPILER_IN_USE |
40 #include "cpwepuiTraces.h" |
40 #include "cpwepuiTraces.h" |
41 #endif |
41 #endif |
42 |
42 |
43 // Constants |
43 // Constants |
44 //The order in which WEP only mode appears in the list of available |
44 //The order in which WEP only mode appears in the list of available |
45 //security mode |
45 //security mode |
46 static const int UI_ORDER_WEP = 10; |
46 static const int UI_ORDER_WEP = 10; |
47 |
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 |
48 /*! |
65 /*! |
49 \class CpWepUi |
66 \class CpWepUi |
50 \brief CpWepUi implements the WEP Security Settings Control Panel Plugin |
67 \brief CpWepUi implements the WEP Security Settings Control Panel Plugin |
51 which will allow viewing/editing of WEP Security Settings. |
68 which will allow viewing/editing of WEP Security Settings. |
52 */ |
69 */ |
53 //Contructs WEP object |
70 //Contructs WEP object |
54 CpWepUi::CpWepUi() : |
71 CpWepUi::CpWepUi() : |
55 mUi(NULL), mNewKeySelected(0), mTranslator(NULL), mCmCM(NULL), mCmId(0) |
72 mUi(NULL), |
56 { |
73 mNewKeySelected(0), |
57 mTranslator = new QTranslator(this); |
74 mTranslator(new HbTranslator("cpwlansecsettingsplugin")), |
58 mTranslator->load(":/loc/wlan_en_GB.qm"); |
75 mCmCM(NULL), |
59 qApp->installTranslator(mTranslator); |
76 mCmId(0) |
60 |
77 { |
61 /* Install localization |
78 //Initialize array members |
62 mTranslator = QSharedPointer<HbTranslator> ( |
79 for(int index=0;index<KMaxNumberofKeys;index++) |
63 new HbTranslator("wlan_en_GB"));*/ |
80 { |
|
81 mWepKey[index] = NULL; |
|
82 mWepKeyText[index] = NULL; |
|
83 mkeyFormat[index] = EFormatHex; |
|
84 } |
|
85 |
64 } |
86 } |
65 |
87 |
66 //Deletes all objects WEP owns |
88 //Deletes all objects WEP owns |
67 CpWepUi::~CpWepUi() |
89 CpWepUi::~CpWepUi() |
68 { |
90 { |
69 OstTraceFunctionEntry1(CPWEPUI_CPWEPUI_ENTRY,this); |
91 OstTraceFunctionEntry1(CPWEPUI_CPWEPUI_ENTRY,this); |
70 //Elements like mUi and components that belong to it |
92 //Elements like mUi and components that belong to it |
71 //, are taken care by the parent |
93 //, are taken care by the parent |
|
94 delete mTranslator; |
72 OstTraceFunctionExit1(CPWEPUI_CPWEPUI_EXIT,this); |
95 OstTraceFunctionExit1(CPWEPUI_CPWEPUI_EXIT,this); |
73 } |
96 } |
74 |
97 |
75 // ======== MEMBER FUNCTIONS ======== |
98 // ======== MEMBER FUNCTIONS ======== |
76 |
99 |
167 wepKeyInUse->setContentWidgetData("currentIndex", mNewKeySelected); |
190 wepKeyInUse->setContentWidgetData("currentIndex", mNewKeySelected); |
168 dataHelpper.addConnection(wepKeyInUse, SIGNAL(currentIndexChanged(int)), |
191 dataHelpper.addConnection(wepKeyInUse, SIGNAL(currentIndexChanged(int)), |
169 this, SLOT(wepKeyInUseChanged(int))); |
192 this, SLOT(wepKeyInUseChanged(int))); |
170 mUi->appendChild(wepKeyInUse); |
193 mUi->appendChild(wepKeyInUse); |
171 |
194 |
172 createWEPKeyOneGroup(dataHelpper); |
195 //Create Ui for all 4 WEP keys |
173 |
196 createWEPKeyGroup(KFirstKey); |
174 createWEPKeyTwoGroup(dataHelpper); |
197 |
175 |
198 createWEPKeyGroup(KSecondKey); |
176 createWEPKeyThreeGroup(dataHelpper); |
199 |
177 |
200 createWEPKeyGroup(KThirdKey); |
178 createWEPKeyFourGroup(dataHelpper); |
201 |
|
202 createWEPKeyGroup(KFourthKey); |
|
203 |
|
204 //Add Connections(signals) |
|
205 addConnections(dataHelpper); |
179 |
206 |
180 OstTraceFunctionExit1(CPWEPUI_UIINSTANCE_EXIT,this); |
207 OstTraceFunctionExit1(CPWEPUI_UIINSTANCE_EXIT,this); |
181 return mUi; |
208 return mUi; |
182 } |
209 } |
183 |
210 |
184 /*! |
211 |
185 * Create Ui element with text edit for WEP KEY One |
212 /*! |
186 * |
213 Validates current security settings. This function is called whenever |
187 * \param dataHelper to add Connections |
214 user tries to exit from the settings view. If the plugin determines |
188 */ |
215 that some settings need editing before considered valid, it shall |
189 void CpWepUi::createWEPKeyOneGroup(CpItemDataHelper &dataHelpper) |
216 return false. A dialog will be shown to the user indicating that |
|
217 settings are still incomplete and asking if he/she wishes to exit |
|
218 anyway. |
|
219 |
|
220 \return True if security settings for WEP are valid, false if not. |
|
221 */ |
|
222 bool CpWepUi::validateSettings() |
|
223 { |
|
224 bool ret(false); |
|
225 //Check the latest string entered for the WEP key in the text box |
|
226 QVariant keyValue = mWepKeyText[mNewKeySelected]->contentWidgetData("text"); |
|
227 QString keyString = keyValue.toString(); |
|
228 |
|
229 WepKeyValidator::KeyStatus keystatus = WepKeyValidator::validateWepKey(keyString); |
|
230 |
|
231 //Check if key is valid and not of zero length |
|
232 if(keystatus==WepKeyValidator::KeyStatusOk) { |
|
233 ret = true; |
|
234 } |
|
235 return ret; |
|
236 } |
|
237 |
|
238 /*! |
|
239 * Create Ui element with text edit for WEP KEYS |
|
240 * |
|
241 * \param index of the WEP key |
|
242 * */ |
|
243 void CpWepUi::createWEPKeyGroup(int index) |
190 { |
244 { |
191 OstTraceFunctionEntry1(CPWEPUI_CREATEWEPKEYONEGROUP_ENTRY,this); |
245 OstTraceFunctionEntry1(CPWEPUI_CREATEWEPKEYGROUP_ENTRY,this); |
192 mWepKeyText[KFirstKey] = new CpSettingFormItemData( |
246 QString textId; |
|
247 |
|
248 switch(index) |
|
249 { |
|
250 case KFirstKey: |
|
251 textId = hbTrId("txt_occ_subhead_wep_key_1"); |
|
252 break; |
|
253 |
|
254 |
|
255 case KSecondKey: |
|
256 textId = hbTrId("txt_occ_subhead_wep_key_2"); |
|
257 break; |
|
258 |
|
259 case KThirdKey: |
|
260 textId = hbTrId("txt_occ_subhead_wep_key_3"); |
|
261 break; |
|
262 |
|
263 case KFourthKey: |
|
264 textId = hbTrId("txt_occ_subhead_wep_key_4"); |
|
265 break; |
|
266 } |
|
267 |
|
268 |
|
269 mWepKeyText[index] = new CpSettingFormItemData( |
193 HbDataFormModelItem::TextItem, |
270 HbDataFormModelItem::TextItem, |
194 hbTrId("txt_occ_subhead_wep_key_1"), mUi); |
271 textId, mUi); |
195 |
272 |
196 if (mKeyData[KFirstKey].length() != 0) { |
273 if (mKeyData[index].length() != 0) { |
197 mWepKeyText[KFirstKey]->setContentWidgetData("text", |
274 mWepKeyText[index]->setContentWidgetData("text", |
198 mKeyData[KFirstKey]); |
275 mKeyData[index]); |
199 } |
276 } |
200 mWepKeyText[KFirstKey]->setContentWidgetData("echoMode", 2); |
277 mWepKeyText[index]->setContentWidgetData("echoMode",HbLineEdit::PasswordEchoOnEdit); |
201 mWepKeyText[KFirstKey]->setContentWidgetData("smileysEnabled", "false"); |
278 mWepKeyText[index]->setContentWidgetData("smileysEnabled", "false"); |
202 |
279 |
|
280 |
|
281 mUi->appendChild(mWepKeyText[index]); |
|
282 OstTraceFunctionExit1(CPWEPUI_CREATEWEPKEYGROUP_EXIT,this); |
|
283 } |
|
284 |
|
285 |
|
286 /*! |
|
287 * Add signals to all the text Edit of WEP key groups. |
|
288 * |
|
289 * \param dataHelper ; to add Connections |
|
290 */ |
|
291 void CpWepUi::addConnections(CpItemDataHelper &dataHelpper) |
|
292 { |
|
293 OstTraceFunctionEntry1( CPWEPUI_ADDCONNECTIONS_ENTRY, this ); |
|
294 |
203 dataHelpper.addConnection(mWepKeyText[KFirstKey], |
295 dataHelpper.addConnection(mWepKeyText[KFirstKey], |
204 SIGNAL( editingFinished ()), this, SLOT(wepKeyOneChanged() )); |
296 SIGNAL( editingFinished ()), this, SLOT(wepKeyOneChanged() )); |
205 |
297 |
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], |
298 dataHelpper.addConnection(mWepKeyText[KSecondKey], |
228 SIGNAL( editingFinished ()), this, SLOT(wepKeyTwoChanged() )); |
299 SIGNAL( editingFinished ()), this, SLOT(wepKeyTwoChanged() )); |
229 |
300 |
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], |
301 dataHelpper.addConnection(mWepKeyText[KThirdKey], |
252 SIGNAL( editingFinished ()), this, SLOT(wepKeyThreeChanged() )); |
302 SIGNAL( editingFinished ()), this, SLOT(wepKeyThreeChanged() )); |
253 |
303 |
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], |
304 dataHelpper.addConnection(mWepKeyText[KFourthKey], |
276 SIGNAL( editingFinished ()), this, SLOT(wepKeyFourChanged() )); |
305 SIGNAL( editingFinished ()), this, SLOT(wepKeyFourChanged() )); |
277 |
306 |
278 mUi->appendChild(mWepKeyText[KFourthKey]); |
307 dataHelpper.connectToForm(SIGNAL(itemShown (const QModelIndex &) ), |
279 OstTraceFunctionExit1(CPWEPUI_CREATEWEPKEYFOURGROUP_EXIT,this); |
308 this, SLOT(setEditorPreferences(const QModelIndex &))); |
280 } |
309 |
|
310 OstTraceFunctionExit1( CPWEPUI_ADDCONNECTIONS_EXIT, this ); |
|
311 } |
|
312 |
281 |
313 |
282 /*! |
314 /*! |
283 * Slot to handle , if a different wep key (index) |
315 * Slot to handle , if a different wep key (index) |
284 * is made active |
316 * is made active |
285 * \param wepKeyInUse index of the chosen wep key |
317 * \param wepKeyInUse index of the chosen wep key |
398 * Commit All 4 WEP keys , anyways |
433 * Commit All 4 WEP keys , anyways |
399 */ |
434 */ |
400 commitWEPkeys(index); |
435 commitWEPkeys(index); |
401 } |
436 } |
402 else { |
437 else { |
|
438 OstTrace0( TRACE_ERROR, CPWEPUI_WEPKEYTEXTCHANGED_ERROR, "CpWepUi::wepKeyTextChanged Invalid WEP Key Input" ); |
403 showMessageBox(HbMessageBox::MessageTypeWarning, hbTrId( |
439 showMessageBox(HbMessageBox::MessageTypeWarning, hbTrId( |
404 "txt_occ_info_invalid_input")); |
440 "txt_occ_info_invalid_input")); |
405 } |
441 } |
406 OstTraceFunctionExit1(CPWEPUI_WEPKEYTEXTCHANGED_EXIT,this); |
442 OstTraceFunctionExit1(CPWEPUI_WEPKEYTEXTCHANGED_EXIT,this); |
407 } |
443 } |
|
444 |
|
445 /*! |
|
446 * Slot that configures the editor settings for all WEP key fields. |
|
447 * This slot is invoked whenever a new item(s) are shown in the current view |
|
448 * |
|
449 * \param modelIndex Index of the current item in the model |
|
450 */ |
|
451 void CpWepUi::setEditorPreferences(const QModelIndex &modelIndex) |
|
452 { |
|
453 |
|
454 HbDataFormModelItem *item = mItemDataHelper->modelItemFromModelIndex(modelIndex); |
|
455 |
|
456 HbSmileyTheme smiley; |
|
457 /* Configure settings only for text fields*/ |
|
458 if(item->type() == HbDataFormModelItem::TextItem) { |
|
459 HbLineEdit *edit = qobject_cast<HbLineEdit*>(mItemDataHelper->widgetFromModelIndex(modelIndex)); |
|
460 HbEditorInterface editInterface(edit); |
|
461 editInterface.setInputConstraints(HbEditorConstraintLatinAlphabetOnly); |
|
462 edit->setInputMethodHints(Qt::ImhNoPredictiveText); |
|
463 edit->setMaxLength(KMaxKeyLength); |
|
464 } |
|
465 } |
|
466 |
408 |
467 |
409 /*! |
468 /*! |
410 * Store the WEP key in Comms |
469 * Store the WEP key in Comms |
411 * \enumValue the right field represented by the enum value |
470 * \enumValue the right field represented by the enum value |
412 * \key the WEP key String to store |
471 * \key the WEP key String to store |