|
1 /* |
|
2 * Copyright (c) 2009-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 Qt Utilities implementation. |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 |
|
20 // User includes |
|
21 |
|
22 #include "wlanqtutilsap.h" |
|
23 #include "wlanqtutilsiap.h" |
|
24 #include "wlanqtutils_p.h" |
|
25 #include "wlanqtutils.h" |
|
26 |
|
27 /*! |
|
28 \class WlanQtUtils |
|
29 \brief Wlan Qt Utilities. This class provides a Qt API for UI components |
|
30 for retrieving different kind of information related to WLAN |
|
31 functionality. |
|
32 */ |
|
33 |
|
34 |
|
35 // External function prototypes |
|
36 |
|
37 // Local constants |
|
38 |
|
39 // ======== LOCAL FUNCTIONS ======== |
|
40 |
|
41 // ======== MEMBER FUNCTIONS ======== |
|
42 |
|
43 /*! |
|
44 Constructor. |
|
45 */ |
|
46 |
|
47 WlanQtUtils::WlanQtUtils() : |
|
48 d_ptr(new WlanQtUtilsPrivate(this)) |
|
49 { |
|
50 } |
|
51 |
|
52 /*! |
|
53 Destructor. |
|
54 */ |
|
55 |
|
56 WlanQtUtils::~WlanQtUtils() |
|
57 { |
|
58 } |
|
59 |
|
60 /*! |
|
61 Function for requesting a single WLAN scan to be triggered. |
|
62 |
|
63 Signal wlanScanReady(int) is emitted when new scan results are available. |
|
64 |
|
65 NOTE: Requesting a new scan while there is an ongoing scan (for this |
|
66 WlanQtUtils instance) is not allowed. |
|
67 */ |
|
68 |
|
69 void WlanQtUtils::scanWlans() |
|
70 { |
|
71 d_ptr->scanWlans(); |
|
72 } |
|
73 |
|
74 /*! |
|
75 Function for requesting a WLAN AP scan to be triggered. |
|
76 |
|
77 Signal availableWlanAps() is emitted when new scan results are available. |
|
78 |
|
79 NOTE: Requesting a new scan while there is an ongoing scan (for this |
|
80 WlanQtUtils instance) is not allowed. |
|
81 */ |
|
82 |
|
83 void WlanQtUtils::scanWlanAps() |
|
84 { |
|
85 d_ptr->scanWlanAps(); |
|
86 } |
|
87 |
|
88 /*! |
|
89 Function for requesting a direct WLAN scan with given SSID. |
|
90 |
|
91 Signal wlanScanDirectReady(int) is emitted when new scan results are |
|
92 available. |
|
93 |
|
94 NOTE: Requesting a new scan while there is an ongoing scan (for this |
|
95 WlanQtUtils instance) is not allowed. |
|
96 |
|
97 @param [in] ssid Network name to be found |
|
98 */ |
|
99 |
|
100 void WlanQtUtils::scanWlanDirect(const QString &ssid) |
|
101 { |
|
102 d_ptr->scanWlanDirect(ssid); |
|
103 } |
|
104 |
|
105 /*! |
|
106 Function for stopping a (possibly) ongoing WLAN scan. |
|
107 This function can also be called when there is no scan in progres. |
|
108 If a scan is actually cancelled, the corresponding scan result signal |
|
109 is sent with ScanStatusCancelled status. |
|
110 */ |
|
111 |
|
112 void WlanQtUtils::stopWlanScan() |
|
113 { |
|
114 d_ptr->stopWlanScan(); |
|
115 } |
|
116 |
|
117 /*! |
|
118 Function to request details of available WLAN networks. Can be called |
|
119 at any time. Calling right after wlanScanReady(int) signal ensures you get |
|
120 the most recent results. |
|
121 |
|
122 @param [out] wlanIapList List of available WLAN IAPs. |
|
123 @param [out] wlanApList List of unknown WLAN APs. |
|
124 */ |
|
125 |
|
126 void WlanQtUtils::availableWlans( |
|
127 QList< QSharedPointer<WlanQtUtilsIap> > &wlanIapList, |
|
128 QList< QSharedPointer<WlanQtUtilsAp> > &wlanApList) const |
|
129 { |
|
130 d_ptr->availableWlans(wlanIapList, wlanApList); |
|
131 } |
|
132 |
|
133 /*! |
|
134 Function to request details of available WLAN networks. This function is |
|
135 used to get the results that are informed by following signals: |
|
136 -wlanScanApReady(int) |
|
137 -wlanScanDirectReady(int) |
|
138 |
|
139 @param [out] wlanApList List of unknown WLAN APs. |
|
140 */ |
|
141 |
|
142 void WlanQtUtils::availableWlanAps( |
|
143 QList< QSharedPointer<WlanQtUtilsAp> > &wlanApList) const |
|
144 { |
|
145 d_ptr->availableWlanAps(wlanApList); |
|
146 } |
|
147 |
|
148 /*! |
|
149 Function to create an IAP from the given WLAN access point. |
|
150 |
|
151 @param [in] wlanAp Access point containing parameters to include in the new IAP. |
|
152 |
|
153 @return IAP ID if creation succeeds, IapIdNone otherwise. |
|
154 */ |
|
155 |
|
156 int WlanQtUtils::createIap(const WlanQtUtilsAp *wlanAp) |
|
157 { |
|
158 return d_ptr->createIap(wlanAp); |
|
159 } |
|
160 |
|
161 /*! |
|
162 Function to update an IAP from the given WLAN access point. |
|
163 |
|
164 @param [in] iapId ID of the IAP to be updated. |
|
165 @param [in] wlanAp Access point containing parameters to update in the IAP. |
|
166 |
|
167 @return Was update successful? |
|
168 */ |
|
169 |
|
170 bool WlanQtUtils::updateIap(int iapId, const WlanQtUtilsAp *wlanAp) |
|
171 { |
|
172 return d_ptr->updateIap(iapId, wlanAp); |
|
173 } |
|
174 |
|
175 /*! |
|
176 Function to delete an IAP. |
|
177 |
|
178 @param [in] iapId ID of the IAP to be deleted. |
|
179 */ |
|
180 |
|
181 void WlanQtUtils::deleteIap(int iapId) |
|
182 { |
|
183 d_ptr->deleteIap(iapId); |
|
184 } |
|
185 |
|
186 /*! |
|
187 Function to start connection creation for the given IAP. Runs also |
|
188 Internet Connectivity Test (ICT), if requested with the optional |
|
189 parameter. |
|
190 |
|
191 Connecting while there is already a connection is also supported. |
|
192 |
|
193 wlanNetworkOpened() or wlanNetworkClosed() signal will be emitted |
|
194 when connection status changes. |
|
195 |
|
196 ictResult() signal will be emitted when (possible) ICT result is |
|
197 available. |
|
198 |
|
199 @param [in] iapId ID of the IAP to be connected. |
|
200 @param [in] runIct Should ICT be run or not? |
|
201 */ |
|
202 |
|
203 void WlanQtUtils::connectIap(int iapId, bool runIct) |
|
204 { |
|
205 d_ptr->connectIap(iapId, runIct); |
|
206 } |
|
207 |
|
208 /*! |
|
209 Function to disconnect the given IAP. |
|
210 Disconnecting when there is no connection is also supported. |
|
211 |
|
212 @param [in] iapId ID of the IAP to be disconnected. |
|
213 */ |
|
214 |
|
215 void WlanQtUtils::disconnectIap(int iapId) |
|
216 { |
|
217 d_ptr->disconnectIap(iapId); |
|
218 } |
|
219 |
|
220 /*! |
|
221 Function to retrieve the name of the IAP with the given ID. |
|
222 |
|
223 @param [in] iapId ID of the requested IAP. |
|
224 |
|
225 @return Name of the IAP or empty QString if IAP is not found. |
|
226 */ |
|
227 |
|
228 QString WlanQtUtils::iapName(int iapId) const |
|
229 { |
|
230 return d_ptr->iapName(iapId); |
|
231 } |
|
232 |
|
233 /*! |
|
234 Connection status getter. |
|
235 |
|
236 @return Current WLAN connection status. |
|
237 */ |
|
238 |
|
239 WlanQtUtils::ConnStatus WlanQtUtils::connectionStatus() const |
|
240 { |
|
241 return d_ptr->connectionStatus(); |
|
242 } |
|
243 |
|
244 /*! |
|
245 Function for getting the ID of the (possibly) active WLAN IAP. |
|
246 Active here means non-disconnected. |
|
247 Use connectionStatus() for retrieving the actual status. |
|
248 |
|
249 @return ID of the active IAP, IapIdNone if not valid. |
|
250 */ |
|
251 |
|
252 int WlanQtUtils::activeIap() const |
|
253 { |
|
254 return d_ptr->activeIap(); |
|
255 } |