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 * @feature %http://tizen.org/feature/network.wifi
125 * @return An error code
126 * @param[in] listener A reference to the listener instance
127 * @exception E_SUCCESS The method is successful.
128 * @exception E_SYSTEM A system error has occurred.
129 * @exception E_OUT_OF_MEMORY The memory is insufficient.
130 * @exception E_UNSUPPORTED_OPERATION The device does not support the Wi-Fi feature.
131 * For more information, see <a href=”../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm”>Application Filtering</a>.
133 * - The @c listener instance must not be deleted before destructing this instance.
134 * - Before calling this method, check whether the feature is supported by %Tizen::System::SystemInfo::GetValue() methods.
136 result Construct(IWifiManagerEventListener& listener);
139 * Activates the local Wi-Fi device.
143 * @privilege %http://tizen.org/privilege/wifi.admin
145 * @return An error code
146 * @exception E_SUCCESS The activation is successful.
147 * @exception E_FAILURE The method has failed to activate.
148 * @exception E_IN_PROGRESS The activate process is in progress.
149 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n
150 * For example, the Wi-Fi is already activated.
151 * @exception E_SYSTEM A system error has occurred.
152 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
153 * @see IWifiManagerEventListener::OnWifiActivated()
155 result Activate(void) const;
158 * Deactivates the local Wi-Fi device.
162 * @privilege %http://tizen.org/privilege/wifi.admin
164 * @return An error code
165 * @exception E_SUCCESS The deactivation is successful.
166 * @exception E_FAILURE The method has failed to deactivate.
167 * @exception E_IN_PROGRESS The deactivate process is in progress.
168 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n
169 * For example, the Wi-Fi is already deactivated.
170 * @exception E_SYSTEM A system error has occurred.
171 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
172 * @see IWifiManagerEventListener::OnWifiDeactivated()
174 result Deactivate(void) const;
177 * Gets the current power status of the local Wi-Fi device.
181 * @return The current power status of the local Wi-Fi device
183 WifiPowerStatus GetPowerStatus(void) const;
186 * Gets the MAC address of the Wi-Fi device.
190 * @return The MAC address in the form '00-00-00-00-00-00'
191 * @remarks This MAC address is different from the MAC address provided by the WifiDirectDevice class.
193 Tizen::Base::String GetMacAddress(void) const;
196 * Checks whether the local device is activated.
200 * @return @c true if the local device is activated, @n
203 bool IsActivated(void) const;
206 * Checks whether the local device is connected with a remote Access Point(AP).
210 * @return @c true if the local device is connected with a remote Access Point(AP), @n
213 bool IsConnected(void) const;
216 * Scans for a nearby BSS with both the infrastructure and independent modes.
220 * @privilege %http://tizen.org/privilege/wifi.read
222 * @return An error code
223 * @exception E_SUCCESS The method is successful.
224 * @exception E_FAILURE The method has failed.
225 * @exception E_INVALID_STATE This instance is in an invalid state.
226 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
227 * @remarks Only active scan (probing for Access Points(APs) and ad hoc stations in the range) is supported.
228 * This operation does not work while the Wi-Fi Direct scanning or connection is in progress.
229 * @see IWifiManagerEventListener::OnWifiScanCompletedN()
234 * Connects to a specific access point that is a BSS with an infrastructure mode.
238 * @privilege %http://tizen.org/privilege/wifi.admin
240 * @return An error code
241 * @param[in] targetApInfo A BSS information representing the target access point
242 * @exception E_SUCCESS The method is successful.
243 * @exception E_FAILURE The method has failed.
244 * @exception E_IN_PROGRESS The previous request is in progress.
245 * @exception E_INVALID_ARG The specified input parameter is invalid. @n
246 * For example, the BSS type is an independent mode.
247 * @exception E_INVALID_STATE This instance is in an invalid state.
248 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
249 * @remarks If a connection to another access point is already established, it will be disconnected and the new connection
250 * of this method will be established.
251 * @see IWifiManagerEventListener::OnWifiConnected()
253 result Connect(const WifiBssInfo& targetApInfo);
256 * Sets the behavior mode of the Wi-Fi background system about connection and background scanning.
259 * @privlevel platform
260 * @privilege %http://tizen.org/privilege/wifimanager
262 * @return An error code
263 * @param[in] mode A Wi-Fi background system mode
264 * @exception E_SUCCESS The method is successful.
265 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
266 * @exception E_OPERATION_FAILED The operation has failed.
267 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
269 result SetWifiSystemScanMode(WifiSystemScanMode mode);
272 * Adds the specified @c listener for receiving the notification when the state of current Wi-Fi connection is changed
273 * or the result of Wi-Fi background scanning is updated.
276 * @privlevel platform
277 * @privilege %http://tizen.org/privilege/wifimanager
279 * @return An error code
280 * @param[in] listener The listener to add
281 * @exception E_SUCCESS The method is successful.
282 * @exception E_OBJ_ALREADY_EXIST The listener is already added.
283 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
284 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
286 result AddSystemMonitoringEventListener(IWifiSystemMonitoringEventListener& listener);
289 * Removes the specified IWifiSystemMonitoringEventListener instance for receiving the notification. @n The removed listener
290 * cannot listen to the events that are fired.
293 * @privlevel platform
294 * @privilege %http://tizen.org/privilege/wifimanager
296 * @return An error code
297 * @param[in] listener The listener to remove
298 * @exception E_SUCCESS The method is successful.
299 * @exception E_OBJ_NOT_FOUND The listener is not found.
300 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
301 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
303 result RemoveSystemMonitoringEventListener(IWifiSystemMonitoringEventListener& listener);
306 * Gets the state of current Wi-Fi connection.
310 * @return The state of the current Wi-Fi connection
312 WifiConnectionState GetConnectionState(void) const;
315 * Gets the information of current Wi-Fi connection target which the local device is connecting or connected with.
319 * @return A pointer to the WifiBssInfo instance representing the information of current Wi-Fi connection target, @n
320 * else @c null if GetConnectionState() is ::WIFI_CONN_STATE_NOT_CONNECTED
322 WifiBssInfo* GetConnectionTargetInfoN(void) const;
325 * Updates the Wi-Fi BSS information which is saved in the underlying Wi-Fi system.
328 * @privlevel platform
329 * @privilege %http://tizen.org/privilege/wifimanager
331 * @return An error code
332 * @param[in] bssInfo A BSS information representing the access point
333 * @exception E_SUCCESS The method is successful.
334 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
335 * @exception E_OBJ_NOT_FOUND The specified input parameter is not found.
336 * @exception E_OPERATION_FAILED The operation has failed.
337 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
339 * @remarks The updated information is deleted when Wi-Fi is turned off if the BSS has never been connected before.
341 result UpdateBssInfo(const WifiBssInfo& bssInfo);
344 * Gets a list of the latest search results which the underlying Wi-Fi system scan periodically on background.
348 * @return A Tizen::Base::Collection::IList containing WifiBssInfo of existing Wi-Fi connections if successful, @n
351 Tizen::Base::Collection::IList* GetSystemScanResultN(void) const;
355 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
357 * @param[in] value An instance of %WifiManager
359 WifiManager(const WifiManager& value);
362 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
364 * @param[in] rhs An instance of %WifiManager
366 WifiManager& operator=(const WifiManager& rhs);
369 _WifiManagerImpl* __pWifiManagerImpl;
371 friend class _WifiManagerImpl;
374 } } } // Tizen::Net::Wifi
375 #endif // _FNET_WIFI_WIFI_MANAGER_H_