|
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 * WLAN Wizard Page: Security mode Selection. |
|
16 * |
|
17 */ |
|
18 |
|
19 // System includes |
|
20 #include <HbDocumentLoader> |
|
21 #include <HbWidget> |
|
22 #include <HbRadioButtonList> |
|
23 #include <HbMainWindow> |
|
24 #include <HbLabel> |
|
25 #include <cmmanagerdefines_shim.h> |
|
26 |
|
27 // User includes |
|
28 #include "wlanwizard_p.h" |
|
29 #include "wlanwizard.h" |
|
30 #include "wlanwizardpagesecuritymode.h" |
|
31 #include "OstTraceDefinitions.h" |
|
32 #ifdef OST_TRACE_COMPILER_IN_USE |
|
33 #include "wlanwizardpagesecuritymodeTraces.h" |
|
34 #endif |
|
35 |
|
36 /*! |
|
37 * Constructor. Member initialization. |
|
38 */ |
|
39 WlanWizardPageSecurityMode::WlanWizardPageSecurityMode( |
|
40 WlanWizardPrivate* parent) : |
|
41 WlanWizardPageInternal(parent), |
|
42 mWidget(NULL), |
|
43 mList(NULL), |
|
44 mLabel(NULL), |
|
45 mLoader(NULL), |
|
46 mValid(false) |
|
47 { |
|
48 } |
|
49 |
|
50 /*! |
|
51 * Destructor. Loader widget is deleted. |
|
52 * All document widgets are deleted by wlanwizard_p destructor. |
|
53 */ |
|
54 WlanWizardPageSecurityMode::~WlanWizardPageSecurityMode() |
|
55 { |
|
56 delete mLoader; |
|
57 } |
|
58 |
|
59 /*! |
|
60 * Page initialization. If view is already loaded, does nothing. |
|
61 */ |
|
62 HbWidget* WlanWizardPageSecurityMode::initializePage() |
|
63 { |
|
64 OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESECURITYMODE_INITIALIZEPAGE, |
|
65 "WlanWizardPageSecurityMode::initializePage" ); |
|
66 |
|
67 if (mWidget==NULL) { |
|
68 |
|
69 mLoader = new HbDocumentLoader(mWizard->mainWindow()); |
|
70 |
|
71 bool ok; |
|
72 |
|
73 mLoader->load( ":/docml/occ_add_wlan_02_03.docml", &ok ); |
|
74 Q_ASSERT_X(ok, "WlanWizardPageSecurityMode", "Invalid docml file"); |
|
75 |
|
76 // Initialize orientation |
|
77 loadDocml( mWizard->mainWindow()->orientation() ); |
|
78 |
|
79 // Load widgets |
|
80 mWidget = qobject_cast<HbWidget*> (mLoader->findWidget("occ_add_wlan_02")); |
|
81 Q_ASSERT_X(mWidget != NULL, "WlanWizardPageSecurityMode", "View not found"); |
|
82 |
|
83 mList = qobject_cast<HbRadioButtonList*> (mLoader->findWidget("list")); |
|
84 Q_ASSERT_X(mList != NULL, "WlanWizardPageSecurityMode", "List not found"); |
|
85 |
|
86 mLabel = qobject_cast<HbLabel*> (mLoader->findWidget("dialog_6")); |
|
87 Q_ASSERT_X(mLabel != NULL, "WlanWizardPageSecurityMode", "Label not found"); |
|
88 |
|
89 mLabel->setPlainText(hbTrId("txt_occ_dialog_select_network_security_mode")); |
|
90 |
|
91 // Create contents to the security mode radio button list. |
|
92 populateSecModeList(); |
|
93 |
|
94 // Connect orientation signal from the main window to orientation |
|
95 // loader. |
|
96 ok &= connect( mWizard->mainWindow(), |
|
97 SIGNAL(orientationChanged(Qt::Orientation)), |
|
98 this, SLOT(loadDocml(Qt::Orientation))); |
|
99 |
|
100 // Connect signal from the radio button list indicating that an item |
|
101 // has been selected to validation handler. |
|
102 ok &= connect( mList, SIGNAL(itemSelected(int)), |
|
103 this, SLOT(itemSelected(int))); |
|
104 |
|
105 Q_ASSERT_X(ok, "WlanWizardPageSecurityMode", "slot connection failed"); |
|
106 |
|
107 |
|
108 |
|
109 } |
|
110 return mWidget; |
|
111 } |
|
112 |
|
113 /*! |
|
114 * Indicates the validity of the security mode page. |
|
115 * @see WlanWizardPage |
|
116 */ |
|
117 bool WlanWizardPageSecurityMode::showPage() |
|
118 { |
|
119 return mValid; |
|
120 } |
|
121 |
|
122 /*! |
|
123 * Sets the page as valid, if any mode is selected. |
|
124 * (Initially none is selected.) |
|
125 */ |
|
126 void WlanWizardPageSecurityMode::itemSelected(int /* index */) |
|
127 { |
|
128 OstTrace0( TRACE_BORDER, WLANWIZARDPAGESECURITYMODE_ITEMSELECTED, |
|
129 "WlanWizardPageSecurityMode::itemSelected" ); |
|
130 |
|
131 mValid = true; |
|
132 mWizard->enableNextButton(mValid); |
|
133 } |
|
134 |
|
135 /*! |
|
136 * Evaluates and returns the next page id. |
|
137 * @see initializePage() |
|
138 */ |
|
139 int WlanWizardPageSecurityMode::nextId(bool &removeFromStack) const |
|
140 { |
|
141 removeFromStack = false; |
|
142 |
|
143 // The configuration is selected from the mSecModes list, which is ordered |
|
144 // during the page initialization. |
|
145 mWizard->setConfiguration( WlanWizardPrivate::ConfSecurityMode, |
|
146 mSecModes.at( mList->selected() ) ); |
|
147 |
|
148 // The configuration is selected from the mUsePsk list, which is ordered |
|
149 // during the page initialization. |
|
150 mWizard->setConfiguration( WlanWizardPrivate::ConfUsePsk, |
|
151 mUsePsk.at( mList->selected() ) ); |
|
152 |
|
153 return mPageIds.at( mList->selected() ); |
|
154 } |
|
155 |
|
156 /*! |
|
157 * Loads the document with given orientation. |
|
158 */ |
|
159 void WlanWizardPageSecurityMode::loadDocml(Qt::Orientation orientation) |
|
160 { |
|
161 OstTrace1( TRACE_NORMAL, WLANWIZARDPAGESECURITYMODE_LOADDOCML, |
|
162 "WlanWizardPageSecurityMode::loadDocml - orientation;orientation=%x", |
|
163 ( TUint )( orientation ) ); |
|
164 |
|
165 bool ok; |
|
166 if( orientation == Qt::Horizontal ) { |
|
167 mLoader->load(":/docml/occ_add_wlan_02_03.docml", "landscape_section", &ok); |
|
168 Q_ASSERT_X(ok, "WlanWizardPageSecurityMode", "Landscape section not found"); |
|
169 } |
|
170 else { |
|
171 mLoader->load(":/docml/occ_add_wlan_02_03.docml", "portrait_section", &ok); |
|
172 Q_ASSERT_X(ok, "WlanWizardPageSecurityMode", "Portrait section not found"); |
|
173 } |
|
174 } |
|
175 |
|
176 /*! |
|
177 * Support function that creates the contents of the security mode list. |
|
178 */ |
|
179 void WlanWizardPageSecurityMode::populateSecModeList() |
|
180 { |
|
181 QStringList items; |
|
182 |
|
183 mSecModes.clear(); |
|
184 mPageIds.clear(); |
|
185 |
|
186 // Create the radio button list to correspond to correct security mode |
|
187 // identifiers and page identifiers. |
|
188 // Populate the list according to network mode selection. |
|
189 addToList(items, hbTrId("txt_occ_list_open"), |
|
190 CMManagerShim::WlanSecModeOpen, |
|
191 WlanWizardPage::PageProcessSettings, |
|
192 false); |
|
193 |
|
194 addToList(items, hbTrId("txt_occ_list_wep_1"), |
|
195 CMManagerShim::WlanSecModeWep, |
|
196 WlanWizardPageInternal::PageKeyQuery, |
|
197 true); |
|
198 |
|
199 // In case of Ad-hoc network, exclude wpa, eap and 802.1X modes. |
|
200 if(mWizard->configuration(WlanWizardPrivate::ConfNetworkMode).toInt() |
|
201 != CMManagerShim::Adhoc) { |
|
202 |
|
203 addToList(items, hbTrId("txt_occ_list_wpa_with_password"), |
|
204 CMManagerShim::WlanSecModeWpa, |
|
205 WlanWizardPageInternal::PageKeyQuery, |
|
206 true); |
|
207 |
|
208 // TODO: Fix these codes |
|
209 addToList(items, hbTrId("txt_occ_list_wpa_with_eap"), |
|
210 CMManagerShim::WlanSecModeWpa, |
|
211 WlanWizardPage::PageEapStart, |
|
212 false); |
|
213 |
|
214 addToList(items, hbTrId("txt_occ_list_8021x_1"), |
|
215 CMManagerShim::WlanSecMode802_1x, |
|
216 WlanWizardPage::PageEapStart, |
|
217 false); |
|
218 } |
|
219 |
|
220 mList->setItems(items); |
|
221 } |
|
222 |
|
223 /*! |
|
224 * Creates lists for security modes and page id:s so that they can be referred |
|
225 * with radio button widget index. |
|
226 */ |
|
227 void WlanWizardPageSecurityMode::addToList(QStringList &list, |
|
228 const QString &item, int mode, int page, bool psk) |
|
229 { |
|
230 list << item; |
|
231 mSecModes.append(mode); |
|
232 mPageIds.append(page); |
|
233 mUsePsk.append(psk); |
|
234 } |
|
235 |
|
236 |