2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FNetWifiWifiManager.h
19 * @brief This is the header file for the %WifiManager class.
21 * This header file contains the declarations of the %WifiManager class.
23 #ifndef _FNET_WIFI_WIFI_MANAGER_H_
24 #define _FNET_WIFI_WIFI_MANAGER_H_
26 #include <FBaseTypes.h>
27 #include <FBaseResult.h>
28 #include <FNetWifiWifiTypes.h>
29 #include <FNetWifiIWifiManagerEventListener.h>
31 namespace Tizen { namespace Net { namespace Wifi
34 class _WifiManagerImpl;
35 class IWifiSystemMonitoringEventListener;
39 * @brief This class provides methods for the local Wi-Fi device management.
43 * The %WifiManager class provides methods for creating a %WifiManager instance, and managing the local Wi-Fi devices. It also allows the
44 * listener to get the events from the local Wi-Fi devices.
46 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/wi-fi_connectivity.htm">Wi-Fi Connectivity</a>.
48 * The following example demonstrates how to use the %WifiManager class.
52 * using namespace Tizen::Net::Wifi;
55 * MyClass::WifiManagerSample(void)
57 * WifiManager wifiMgr; // Creates an instance of WifiManager
58 * MyListenerClass wifiListener; // Creates a listener for WifiManager
61 * // Initializes wifiMgr using the Construct method
62 * r = wifiMgr.Construct(wifiListener);
68 * // Activates the local Wi-Fi device
69 * r = wifiMgr.Activate();
75 * // Checks the current connection status
76 * if (!wifiMgr.IsConnected())
78 * // Deactivates the local Wi-Fi device
79 * r = wifiMgr.Deactivate();
89 * // Do some exception handling.
97 class _OSP_EXPORT_ WifiManager
98 : public Tizen::Base::Object
102 * This is the default constructor for this class.
106 * @remarks After creating an instance of this class, the Construct() method must be called explicitly to initialize the instance.
112 * This destructor overrides Tizen::Base::Object::~Object().
116 virtual ~WifiManager(void);
119 * Initializes this instance of %WifiManager with the specified listener.
123 * @return An error code
124 * @param[in] listener A reference to the listener instance
125 * @exception E_SUCCESS The method is successful.
126 * @exception E_SYSTEM A system error has occurred.
127 * @exception E_OUT_OF_MEMORY The memory is insufficient.
128 * @exception E_UNSUPPORTED_OPERATION This operation is not supported.
129 * @remarks The @c listener instance must not be deleted before destructing this instance.
131 result Construct(IWifiManagerEventListener& listener);
134 * Activates the local Wi-Fi device.
138 * @privilege http://tizen.org/privilege/wifi.admin
140 * @return An error code
141 * @exception E_SUCCESS The activation is successful.
142 * @exception E_FAILURE The method has failed to activate.
143 * @exception E_IN_PROGRESS The activate process is in progress.
144 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n
145 * For example, the Wi-Fi is already activated.
146 * @exception E_SYSTEM A system error has occurred.
147 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
148 * @see IWifiManagerEventListener::OnWifiActivated()
150 result Activate(void) const;
153 * Deactivates the local Wi-Fi device.
157 * @privilege http://tizen.org/privilege/wifi.admin
159 * @return An error code
160 * @exception E_SUCCESS The deactivation is successful.
161 * @exception E_FAILURE The method has failed to deactivate.
162 * @exception E_IN_PROGRESS The deactivate process is in progress.
163 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n
164 * For example, the Wi-Fi is already deactivated.
165 * @exception E_SYSTEM A system error has occurred.
166 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
167 * @see IWifiManagerEventListener::OnWifiDeactivated()
169 result Deactivate(void) const;
172 * Gets the current power status of the local Wi-Fi device.
176 * @return The current power status of the local Wi-Fi device
178 WifiPowerStatus GetPowerStatus(void) const;
181 * Gets the MAC address of the Wi-Fi device.
185 * @return The MAC address in the form '00-00-00-00-00-00'
186 * @remarks This MAC address is different from the MAC address provided by the WifiDirectDevice class.
188 Tizen::Base::String GetMacAddress(void) const;
191 * Checks whether the local device is activated.
195 * @return @c true if the local device is activated, @n
198 bool IsActivated(void) const;
201 * Checks whether the local device is connected with a remote Access Point(AP).
205 * @return @c true if the local device is connected with a remote Access Point(AP), @n
208 bool IsConnected(void) const;
211 * Scans for a nearby BSS with both the infrastructure and independent modes.
215 * @privilege http://tizen.org/privilege/wifi.read
217 * @return An error code
218 * @exception E_SUCCESS The method is successful.
219 * @exception E_FAILURE The method has failed.
220 * @exception E_INVALID_STATE This instance is in an invalid state.
221 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
222 * @remarks Only active scan (probing for Access Points(APs) and ad hoc stations in the range) is supported.
223 * This operation does not work while the Wi-Fi Direct scanning or connection is in progress.
224 * @see IWifiManagerEventListener::OnWifiScanCompletedN()
229 * Connects to a specific access point that is a BSS with an infrastructure mode.
233 * @privilege http://tizen.org/privilege/wifi.admin
235 * @return An error code
236 * @param[in] targetApInfo A BSS information representing the target access point
237 * @exception E_SUCCESS The method is successful.
238 * @exception E_FAILURE The method has failed.
239 * @exception E_IN_PROGRESS The previous request is in progress.
240 * @exception E_INVALID_ARG The specified input parameter is invalid. @n
241 * For example, the BSS type is an independent mode.
242 * @exception E_INVALID_STATE This instance is in an invalid state.
243 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
244 * @remarks If a connection to another access point is already established, it will be disconnected and the new connection
245 * of this method will be established.
246 * @see IWifiManagerEventListener::OnWifiConnected()
248 result Connect(const WifiBssInfo& targetApInfo);
251 * Sets the behavior mode of the Wi-Fi background system about connection and background scanning.
254 * @privlevel platform
255 * @privilege http://tizen.org/privilege/wifimanager
257 * @return An error code
258 * @param[in] mode A Wi-Fi background system mode
259 * @exception E_SUCCESS The method is successful.
260 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
261 * @exception E_OPERATION_FAILED The operation has failed.
262 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
264 result SetWifiSystemScanMode(WifiSystemScanMode mode);
267 * Adds the specified listener for receiving the notification when the state of current Wi-Fi connection is changed
268 * or the result of Wi-Fi background scanning is updated
271 * @privlevel platform
272 * @privilege http://tizen.org/privilege/wifimanager
274 * @return An error code
275 * @param[in] listener The listener to add
276 * @exception E_SUCCESS The method is successful.
277 * @exception E_OBJ_ALREADY_EXIST The listener is already added.
278 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
279 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
281 result AddSystemMonitoringEventListener(IWifiSystemMonitoringEventListener& listener);
284 * Removes the specified IWifiSystemMonitoringEventListener instance for receiving the notification. The removed listener
285 * cannot listen to the events that are fired.
288 * @privlevel platform
289 * @privilege http://tizen.org/privilege/wifimanager
291 * @return An error code
292 * @param[in] listener The listener to remove
293 * @exception E_SUCCESS The method is successful.
294 * @exception E_OBJ_NOT_FOUND The listener is not found.
295 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
296 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
298 result RemoveSystemMonitoringEventListener(IWifiSystemMonitoringEventListener& listener);
301 * Gets the state of current Wi-Fi connection.
305 * @return The state of the current Wi-Fi connection
307 WifiConnectionState GetConnectionState(void) const;
310 * Gets the information of current Wi-Fi connection target which the local device is connecting or connected with.
314 * @return A pointer to the WifiBssInfo instance representing the information of current Wi-Fi connection target
315 * else @c null if GetConnectionState() is WIFI_CONN_STATE_NOT_CONNECTED
317 WifiBssInfo* GetConnectionTargetInfoN(void) const;
320 * Updates the Wi-Fi BSS information which is saved in the underlying Wi-Fi system.
323 * @privlevel platform
324 * @privilege http://tizen.org/privilege/wifimanager
326 * @return An error code
327 * @param[in] bssInfo A BSS information representing the access point
328 * @exception E_SUCCESS The method is successful.
329 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
330 * @exception E_OBJ_NOT_FOUND The specified input parameter is not found.
331 * @exception E_OPERATION_FAILED The operation has failed.
332 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
334 * @remarks The updated information is deleted when Wi-Fi is turned off if the BSS has never been connected before.
336 result UpdateBssInfo(const WifiBssInfo& bssInfo);
339 * Gets a list of the latest search results which the underlying Wi-Fi system scan periodically on background.
343 * @return An IList containing WifiBssInfo of existing Wi-Fi connections if successful, @n
346 Tizen::Base::Collection::IList* GetSystemScanResultN(void) const;
350 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
352 * @param[in] value An instance of %WifiManager
354 WifiManager(const WifiManager& value);
357 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
359 * @param[in] rhs An instance of %WifiManager
361 WifiManager& operator=(const WifiManager& rhs);
364 _WifiManagerImpl* __pWifiManagerImpl;
366 friend class _WifiManagerImpl;
369 } } } // Tizen::Net::Wifi
370 #endif // _FNET_WIFI_WIFI_MANAGER_H_