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: Private implementation. |
|
16 * |
|
17 */ |
|
18 |
|
19 /* |
|
20 * %version: 1 % |
|
21 */ |
|
22 |
|
23 // System includes |
|
24 #include <hbdocumentloader.h> |
|
25 #include <qgraphicswidget> |
|
26 #include <hbmainwindow.h> |
|
27 #include <hbview.h> |
|
28 #include <hbstackedwidget.h> |
|
29 #include <hblabel.h> |
|
30 #include <hbaction.h> |
|
31 #include <qapplication.h> |
|
32 |
|
33 // Trace includes |
|
34 #include "OstTraceDefinitions.h" |
|
35 #ifdef OST_TRACE_COMPILER_IN_USE |
|
36 #include "wpswizardprivateTraces.h" |
|
37 #endif |
|
38 |
|
39 // User includes |
|
40 #include "wlanwizardhelpper.h" |
|
41 // Wizard |
|
42 #include "wpswizard.h" |
|
43 #include "wpswizard_p.h" |
|
44 // Wizard Pages |
|
45 #include "wpswizardsteptwo.h" |
|
46 #include "wpswizardstepthreebutton.h" |
|
47 #include "wpswizardstepthreenumber.h" |
|
48 #include "wpswizardstepfour.h" |
|
49 #include "wpswizardstepfive.h" |
|
50 |
|
51 |
|
52 class WlanWizardHelpper; |
|
53 |
|
54 /*! |
|
55 * Constructor for the private implementation of wps wiazard |
|
56 * |
|
57 * \param WpsWizard* pointer to the framework object |
|
58 * \param WlanWizardHelpper * pointer to the wizard helpper class |
|
59 * |
|
60 */ |
|
61 WpsWizardPrivate::WpsWizardPrivate(WpsWizard* wizard, |
|
62 WlanWizardHelpper *wizardHelpper, int bearerType, int referenceId) : |
|
63 q_ptr(wizard), mBearerType(bearerType), mReferenceId(referenceId), |
|
64 mWizardHelpper(wizardHelpper), mRandomNumber(0) |
|
65 |
|
66 { |
|
67 OstTraceFunctionEntry1(WPSWIZARDPRIVATE_WPSWIZARDPRIVATE_ENTRY, this); |
|
68 |
|
69 // TODO: load localization file |
|
70 mTranslator = new QTranslator(this); |
|
71 mTranslator->load(":/loc/wpswizardplugin.qm"); |
|
72 qApp->installTranslator(mTranslator); |
|
73 |
|
74 createPages(); |
|
75 |
|
76 OstTraceFunctionExit1(WPSWIZARDPRIVATE_WPSWIZARDPRIVATE_EXIT, this); |
|
77 } |
|
78 |
|
79 /*! |
|
80 * Destructor |
|
81 */ |
|
82 WpsWizardPrivate::~WpsWizardPrivate() |
|
83 { |
|
84 OstTraceFunctionEntry1(WPSWIZARDPRIVATE_WPSWIZARDPRIVATE_ENTRY, this); |
|
85 // have to delete the memory that was allocated in this object |
|
86 mIapList.clear(); |
|
87 delete mTranslator; |
|
88 OstTraceFunctionExit1(WPSWIZARDPRIVATE_WPSWIZARDPRIVATE_EXIT, this); |
|
89 } |
|
90 |
|
91 /*! |
|
92 * Provides the caller with the functionality to enable/disable the 'Next' button |
|
93 * |
|
94 * \param bool to indicate whether to enable or disable the 'next button' |
|
95 */ |
|
96 void WpsWizardPrivate::enableNextButton(bool enable) |
|
97 { |
|
98 OstTraceFunctionEntry1(WPSWIZARDPRIVATE_ENABLENEXTBUTTON_ENTRY, this); |
|
99 mWizardHelpper->enableNextButton(enable); |
|
100 OstTraceFunctionExit1(WPSWIZARDPRIVATE_ENABLENEXTBUTTON_EXIT, this); |
|
101 } |
|
102 |
|
103 /*! |
|
104 * Provides the functionality to automatically move to the next page. |
|
105 */ |
|
106 void WpsWizardPrivate::nextPage() |
|
107 { |
|
108 OstTraceFunctionEntry1(WPSWIZARDPRIVATE_NEXTPAGE_ENTRY, this); |
|
109 mWizardHelpper->nextPage(); |
|
110 OstTraceFunctionExit1(WPSWIZARDPRIVATE_NEXTPAGE_EXIT, this); |
|
111 } |
|
112 |
|
113 /*! |
|
114 * Provides the functionality to store the recieved settings |
|
115 * |
|
116 * \param int indicates the index in the array of received settings to be stored |
|
117 */ |
|
118 void WpsWizardPrivate::storeSettings(int aIndex) |
|
119 { |
|
120 OstTraceFunctionEntry1(WPSWIZARDPRIVATE_STORESETTINGS_ENTRY, this); |
|
121 mWpsAttr = mIapList[aIndex]; |
|
122 |
|
123 QString ssid = QString::fromUtf8((const char*) mWpsAttr.iSsid.Ptr(), |
|
124 mWpsAttr.iSsid.Length()); |
|
125 |
|
126 mWizardHelpper->setConfigurations(WlanWizardHelpper::ConfSsid, ssid); |
|
127 mWizardHelpper->setConfigurations(WlanWizardHelpper::ConfNetworkMode, |
|
128 mWpsAttr.iOperatingMode); |
|
129 mWizardHelpper->setConfigurations(WlanWizardHelpper::ConfSecurityMode, |
|
130 mWpsAttr.iSecurityMode); |
|
131 mWizardHelpper->setConfigurations(WlanWizardHelpper::ConfKeyWepDefault, |
|
132 mWpsAttr.iWepDefaultKey); |
|
133 QString str = QString::fromUtf8((const char*) mWpsAttr.iWepKey1.Ptr(), |
|
134 mWpsAttr.iWepKey1.Length()); |
|
135 mWizardHelpper->setConfigurations(WlanWizardHelpper::ConfKeyWep1, str); |
|
136 str = QString::fromUtf8((const char*) mWpsAttr.iWepKey2.Ptr(), mWpsAttr.iWepKey2.Length()); |
|
137 mWizardHelpper->setConfigurations(WlanWizardHelpper::ConfKeyWep2, str); |
|
138 str = QString::fromUtf8((const char*) mWpsAttr.iWepKey3.Ptr(), mWpsAttr.iWepKey3.Length()); |
|
139 mWizardHelpper->setConfigurations(WlanWizardHelpper::ConfKeyWep3, str); |
|
140 str = QString::fromUtf8((const char*) mWpsAttr.iWepKey4.Ptr(), mWpsAttr.iWepKey4.Length()); |
|
141 mWizardHelpper->setConfigurations(WlanWizardHelpper::ConfKeyWep4, str); |
|
142 |
|
143 OstTraceFunctionExit1(WPSWIZARDPRIVATE_STORESETTINGS_EXIT, this); |
|
144 } |
|
145 |
|
146 /*! |
|
147 * Provides the functionality to retrieve the ssid of the network to connect |
|
148 * \return returns the SSID as a QString |
|
149 */ |
|
150 QString WpsWizardPrivate::getSsid() |
|
151 { |
|
152 OstTraceFunctionEntry1(WPSWIZARDPRIVATE_GETSSID_ENTRY, this); |
|
153 QString ssid; |
|
154 ssid = mWizardHelpper->configurations(WlanWizardHelpper::ConfSsid).toString(); |
|
155 OstTraceFunctionExit1(WPSWIZARDPRIVATE_GETSSID_EXIT, this); |
|
156 return ssid; |
|
157 } |
|
158 |
|
159 /*! |
|
160 * Provides functionality for the caller to store the array of recieved settings from AP |
|
161 * \param QList<TWlanProtectedSetupCredentialAttribute>& received settings |
|
162 * |
|
163 */ |
|
164 void WpsWizardPrivate::storeSettingsArray(QList< |
|
165 TWlanProtectedSetupCredentialAttribute>& aIapList) |
|
166 { |
|
167 OstTraceFunctionEntry1(WPSWIZARDPRIVATE_STORESETTINGSARRAY_ENTRY, this); |
|
168 mIapList = aIapList; |
|
169 OstTraceFunctionExit1(WPSWIZARDPRIVATE_STORESETTINGSARRAY_EXIT, this); |
|
170 } |
|
171 |
|
172 /*! |
|
173 * Returns the array of settings received from the AP |
|
174 * |
|
175 * \return Array containing the settings |
|
176 */ |
|
177 QList<TWlanProtectedSetupCredentialAttribute> WpsWizardPrivate::getSettingsArray() |
|
178 { |
|
179 OstTraceFunctionEntry1(WPSWIZARDPRIVATE_GETSETTINGSARRAY_ENTRY, this); |
|
180 OstTraceFunctionExit1(WPSWIZARDPRIVATE_GETSETTINGSARRAY_EXIT, this); |
|
181 return mIapList; |
|
182 } |
|
183 |
|
184 |
|
185 |
|
186 /*! |
|
187 * Creates the required pages for WPS setup |
|
188 */ |
|
189 void WpsWizardPrivate::createPages() |
|
190 { |
|
191 OstTraceFunctionEntry1(WPSWIZARDPRIVATE_CREATEPAGES_ENTRY, this); |
|
192 mWizardHelpper->addPage(WpsWizardPage::PageWpsWizardStep2, |
|
193 new WpsPageStepTwo(this)); |
|
194 mWizardHelpper->addPage(WpsWizardPage::PageWpsWizardStep3_Button, |
|
195 new WpsPageStepThreeButton(this)); |
|
196 mWizardHelpper->addPage(WpsWizardPage::PageWpsWizardStep3_Number, |
|
197 new WpsPageStepThreeNumber(this)); |
|
198 mWizardHelpper->addPage(WpsWizardPage::PageWpsWizardStep4, |
|
199 new WpsPageStepFour(this)); |
|
200 mWizardHelpper->addPage(WpsWizardPage::PageWpsWizardStep5, |
|
201 new WpsPageStepFive(this)); |
|
202 OstTraceFunctionExit1(WPSWIZARDPRIVATE_CREATEPAGES_EXIT, this); |
|
203 } |
|
204 |
|
205 /*! |
|
206 * Provides with the functionality to store the PIN generated |
|
207 * |
|
208 * \param int The generated PIN code to be used in succesive steps |
|
209 * |
|
210 */ |
|
211 void WpsWizardPrivate::setPin(int random) |
|
212 { |
|
213 OstTraceFunctionEntry1(WPSWIZARDPRIVATE_SETPIN_ENTRY, this); |
|
214 mRandomNumber = random; |
|
215 OstTraceFunctionExit1(WPSWIZARDPRIVATE_SETPIN_EXIT, this); |
|
216 } |
|
217 |
|
218 /*! |
|
219 * Returns the PIN code stored in one of the WPS Pages |
|
220 * |
|
221 * \return PIN code to be used in the WPS operation. |
|
222 */ |
|
223 int WpsWizardPrivate::getPin() |
|
224 { |
|
225 OstTraceFunctionEntry1(WPSWIZARDPRIVATE_GETPIN_ENTRY, this); |
|
226 OstTraceFunctionExit1(WPSWIZARDPRIVATE_GETPIN_EXIT, this); |
|
227 return mRandomNumber; |
|
228 |
|
229 } |
|