|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0"" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Control Panel WLAN AP settings view implementation. |
|
16 * |
|
17 */ |
|
18 |
|
19 // System includes |
|
20 #include <QString> |
|
21 #include <QVariant> |
|
22 #include <QDir> |
|
23 #include <QPluginLoader> |
|
24 #include <HbMainWindow> |
|
25 #include <HbMenu> |
|
26 #include <HbDataForm> |
|
27 #include <HbDataFormModel> |
|
28 #include <HbDataFormViewItem> |
|
29 #include <HbLineEdit> |
|
30 #include <HbEditorInterface> |
|
31 #include <HbUrlFilter> |
|
32 #include <HbPopup> |
|
33 #include <HbMessageBox> |
|
34 #include <HbAction> |
|
35 #include <wlanmgmtcommon.h> |
|
36 #include <cpitemdatahelper.h> |
|
37 #include <cpsettingformitemdata.h> |
|
38 #include <cmconnectionmethod_shim.h> |
|
39 #include <cpwlansecurityplugininterface.h> |
|
40 |
|
41 // User includes |
|
42 #include "cpwlanapplugin.h" |
|
43 #include "cpwlanapview.h" |
|
44 #include "cpwlanapadvancedview.h" |
|
45 #include "OstTraceDefinitions.h" |
|
46 #ifdef OST_TRACE_COMPILER_IN_USE |
|
47 #include "cpwlanapviewTraces.h" |
|
48 #endif |
|
49 |
|
50 /*! |
|
51 \class CpWlanApView |
|
52 \brief This class implements the WLAN AP Control Panel settings view. |
|
53 */ |
|
54 |
|
55 // External function prototypes |
|
56 |
|
57 // Local constants |
|
58 |
|
59 static const QString wlanSecurityPluginsDir = |
|
60 "\\resource\\qt\\plugins\\controlpanel\\wlansecurity"; |
|
61 |
|
62 // ======== LOCAL FUNCTIONS ======== |
|
63 |
|
64 // ======== MEMBER FUNCTIONS ======== |
|
65 |
|
66 /*! |
|
67 Constructor. |
|
68 */ |
|
69 CpWlanApView::CpWlanApView( |
|
70 CmConnectionMethodShim *cmConnectionMethod, |
|
71 QGraphicsItem *parent) : |
|
72 CpBaseSettingView(0, parent), |
|
73 mForm(0), |
|
74 mModel(0), |
|
75 mItemDataHelper(0), |
|
76 mApSettingsGroupItem(0), |
|
77 mConnectionNameItem(0), |
|
78 mWlanNetworkNameItem(0), |
|
79 mNetworkStatusItem(0), |
|
80 mNetworkModeItem(0), |
|
81 mSecurityModeItem(0), |
|
82 mHomepageItem(0), |
|
83 mSecuritySettingsGroupItem(0), |
|
84 mAdvancedSettingsAction(0), |
|
85 mCmConnectionMethod(cmConnectionMethod), |
|
86 mMessageBox(0) |
|
87 { |
|
88 OstTraceFunctionEntry0(CPWLANAPVIEW_CPWLANAPVIEW_ENTRY); |
|
89 |
|
90 // Add "Advanced settings" menu item |
|
91 HbMenu *menu = this->menu(); |
|
92 mAdvancedSettingsAction = menu->addAction( |
|
93 hbTrId("txt_occ_opt_advanced_settings")); |
|
94 bool status = connect( |
|
95 menu, |
|
96 SIGNAL(triggered(HbAction*)), |
|
97 this, |
|
98 SLOT(menuActionTriggered(HbAction*))); |
|
99 Q_ASSERT(status); |
|
100 |
|
101 // Construct WLAN AP settings UI |
|
102 mForm = settingForm(); |
|
103 if (mForm) { |
|
104 mModel = new HbDataFormModel(mForm); |
|
105 |
|
106 // The parameter given as 0 is a HbDataForm pointer, not parent |
|
107 mItemDataHelper = new CpItemDataHelper(0); |
|
108 mItemDataHelper->setParent(this); |
|
109 |
|
110 // Add access point settings group |
|
111 createAccessPointSettingsGroup(); |
|
112 |
|
113 mItemDataHelper->bindToForm(mForm); |
|
114 mForm->setModel(mModel); |
|
115 |
|
116 status = connect( |
|
117 mForm, |
|
118 SIGNAL(itemShown(const QModelIndex)), |
|
119 this, |
|
120 SLOT(setEditorPreferences(const QModelIndex))); |
|
121 Q_ASSERT(status); |
|
122 |
|
123 // Expand access point settings group |
|
124 mForm->setExpanded(mModel->indexFromItem(mApSettingsGroupItem), TRUE); |
|
125 |
|
126 // Add security settings group if necessary |
|
127 updateSecurityGroup( |
|
128 mSecurityModeItem->contentWidgetData("currentIndex").toInt()); |
|
129 } |
|
130 |
|
131 OstTraceFunctionExit0(CPWLANAPVIEW_CPWLANAPVIEW_EXIT); |
|
132 } |
|
133 |
|
134 /*! |
|
135 Destructor. |
|
136 */ |
|
137 CpWlanApView::~CpWlanApView() |
|
138 { |
|
139 OstTraceFunctionEntry0(DUP1_CPWLANAPVIEW_CPWLANAPVIEW_ENTRY); |
|
140 |
|
141 OstTraceFunctionExit0(DUP1_CPWLANAPVIEW_CPWLANAPVIEW_EXIT); |
|
142 } |
|
143 |
|
144 /*! |
|
145 Creates the WLAN "Access point settings" group. |
|
146 */ |
|
147 void CpWlanApView::createAccessPointSettingsGroup() |
|
148 { |
|
149 OstTraceFunctionEntry0(CPWLANAPVIEW_CREATEACCESSPOINTSETTINGSGROUP_ENTRY); |
|
150 |
|
151 // Access point settings group |
|
152 mApSettingsGroupItem = new HbDataFormModelItem( |
|
153 HbDataFormModelItem::GroupItem, |
|
154 hbTrId("txt_occ_subhead_access_point_settings")); |
|
155 mModel->appendDataFormItem(mApSettingsGroupItem); |
|
156 |
|
157 // Connection name |
|
158 mConnectionNameItem = new CpSettingFormItemData( |
|
159 HbDataFormModelItem::TextItem, |
|
160 hbTrId("txt_occ_setlabel_connection_name")); |
|
161 // Connect signal and add item to group |
|
162 mForm->addConnection( |
|
163 mConnectionNameItem, |
|
164 SIGNAL(editingFinished()), |
|
165 this, |
|
166 SLOT(connectionNameChanged())); |
|
167 mApSettingsGroupItem->appendChild(mConnectionNameItem); |
|
168 |
|
169 // WLAN network name |
|
170 mWlanNetworkNameItem = new CpSettingFormItemData( |
|
171 HbDataFormModelItem::TextItem, |
|
172 hbTrId("txt_occ_setlabel_wlan_network_name")); |
|
173 // Connect signal and add item to group |
|
174 mForm->addConnection( |
|
175 mWlanNetworkNameItem, |
|
176 SIGNAL(editingFinished()), |
|
177 this, |
|
178 SLOT(wlanNetworkNameChanged())); |
|
179 mApSettingsGroupItem->appendChild(mWlanNetworkNameItem); |
|
180 |
|
181 // Network status |
|
182 mNetworkStatusItem = new CpSettingFormItemData( |
|
183 HbDataFormModelItem::ComboBoxItem, |
|
184 hbTrId("txt_occ_setlabel_network_status")); |
|
185 // Add items to combobox |
|
186 QStringList networkStatusItems; |
|
187 networkStatusItems |
|
188 << hbTrId("txt_occ_setlabel_network_status_val_public") |
|
189 << hbTrId("txt_occ_setlabel_network_status_val_hidden"); |
|
190 mNetworkStatusItem->setContentWidgetData("items", networkStatusItems); |
|
191 // Construct map to link item indexes to setting values |
|
192 mNetworkStatusMap.insert(0, false); // public |
|
193 mNetworkStatusMap.insert(1, true); // hidden |
|
194 // Connect signal and add item to group |
|
195 mForm->addConnection( |
|
196 mNetworkStatusItem, |
|
197 SIGNAL(currentIndexChanged(int)), |
|
198 this, |
|
199 SLOT(networkStatusChanged(int))); |
|
200 mApSettingsGroupItem->appendChild(mNetworkStatusItem); |
|
201 |
|
202 // Network mode |
|
203 mNetworkModeItem = new CpSettingFormItemData( |
|
204 HbDataFormModelItem::ComboBoxItem, |
|
205 hbTrId("txt_occ_setlabel_wlan_network_mode")); |
|
206 // Add items to combobox |
|
207 QStringList networkModeItems; |
|
208 networkModeItems |
|
209 << hbTrId("txt_occ_setlabel_wlan_network_mode_val_infrastruct") |
|
210 << hbTrId("txt_occ_setlabel_wlan_network_mode_val_adhoc"); |
|
211 mNetworkModeItem->setContentWidgetData("items", networkModeItems); |
|
212 // Construct map to link item indexes to setting values |
|
213 mNetworkModeMap.insert(0, CMManagerShim::Infra); // infrastructure |
|
214 mNetworkModeMap.insert(1, CMManagerShim::Adhoc); // adhoc |
|
215 // Connect signal and add item to group |
|
216 mForm->addConnection( |
|
217 mNetworkModeItem, |
|
218 SIGNAL(currentIndexChanged(int)), |
|
219 this, |
|
220 SLOT(networkModeChanged(int))); |
|
221 mApSettingsGroupItem->appendChild(mNetworkModeItem); |
|
222 |
|
223 // Security mode |
|
224 mSecurityModeItem = new CpSettingFormItemData( |
|
225 HbDataFormModelItem::ComboBoxItem, |
|
226 hbTrId("txt_occ_setlabel_wlan_security_mode")); |
|
227 // Load WLAN security plugins and construct map |
|
228 mSecurityModeMap.insert(0, NULL); // open mode |
|
229 // Load all security plugins and construct map |
|
230 loadSecurityPlugins(); |
|
231 // Add items to combobox |
|
232 QStringList securityModeItems; |
|
233 foreach (CpWlanSecurityPluginInterface *plugin, mSecurityModeMap) { |
|
234 if (plugin) { |
|
235 // Add security mode from plugin |
|
236 securityModeItems |
|
237 << hbTrId(plugin->securityModeTextId().toLatin1()); |
|
238 } else { |
|
239 // Add open mode |
|
240 securityModeItems |
|
241 << hbTrId("txt_occ_setlabel_wlan_security_mode_val_open"); |
|
242 } |
|
243 } |
|
244 mSecurityModeItem->setContentWidgetData("items", securityModeItems); |
|
245 // Connect signal and add item to group |
|
246 mForm->addConnection( |
|
247 mSecurityModeItem, |
|
248 SIGNAL(currentIndexChanged(int)), |
|
249 this, |
|
250 SLOT(securityModeChanged(int))); |
|
251 mApSettingsGroupItem->appendChild(mSecurityModeItem); |
|
252 |
|
253 // Homepage |
|
254 mHomepageItem = new CpSettingFormItemData( |
|
255 HbDataFormModelItem::TextItem, |
|
256 hbTrId("txt_occ_setlabel_homepage")); |
|
257 // Connect signal and add item to group |
|
258 mForm->addConnection( |
|
259 mHomepageItem, |
|
260 SIGNAL(editingFinished()), |
|
261 this, |
|
262 SLOT(homepageChanged())); |
|
263 mApSettingsGroupItem->appendChild(mHomepageItem); |
|
264 |
|
265 // Read settings from CommsDat and update widgets |
|
266 updateAccessPointSettingsGroup(); |
|
267 |
|
268 OstTraceFunctionExit0(CPWLANAPVIEW_CREATEACCESSPOINTSETTINGSGROUP_EXIT); |
|
269 } |
|
270 |
|
271 /*! |
|
272 Reads attribute values and updates "Access point settings" group settings. |
|
273 */ |
|
274 void CpWlanApView::updateAccessPointSettingsGroup() |
|
275 { |
|
276 OstTraceFunctionEntry0(CPWLANAPVIEW_UPDATEACCESSPOINTSETTINGSGROUP_ENTRY); |
|
277 |
|
278 // Get attributes from CommsDat and set values to UI widgets |
|
279 |
|
280 // Connection name |
|
281 QString connectionName = mCmConnectionMethod->getStringAttribute( |
|
282 CMManagerShim::CmName); |
|
283 mConnectionNameItem->setContentWidgetData("text", connectionName); |
|
284 |
|
285 // WLAN network name |
|
286 QString networkName = mCmConnectionMethod->getStringAttribute( |
|
287 CMManagerShim::WlanSSID); |
|
288 mWlanNetworkNameItem->setContentWidgetData("text", networkName); |
|
289 |
|
290 // Network status |
|
291 bool scanSsid = mCmConnectionMethod->getBoolAttribute( |
|
292 CMManagerShim::WlanScanSSID); |
|
293 mNetworkStatusItem->setContentWidgetData( |
|
294 "currentIndex", |
|
295 mNetworkStatusMap.key(scanSsid)); |
|
296 |
|
297 // Network mode |
|
298 int networkMode = mCmConnectionMethod->getIntAttribute( |
|
299 CMManagerShim::WlanConnectionMode); |
|
300 mNetworkModeItem->setContentWidgetData( |
|
301 "currentIndex", |
|
302 mNetworkModeMap.key(networkMode)); |
|
303 |
|
304 // Security mode |
|
305 QVariant securityMode = mCmConnectionMethod->getIntAttribute( |
|
306 CMManagerShim::WlanSecurityMode); |
|
307 // Iterate through the map to find correct security plugin and set |
|
308 // mode index |
|
309 int securityModeIndex = 0; |
|
310 QMapIterator<int, CpWlanSecurityPluginInterface *> i(mSecurityModeMap); |
|
311 while (i.hasNext()) { |
|
312 i.next(); |
|
313 if (i.value() |
|
314 && i.value()->securityMode() == securityMode.toInt()) { |
|
315 securityModeIndex = i.key(); |
|
316 } |
|
317 } |
|
318 mSecurityModeItem->setContentWidgetData("currentIndex", |
|
319 securityModeIndex); |
|
320 |
|
321 // Homepage |
|
322 QString homepage = mCmConnectionMethod->getStringAttribute( |
|
323 CMManagerShim::CmStartPage); |
|
324 mHomepageItem->setContentWidgetData("text", homepage); |
|
325 |
|
326 OstTraceFunctionExit0(CPWLANAPVIEW_UPDATEACCESSPOINTSETTINGSGROUP_EXIT); |
|
327 } |
|
328 |
|
329 /*! |
|
330 Loads all WLAN security plugins. |
|
331 */ |
|
332 void CpWlanApView::loadSecurityPlugins() |
|
333 { |
|
334 OstTraceFunctionEntry0(CPWLANAPVIEW_LOADSECURITYPLUGINS_ENTRY); |
|
335 |
|
336 // Load security plugins |
|
337 QList<CpWlanSecurityPluginInterface *> plugins; |
|
338 QDir pluginsDir(wlanSecurityPluginsDir); |
|
339 foreach (QString fileName, pluginsDir.entryList(QDir::Files)) { |
|
340 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName)); |
|
341 CpWlanSecurityPluginInterface *plugin = |
|
342 qobject_cast<CpWlanSecurityPluginInterface *>(loader.instance()); |
|
343 if (plugin) { |
|
344 // Sort items based on the orderNumber() |
|
345 QList<CpWlanSecurityPluginInterface *>::iterator i; |
|
346 for (i = plugins.begin(); i != plugins.end(); ++i) { |
|
347 if ((*i)->orderNumber() > plugin->orderNumber()) { |
|
348 plugins.insert(i, plugin); |
|
349 plugin = NULL; |
|
350 break; |
|
351 } |
|
352 } |
|
353 if (plugin) { |
|
354 plugins.append(plugin); |
|
355 } |
|
356 } |
|
357 } |
|
358 |
|
359 // Add security plugins to map |
|
360 int i; |
|
361 i = mSecurityModeMap.size(); |
|
362 foreach (CpWlanSecurityPluginInterface *plugin, plugins) { |
|
363 mSecurityModeMap.insert(i, plugin); |
|
364 i++; |
|
365 } |
|
366 |
|
367 OstTraceFunctionExit0(CPWLANAPVIEW_LOADSECURITYPLUGINS_EXIT); |
|
368 } |
|
369 |
|
370 /*! |
|
371 Updates the "Security settings" group. |
|
372 */ |
|
373 void CpWlanApView::updateSecurityGroup(int index) |
|
374 { |
|
375 OstTraceFunctionEntry0(CPWLANAPVIEW_UPDATESECURITYGROUP_ENTRY); |
|
376 |
|
377 // Remove old security settings group |
|
378 if (mSecuritySettingsGroupItem) { |
|
379 mModel->removeItem(mSecuritySettingsGroupItem); |
|
380 mSecuritySettingsGroupItem = NULL; |
|
381 } |
|
382 |
|
383 // Add new security settings group |
|
384 if (index > 0) { |
|
385 // Get correct security plugin |
|
386 CpWlanSecurityPluginInterface *plugin = mSecurityModeMap.value(index); |
|
387 if (plugin) { |
|
388 // Ask plugin to create the security group |
|
389 plugin->setReference( |
|
390 mCmConnectionMethod, |
|
391 mCmConnectionMethod->getIntAttribute(CMManagerShim::CmId)); |
|
392 mSecuritySettingsGroupItem = plugin->uiInstance(*mItemDataHelper); |
|
393 if (mSecuritySettingsGroupItem) { |
|
394 // And add it to dataform |
|
395 mModel->appendDataFormItem(mSecuritySettingsGroupItem); |
|
396 } |
|
397 } |
|
398 } |
|
399 |
|
400 OstTraceFunctionExit0(CPWLANAPVIEW_UPDATESECURITYGROUP_EXIT); |
|
401 } |
|
402 |
|
403 /*! |
|
404 Shows message box with "OK" button using given text. |
|
405 */ |
|
406 void CpWlanApView::showMessageBox( |
|
407 HbMessageBox::MessageBoxType type, |
|
408 const QString &text) |
|
409 { |
|
410 OstTraceFunctionEntry0(CPWLANAPVIEW_SHOWMESSAGEBOX_ENTRY); |
|
411 |
|
412 // Create a message box |
|
413 mMessageBox = QSharedPointer<HbMessageBox>(new HbMessageBox(type)); |
|
414 mMessageBox->setText(text); |
|
415 mMessageBox->setModal(true); |
|
416 mMessageBox->setTimeout(HbPopup::NoTimeout); |
|
417 mMessageBox->open(); |
|
418 |
|
419 OstTraceFunctionExit0(CPWLANAPVIEW_SHOWMESSAGEBOX_EXIT); |
|
420 } |
|
421 |
|
422 /*! |
|
423 Tries to update connection method changes to CommsDat. |
|
424 Returns "true" if success, "false" if some error happened. |
|
425 */ |
|
426 bool CpWlanApView::tryUpdate() |
|
427 { |
|
428 OstTraceFunctionEntry0(CPWLANAPVIEW_TRYUPDATE_ENTRY); |
|
429 |
|
430 // Try update |
|
431 try { |
|
432 mCmConnectionMethod->update(); |
|
433 } |
|
434 catch (const std::exception&) { |
|
435 // Handle error |
|
436 handleUpdateError(); |
|
437 |
|
438 OstTraceFunctionExit0(CPWLANAPVIEW_TRYUPDATE_EXIT); |
|
439 return false; |
|
440 } |
|
441 |
|
442 OstTraceFunctionExit0(DUP1_CPWLANAPVIEW_TRYUPDATE_EXIT); |
|
443 return true; |
|
444 } |
|
445 |
|
446 /*! |
|
447 Handles failed CommsDat update. |
|
448 */ |
|
449 void CpWlanApView::handleUpdateError() |
|
450 { |
|
451 OstTraceFunctionEntry0(CPWLANAPVIEW_HANDLEUPDATEERROR_ENTRY); |
|
452 |
|
453 // Show error note to user |
|
454 showMessageBox( |
|
455 HbMessageBox::MessageTypeWarning, |
|
456 hbTrId("txt_occ_info_unable_to_save_setting")); |
|
457 // Reload settings from CommsDat and update UI |
|
458 try { |
|
459 mCmConnectionMethod->refresh(); |
|
460 } |
|
461 catch (const std::exception&) { |
|
462 // Ignore error from refresh. Most likely this will not happen, but |
|
463 // if it does, there isn't very much we can do. |
|
464 OstTrace0( |
|
465 TRACE_ERROR, |
|
466 CPWLANAPPLUGIN_HANDLEUPDATEERROR, |
|
467 "Refresh failed"); |
|
468 }; |
|
469 updateAccessPointSettingsGroup(); |
|
470 |
|
471 OstTraceFunctionExit0(CPWLANAPVIEW_HANDLEUPDATEERROR_EXIT); |
|
472 } |
|
473 |
|
474 /*! |
|
475 Stores connection name. |
|
476 */ |
|
477 void CpWlanApView::connectionNameChanged() |
|
478 { |
|
479 OstTraceFunctionEntry0(CPWLANAPVIEW_CONNECTIONNAMECHANGED_ENTRY); |
|
480 |
|
481 QString connectionName = |
|
482 mConnectionNameItem->contentWidgetData("text").toString(); |
|
483 if (!connectionName.isEmpty()) { |
|
484 // Update to CommsDat |
|
485 mCmConnectionMethod->setStringAttribute( |
|
486 CMManagerShim::CmName, |
|
487 connectionName); |
|
488 if (tryUpdate()) { |
|
489 // Update successful |
|
490 // Read name because in case the name already exists it will |
|
491 // be made unique by CMManager |
|
492 connectionName = mCmConnectionMethod->getStringAttribute( |
|
493 CMManagerShim::CmName); |
|
494 mConnectionNameItem->setContentWidgetData("text", connectionName); |
|
495 } |
|
496 } else { |
|
497 // Inform user of invalid name |
|
498 showMessageBox( |
|
499 HbMessageBox::MessageTypeInformation, |
|
500 hbTrId("txt_occ_info_invalid_name")); |
|
501 |
|
502 // Empty name not allowed, revert back to old value |
|
503 connectionName = mCmConnectionMethod->getStringAttribute( |
|
504 CMManagerShim::CmName); |
|
505 mConnectionNameItem->setContentWidgetData("text", connectionName); |
|
506 } |
|
507 |
|
508 OstTraceFunctionExit0(CPWLANAPVIEW_CONNECTIONNAMECHANGED_EXIT); |
|
509 } |
|
510 |
|
511 /*! |
|
512 Stores WLAN network name. |
|
513 */ |
|
514 void CpWlanApView::wlanNetworkNameChanged() |
|
515 { |
|
516 OstTraceFunctionEntry0(CPWLANAPVIEW_WLANNETWORKNAMECHANGED_ENTRY); |
|
517 |
|
518 // Update to CommsDat |
|
519 QString wlanNetworkName = |
|
520 mWlanNetworkNameItem->contentWidgetData("text").toString(); |
|
521 if (!wlanNetworkName.isEmpty()) { |
|
522 mCmConnectionMethod->setStringAttribute( |
|
523 CMManagerShim::WlanSSID, |
|
524 wlanNetworkName); |
|
525 (void)tryUpdate(); |
|
526 } else { |
|
527 // Inform user of invalid name |
|
528 showMessageBox( |
|
529 HbMessageBox::MessageTypeInformation, |
|
530 hbTrId("txt_occ_info_invalid_name")); |
|
531 |
|
532 // Empty name not allowed, revert back to old value |
|
533 wlanNetworkName = mCmConnectionMethod->getStringAttribute( |
|
534 CMManagerShim::WlanSSID); |
|
535 mWlanNetworkNameItem->setContentWidgetData("text", wlanNetworkName); |
|
536 } |
|
537 |
|
538 OstTraceFunctionExit0(CPWLANAPVIEW_WLANNETWORKNAMECHANGED_EXIT); |
|
539 } |
|
540 |
|
541 /*! |
|
542 Stores WLAN network status. |
|
543 */ |
|
544 void CpWlanApView::networkStatusChanged(int index) |
|
545 { |
|
546 OstTraceFunctionEntry0(CPWLANAPVIEW_NETWORKSTATUSCHANGED_ENTRY); |
|
547 |
|
548 // Update to CommsDat |
|
549 mCmConnectionMethod->setBoolAttribute(CMManagerShim::WlanScanSSID, |
|
550 mNetworkStatusMap.value(index)); |
|
551 (void)tryUpdate(); |
|
552 |
|
553 OstTraceFunctionExit0(CPWLANAPVIEW_NETWORKSTATUSCHANGED_EXIT); |
|
554 } |
|
555 |
|
556 /*! |
|
557 Stores WLAN network mode. |
|
558 */ |
|
559 void CpWlanApView::networkModeChanged(int index) |
|
560 { |
|
561 OstTraceFunctionEntry0(CPWLANAPVIEW_NETWORKMODECHANGED_ENTRY); |
|
562 |
|
563 // Update to CommsDat |
|
564 mCmConnectionMethod->setIntAttribute(CMManagerShim::WlanConnectionMode, |
|
565 mNetworkModeMap.value(index)); |
|
566 (void)tryUpdate(); |
|
567 |
|
568 OstTraceFunctionExit0(CPWLANAPVIEW_NETWORKMODECHANGED_EXIT); |
|
569 } |
|
570 |
|
571 /*! |
|
572 Stores WLAN security mode. |
|
573 */ |
|
574 void CpWlanApView::securityModeChanged(int index) |
|
575 { |
|
576 OstTraceFunctionEntry0(CPWLANAPVIEW_SECURITYMODECHANGED_ENTRY); |
|
577 |
|
578 // Get security plugin |
|
579 CpWlanSecurityPluginInterface *plugin = mSecurityModeMap.value(index); |
|
580 // Update to CommsDat |
|
581 if (plugin) { |
|
582 mCmConnectionMethod->setIntAttribute(CMManagerShim::WlanSecurityMode, |
|
583 plugin->securityMode()); |
|
584 } else { |
|
585 mCmConnectionMethod->setIntAttribute(CMManagerShim::WlanSecurityMode, |
|
586 CMManagerShim::WlanSecModeOpen); |
|
587 } |
|
588 (void)tryUpdate(); |
|
589 |
|
590 // Update UI |
|
591 updateSecurityGroup( |
|
592 mSecurityModeItem->contentWidgetData("currentIndex").toInt()); |
|
593 |
|
594 OstTraceFunctionExit0(CPWLANAPVIEW_SECURITYMODECHANGED_EXIT); |
|
595 } |
|
596 |
|
597 /*! |
|
598 Stores homepage. |
|
599 */ |
|
600 void CpWlanApView::homepageChanged() |
|
601 { |
|
602 OstTraceFunctionEntry0(CPWLANAPVIEW_HOMEPAGECHANGED_ENTRY); |
|
603 |
|
604 // Update to CommsDat |
|
605 QString homepage = mHomepageItem->contentWidgetData("text").toString(); |
|
606 mCmConnectionMethod->setStringAttribute( |
|
607 CMManagerShim::CmStartPage, |
|
608 homepage); |
|
609 (void)tryUpdate(); |
|
610 |
|
611 OstTraceFunctionExit0(CPWLANAPVIEW_HOMEPAGECHANGED_EXIT); |
|
612 } |
|
613 |
|
614 /*! |
|
615 Handles view menu actions. |
|
616 */ |
|
617 void CpWlanApView::menuActionTriggered(HbAction *action) |
|
618 { |
|
619 OstTraceFunctionEntry0(CPWLANAPVIEW_MENUACTIONTRIGGERED_ENTRY); |
|
620 |
|
621 if (action == mAdvancedSettingsAction) { |
|
622 HbMainWindow *mainWindow = this->mainWindow(); |
|
623 |
|
624 // Create the advanced settings view |
|
625 HbView *newView = new CpWlanApAdvancedView(mCmConnectionMethod); |
|
626 // Connect signal to return back to the previous view |
|
627 bool status = QObject::connect( |
|
628 newView, |
|
629 SIGNAL(aboutToClose()), |
|
630 this, |
|
631 SLOT(restoreCurrentView())); |
|
632 Q_ASSERT(status); |
|
633 |
|
634 mainWindow->addView(newView); |
|
635 mainWindow->setCurrentView(newView); |
|
636 } |
|
637 |
|
638 OstTraceFunctionExit0(CPWLANAPVIEW_MENUACTIONTRIGGERED_EXIT); |
|
639 } |
|
640 |
|
641 /*! |
|
642 Removes current view from main window and sets this view as the |
|
643 current view. Used when "back" button is pressed in "Advanced settings" |
|
644 view. |
|
645 */ |
|
646 void CpWlanApView::restoreCurrentView() |
|
647 { |
|
648 OstTraceFunctionEntry0(CPWLANAPVIEW_RESTORECURRENTVIEW_ENTRY); |
|
649 |
|
650 HbMainWindow *mainWindow = this->mainWindow(); |
|
651 |
|
652 // Remove the previous view and delete it |
|
653 HbView *prevView = mainWindow->currentView(); |
|
654 mainWindow->removeView(prevView); |
|
655 prevView->deleteLater(); |
|
656 |
|
657 // Set this view on top |
|
658 mainWindow->setCurrentView(this); |
|
659 |
|
660 OstTraceFunctionExit0(CPWLANAPVIEW_RESTORECURRENTVIEW_EXIT); |
|
661 } |
|
662 |
|
663 /*! |
|
664 Sets editor preferences for all HbLineEdit items. |
|
665 */ |
|
666 void CpWlanApView::setEditorPreferences(const QModelIndex modelIndex) |
|
667 { |
|
668 OstTraceFunctionEntry0(CPWLANAPVIEW_SETEDITORPREFERENCES_ENTRY); |
|
669 |
|
670 HbDataFormViewItem *viewItem = mForm->dataFormViewItem(modelIndex); |
|
671 HbDataFormModelItem *modelItem = mModel->itemFromIndex(modelIndex); |
|
672 |
|
673 if (modelItem == mConnectionNameItem |
|
674 || modelItem == mWlanNetworkNameItem |
|
675 || modelItem == mHomepageItem ) { |
|
676 // HbLineEdit items, get editor and editor interface |
|
677 HbLineEdit *edit = qobject_cast<HbLineEdit *> |
|
678 (viewItem->dataItemContentWidget()); |
|
679 HbEditorInterface editInterface(edit); |
|
680 |
|
681 if (modelItem == mConnectionNameItem) { |
|
682 // Setup editor for connection name |
|
683 editInterface.setConstraints(HbEditorConstraintLatinAlphabetOnly); |
|
684 edit->setInputMethodHints(Qt::ImhNoPredictiveText); |
|
685 edit->setMaxLength(CMManagerShim::CmNameLength); |
|
686 } else if (modelItem == mWlanNetworkNameItem) { |
|
687 // Setup editor for WLAN SSID |
|
688 editInterface.setInputMode(HbInputModeNone); |
|
689 editInterface.setConstraints(HbEditorConstraintLatinAlphabetOnly); |
|
690 // TODO: Remove comment, should be in w12 |
|
691 //editInterface.setEditorClass(HbInputEditorClassNetworkName); |
|
692 editInterface.setLocalDigitType(HbDigitTypeNone); |
|
693 edit->setInputMethodHints( |
|
694 Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase); |
|
695 edit->setMaxLength(CMManagerShim::WlanSSIDLength); |
|
696 } else { /* mHomepageItem */ |
|
697 // Setup editor for URL |
|
698 editInterface.setInputMode(HbInputModeNone); |
|
699 editInterface.setConstraints(HbEditorConstraintLatinAlphabetOnly); |
|
700 editInterface.setFilter(HbUrlFilter::instance()); |
|
701 editInterface.setEditorClass(HbInputEditorClassUrl); |
|
702 editInterface.setLocalDigitType(HbDigitTypeNone); |
|
703 edit->setInputMethodHints( |
|
704 Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase); |
|
705 edit->setMaxLength(CMManagerShim::CmStartPageLength); |
|
706 } |
|
707 } |
|
708 |
|
709 OstTraceFunctionExit0(CPWLANAPVIEW_SETEDITORPREFERENCES_EXIT); |
|
710 } |