31
|
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: API.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
// System includes
|
|
20 |
|
|
21 |
// User includes
|
|
22 |
#include "wlanwizard.h"
|
|
23 |
#include "wlanwizard_p.h"
|
|
24 |
|
|
25 |
/*!
|
|
26 |
\class WlanWizard
|
|
27 |
\brief Interface of WLAN Wizard.
|
|
28 |
|
|
29 |
Example usage:
|
|
30 |
\code
|
|
31 |
MyClass::createWizard() {
|
|
32 |
mWizard = new WlanWizard(mainWindow());
|
|
33 |
connect(
|
|
34 |
mWizard, SIGNAL(finished(int, bool)),
|
|
35 |
this, SLOT(finished(int, bool)));
|
|
36 |
connect(mWizard, SIGNAL(cancelled()), this, SLOT(cancelled()));
|
|
37 |
|
|
38 |
// If client know the parameters for WLAN Access Point call following
|
|
39 |
mWizard->setParameters(
|
|
40 |
"MySSid",
|
|
41 |
CmManagerShim::Infra,
|
|
42 |
CmManagerShim::WlanSecModeWpa,
|
|
43 |
true, // WPA-PSK
|
|
44 |
false, // Non-Hidden
|
|
45 |
false ); // Non-Wifi Protected Setup
|
|
46 |
|
|
47 |
// and execute wizard
|
|
48 |
mWizard->show();
|
|
49 |
}
|
|
50 |
|
|
51 |
void MyClass::finished(int iapId, bool connected) {
|
|
52 |
// User has successfully created WLAN IAP with the wizard.
|
|
53 |
|
|
54 |
// if connected equals to true, wizard has established connection to it
|
|
55 |
// now the client needs to connect also to given IAP Id to keep the
|
|
56 |
// connection open.
|
|
57 |
// see WlanQtUtils or RConnection.
|
|
58 |
|
|
59 |
// Delete wizard. Do not delete in this call stack since this call has
|
|
60 |
// been done from the context of the wizards call stack.
|
|
61 |
mWizard->deleteLater();
|
|
62 |
mWizard = NULL;
|
|
63 |
}
|
|
64 |
|
|
65 |
void MyClass::cancelled() {
|
|
66 |
// wizard operation was cancelled by user, iap has not been created
|
|
67 |
// and WLAN connection is not established
|
|
68 |
|
|
69 |
// Delete wizard. Do not delete in this call stack since this call has
|
|
70 |
// been done from the context of the wizards call stack.
|
|
71 |
mWizard->deleteLater();
|
|
72 |
mWizard = NULL;
|
|
73 |
}
|
|
74 |
\endcode
|
|
75 |
|
|
76 |
Implements wizard based on wizard pattern.
|
|
77 |
*/
|
|
78 |
|
|
79 |
/*!
|
|
80 |
\fn void WlanWizard::cancelled()
|
|
81 |
This signal is emitted when the execution of wizard has been cancelled.
|
|
82 |
*/
|
|
83 |
|
|
84 |
/*!
|
|
85 |
\fn void WlanWizard::finished(int iapId, bool connected)
|
|
86 |
This signal is emitted when the execution of wizard has been finished
|
|
87 |
succesfully.
|
|
88 |
|
|
89 |
@param iapId IAP ID that has been created.
|
|
90 |
@param connected true if the connection to wlan has been established.
|
|
91 |
*/
|
|
92 |
|
|
93 |
// External function prototypes
|
|
94 |
|
|
95 |
// Local constants
|
|
96 |
|
|
97 |
|
|
98 |
// ======== LOCAL FUNCTIONS ========
|
|
99 |
|
|
100 |
// ======== MEMBER FUNCTIONS ========
|
|
101 |
|
|
102 |
/*!
|
|
103 |
Constructor of WLAN Wizard.
|
|
104 |
|
|
105 |
@param [in] mainWindow HbMainWindow to where the wizard is going to be executed.
|
|
106 |
*/
|
|
107 |
WlanWizard::WlanWizard(HbMainWindow *mainWindow) :
|
|
108 |
d_ptr(new WlanWizardPrivate(this, mainWindow))
|
|
109 |
{
|
|
110 |
}
|
|
111 |
|
|
112 |
/*!
|
|
113 |
Destructor.
|
|
114 |
*/
|
|
115 |
WlanWizard::~WlanWizard()
|
|
116 |
{
|
|
117 |
delete d_ptr;
|
|
118 |
}
|
|
119 |
|
|
120 |
/*!
|
|
121 |
Client can set the known WLAN Access Point configurations to speed up wizard
|
|
122 |
processing and make it easier for end user.
|
|
123 |
|
|
124 |
Values for network mode (CmManagerShim::WlanConnectionMode) and security mode
|
|
125 |
(CmManagerShim::WlanSecMode).
|
|
126 |
|
|
127 |
Supported configuration sets:
|
|
128 |
- Open: \a ssid \a networkMode \a securityMode
|
|
129 |
- WEP: \a ssid \a networkMode \a securityMode
|
|
130 |
- WPA (2) with EAP: \a ssid \a networkMode \a securityMode \a usePsk (false)
|
|
131 |
- WPA (2) with PSK: \a ssid \a networkMode \a securityMode \a usePsk (true)
|
|
132 |
- 802.1x: \a ssid \a networkMode \a securityMode
|
|
133 |
|
|
134 |
Hidden WLAN:
|
|
135 |
\a hidden can be used with \a networkMode CmManagerShim::Infra
|
|
136 |
|
|
137 |
Wifi Protected Setup
|
|
138 |
\a wps can be used with Open, WEP and WPA (2) with PSK.
|
|
139 |
|
|
140 |
@param [in] ssid The name of WLAN network (ssid), max length 32 characters.
|
|
141 |
@param [in] networkMode Network mode of known access point
|
|
142 |
@param [in] securityMode Security mode of known access point
|
|
143 |
@param [in] usePsk used only with WPA or WPA2 \a securityMode
|
|
144 |
@param [in] hidden if true WLAN is hidden.
|
|
145 |
@param [in] wps is Wifi Protected Setup supported?
|
|
146 |
*/
|
|
147 |
void WlanWizard::setParameters(
|
|
148 |
const QString &ssid,
|
|
149 |
int networkMode,
|
|
150 |
int securityMode,
|
|
151 |
bool usePsk,
|
|
152 |
bool hidden,
|
|
153 |
bool wps)
|
|
154 |
{
|
|
155 |
d_ptr->setParameters(ssid, networkMode, securityMode, usePsk, hidden, wps);
|
|
156 |
}
|
|
157 |
|
|
158 |
/*!
|
|
159 |
Executes the wizard and shows the first page.
|
|
160 |
|
|
161 |
@note it is not allowed to call this method twice with same instance.
|
|
162 |
|
|
163 |
Possible signals:
|
|
164 |
- finished(int, bool): called after wizard has successfully completed
|
|
165 |
- cancelled(): user has cancelled the wizard operations.
|
|
166 |
|
|
167 |
First page for the wizard is SSID (WLAN network name) query or if
|
|
168 |
setParameters() has been called the first page is determined based on the
|
|
169 |
given configuration combination.
|
|
170 |
*/
|
|
171 |
void WlanWizard::show()
|
|
172 |
{
|
|
173 |
d_ptr->show();
|
|
174 |
}
|