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 * WPS Wizard Page: Step 4 progress bar display |
|
16 * |
|
17 */ |
|
18 |
|
19 /* |
|
20 * %version: 1 % |
|
21 */ |
|
22 |
|
23 // System includes |
|
24 #include <hbdocumentloader.h> |
|
25 #include <hbwidget.h> |
|
26 #include <hbradiobuttonlist.h> |
|
27 #include <hblineedit.h> |
|
28 #include <hblabel.h> |
|
29 #include <hbprogressbar.h> |
|
30 #include <hbmessagebox.h> |
|
31 |
|
32 // User includes |
|
33 #include "wpswizardstepfour.h" |
|
34 #include "wpswizard_p.h" |
|
35 |
|
36 // Trace includes |
|
37 #include "OstTraceDefinitions.h" |
|
38 #ifdef OST_TRACE_COMPILER_IN_USE |
|
39 #include "wpspagestepfourTraces.h" |
|
40 #endif |
|
41 |
|
42 /*! |
|
43 * Constructor for WPS page four |
|
44 * |
|
45 * \param WpsWizardPrivate* Pointer to the WPS wizard private implementation |
|
46 */ |
|
47 WpsPageStepFour::WpsPageStepFour(WpsWizardPrivate* parent) : |
|
48 WpsWizardPage(parent), mWidget(NULL), mRadio(NULL), mValid(false) |
|
49 { |
|
50 OstTraceFunctionEntry1(WPSPAGESTEPFOUR_WPSPAGESTEPFOUR_ENTRY, this) |
|
51 OstTraceFunctionExit1(WPSPAGESTEPFOUR_WPSPAGESTEPFOUR_EXIT, this) |
|
52 |
|
53 } |
|
54 |
|
55 /*! |
|
56 * Destructor |
|
57 */ |
|
58 WpsPageStepFour::~WpsPageStepFour() |
|
59 { |
|
60 OstTraceFunctionEntry1(WPSPAGESTEPFOUR_WPSPAGESTEPFOUR_ENTRY, this) |
|
61 |
|
62 delete mWidget; |
|
63 delete mWpsActiveRunner; |
|
64 |
|
65 OstTraceFunctionExit1(WPSPAGESTEPFOUR_WPSPAGESTEPFOUR_EXIT, this) |
|
66 } |
|
67 |
|
68 /*! |
|
69 * Loads the page with all the widgets |
|
70 * |
|
71 * \return HbWidget* Returns the view widget |
|
72 */ |
|
73 HbWidget* WpsPageStepFour::initializePage() |
|
74 { |
|
75 OstTraceFunctionEntry1(WPSPAGESTEPFOUR_INITIALIZEPAGE_ENTRY, this) |
|
76 |
|
77 if (!mWidget) { |
|
78 bool ok; |
|
79 HbDocumentLoader loader; |
|
80 loader.load(":/docml/occ_wps_P4.docml", &ok); |
|
81 Q_ASSERT_X(ok, "WPS Wizard", "Invalid docml file"); |
|
82 |
|
83 mWidget = qobject_cast<HbWidget*> (loader.findWidget("occ_wps_P4")); |
|
84 Q_ASSERT_X(mWidget != 0, "WPS Wizard", "View not found"); |
|
85 |
|
86 //mTitle = qobject_cast<HbLabel*> (loader.findWidget("label_title")); |
|
87 //Q_ASSERT_X(mTitle != 0, "WPS wizard", "title not found"); |
|
88 |
|
89 mHeading = qobject_cast<HbLabel*> (loader.findWidget("label_heading")); |
|
90 Q_ASSERT_X(mTitle != 0, "WPS wizard", "Header not found"); |
|
91 |
|
92 mProgressBar = qobject_cast<HbProgressBar*> (loader.findWidget("horizontalProgressBar")); |
|
93 Q_ASSERT_X(mRadio != 0, "WPS Wizard", "List not found"); |
|
94 |
|
95 // start the framework. |
|
96 mWpsActiveRunner = CWpsActiveRunner::NewL(*this); |
|
97 Q_ASSERT(error == NULL); |
|
98 } |
|
99 |
|
100 mProgressBar->setRange(0, 0); |
|
101 |
|
102 StartWpsRunner(); |
|
103 OstTraceFunctionExit1(WPSPAGESTEPFOUR_INITIALIZEPAGE_EXIT, this) |
|
104 |
|
105 return mWidget; |
|
106 } |
|
107 |
|
108 /*! |
|
109 * Funtion to determine the next page to be displayed in the wizard process |
|
110 * |
|
111 * \param bool& RemoveFromStack indicating whether the current page should be |
|
112 * removed from the stack |
|
113 * |
|
114 * \return int Page Id of the next page to be displayed. |
|
115 */ |
|
116 int WpsPageStepFour::nextId(bool &removeFromStack) const |
|
117 { |
|
118 OstTraceFunctionEntry1(WPSPAGESTEPFOUR_NEXTID_ENTRY, this) |
|
119 |
|
120 int id = WpsWizardPage::PageNone; |
|
121 removeFromStack = false; |
|
122 if (countCredentials >= 2) { |
|
123 id = WpsWizardPage::PageWpsWizardStep5; |
|
124 } |
|
125 else { |
|
126 // only one response received. So go to the summary page |
|
127 mWizard->storeSettings(0); |
|
128 id = WlanWizardPage::PageProcessSettings; |
|
129 } |
|
130 OstTraceFunctionExit1(WPSPAGESTEPFOUR_NEXTID_EXIT, this) |
|
131 |
|
132 return id; |
|
133 } |
|
134 |
|
135 |
|
136 /*! |
|
137 * Determines the Number of steps to move backwards when 'Prev' Button |
|
138 * is clicked |
|
139 * |
|
140 * \return int Number of pages to move backwards |
|
141 */ |
|
142 int WpsPageStepFour::stepsBackwards() |
|
143 { |
|
144 OstTraceFunctionEntry1(WPSPAGESTEPFOUR_STEPSBACKWARDS_ENTRY, this) |
|
145 OstTraceFunctionExit1(WPSPAGESTEPFOUR_STEPBACKWARDS_EXIT, this) |
|
146 |
|
147 return (PageWpsWizardStep4 - PageWpsWizardStep2) - 1; |
|
148 } |
|
149 |
|
150 /*! |
|
151 * Callback when the previous button is clicked |
|
152 */ |
|
153 void WpsPageStepFour::previousTriggered() |
|
154 { |
|
155 OstTraceFunctionEntry1(WPSPAGESTEPFOUR_PREVIOUSTRIGGERED_ENTRY, this) |
|
156 |
|
157 mWpsActiveRunner->DoCancel(); |
|
158 OstTraceFunctionExit1(WPSPAGESTEPFOUR_PREVIOUSTRIGGERED_EXIT, this) |
|
159 |
|
160 } |
|
161 |
|
162 /*! |
|
163 * CallBack when the cancel button is clicked |
|
164 */ |
|
165 void WpsPageStepFour::cancelTriggered() |
|
166 { |
|
167 OstTraceFunctionEntry1(WPSPAGESTEPFOUR_CANCELTRIGGERED_ENTRY, this) |
|
168 |
|
169 mWpsActiveRunner->DoCancel(); |
|
170 OstTraceFunctionExit1(WPSPAGESTEPFOUR_CANCELTRIGGERED_EXIT, this) |
|
171 |
|
172 } |
|
173 |
|
174 /*! |
|
175 * Validates the content of the pages |
|
176 * |
|
177 * \return bool Indicating the result of the operation |
|
178 */ |
|
179 bool WpsPageStepFour::validate() const |
|
180 { |
|
181 OstTraceFunctionEntry1(WPSPAGESTEPFOUR_VALIDATE_ENTRY, this) |
|
182 OstTraceFunctionExit1(WPSPAGESTEPFOUR_VALIDATE_EXIT, this) |
|
183 |
|
184 return mValid; |
|
185 } |
|
186 |
|
187 |
|
188 /*! |
|
189 * CallBack function when the middleware WPS call returns back |
|
190 * |
|
191 * \param QList An array of received settngs |
|
192 * \param int Error indicating the result of the operation |
|
193 * |
|
194 */ |
|
195 void WpsPageStepFour::WpsActiveRunnerStopped( |
|
196 QList<TWlanProtectedSetupCredentialAttribute>& aCredentials, TInt aError) |
|
197 { |
|
198 OstTraceFunctionEntry1(WPSPAGESTEPFOUR_WPSACTIVERUNNERSTOPPED_ENTRY, this) |
|
199 |
|
200 mWpsErrorCode = aError; |
|
201 if (aError == KErrNone) { |
|
202 countCredentials = aCredentials.count(); |
|
203 mWizard->storeSettingsArray(aCredentials); |
|
204 mWizard->nextPage(); |
|
205 } |
|
206 else if (aError == KErrCancel) { |
|
207 // operation was cancelled |
|
208 |
|
209 } |
|
210 else { |
|
211 QString str; |
|
212 str = QString("Error: %1").arg(aError); |
|
213 mProgressBar->setVisible(false); |
|
214 //mHeading->setPlainText("General Error"); |
|
215 mHeading->setPlainText(str); |
|
216 mWizard->enableNextButton(false); |
|
217 |
|
218 } |
|
219 OstTraceFunctionExit1(WPSPAGESTEPFOUR_WPSACTIVERUNNERSTOPPED_EXIT, this) |
|
220 } |
|
221 |
|
222 |
|
223 /*! |
|
224 * Provides the functionality to initiate the WPS functionality |
|
225 */ |
|
226 void WpsPageStepFour::StartWpsRunner() |
|
227 { |
|
228 |
|
229 OstTraceFunctionEntry1(WPSPAGESTEPFOUR_STARTWPSRUNNER_ENTRY, this) |
|
230 |
|
231 // convert QString to symbian RBuf8 |
|
232 |
|
233 QString ssid = mWizard->getSsid(); |
|
234 |
|
235 TPtrC ptrName(reinterpret_cast<const TText*> (ssid.constData())); |
|
236 |
|
237 RBuf8 ssidName; |
|
238 ssidName.Create(ptrName.Length()); |
|
239 ssidName.Copy(ptrName); |
|
240 |
|
241 mWpsActiveRunner->StartSetup(ssidName, mWizard->getPin()); |
|
242 ssidName.Close(); |
|
243 OstTraceFunctionExit1(WPSPAGESTEPFOUR_STARTWPSRUNNER_EXIT, this) |
|
244 } |
|