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 FNetWifi_WifiSystemAdapter.h
19 * @brief This is the header file for the _WifiSystemAdapter class.
22 * This header file contains declarations of the _WifiSystemAdapter class.
24 #ifndef _FNET_WIFI_INTERNAL_WIFI_SYSTEM_ADAPTER_H_
25 #define _FNET_WIFI_INTERNAL_WIFI_SYSTEM_ADAPTER_H_
27 #include <unique_ptr.h>
29 #include <FOspConfig.h>
30 #include <FBaseObject.h>
31 #include <FNetWifiWifiTypes.h>
33 namespace Tizen { namespace Net { namespace Wifi
37 class _WifiManagerImpl;
38 class _IWifiManagerEventListener;
40 class _OSP_EXPORT_ _WifiSystemAdapter :
41 public Tizen::Base::Object
46 * Register an instance of _IWifiManagerEventListener interface.
48 * @return An error code
49 * @param[in] listener The instance of _IWifiManagerEventListener to be registered
50 * @param[in] isHighPriority Set to @c true to register with the high priority, @n
52 * @exception E_SUCCESS The method is successful.
53 * @exception E_OUT_OF_MEMORY The memory is insufficient.
55 result RegisterManagerEventListener(_IWifiManagerEventListener& listener);
58 * Unregister an instance of _IBluetoothManagerEventListener interface.
60 * @return An error code
61 * @param[in] listener The instance of _IWifiManagerEventListener to be unregistered
62 * @exception E_SUCCESS The method is successful.
63 * @exception E_OBJ_NOT_FOUND The input instance is not registered.
65 result UnregisterManagerEventListener(_IWifiManagerEventListener& listener);
68 * Activates the local Wifi device.
70 * @return An error code
71 * @exception E_SUCCESS The activation was successful.
72 * @exception E_FAILURE Failed to activate.
73 * @exception E_SYSTEM A system error occurred.
75 result Activate(void);
78 * Deactivates the local Wifi device.
80 * @return An error code
81 * @exception E_SUCCESS The deactivation was successful.
82 * @exception E_FAILURE Failed to deactivate.
83 * @exception E_SYSTEM A system error occurred.
85 result Deactivate(void);
88 * Gets the MAC address of the Wifi device.
89 * @return The MAC address in the form '00-00-00-00-00-00'
91 Tizen::Base::String GetMacAddress(void) const;
94 * Checks whether the local device is activated.
95 * @return @c true, if the local device is activated @n
98 bool IsActivated(void) const;
101 * Checks whether the local device is connected with a remote STA.
102 * @return @c true, if the local device is connected with a remote STA @n
103 * @c false, otherwise
105 bool IsConnected(void) const;
108 * Checks whether the local device is already connected with a specific remote STA.
110 * @return @c true, if the local device is already connected with a specific remote STA @n
111 * @c false, otherwise
112 * @param[in] pApHandle a handle of access point
115 bool IsConnected(wifi_ap_h pApHandle) const;
118 * Requests a scan for nearby BSS with both infrastructure and independent mode.
120 * @return An error code
121 * @exception E_SUCCESS The method was successful.
122 * @exception E_FAILURE The method failed.
123 * @remarks Only active scan - i.e. probing for APs in the range - is supported.
124 * @see IWifiManagerEventListener::OnWifiScanCompleted()
129 * Establishes a connection to a specific access point - only BSS with infrastructure mode.
131 * @return An error code
132 * @param[in] targetApInfo A BSS information that represents target access point.
133 * @exception E_SUCCESS The method was successful.
134 * @exception E_FAILURE The method failed.
135 * @exception E_INVALID_ARG A specified input parameter is invalid. E.g. BSS type is independent mode.
136 * @remarks If a connection to other access point is already established, it will be disconnected and the new connection
137 * of this method will be established.
138 * @see IWifiManagerEventListener::OnWifiConnected()
140 result Connect(const WifiBssInfo& targetApInfo);
143 * Gets the state of current Wi-Fi connection.
145 * @return The state of the current Wi-Fi connection
147 WifiConnectionState GetConnectionState(void) const;
150 * Gets the information of current Wi-Fi connection target which the local device is connecting or connected with.
152 * @return A pointer to the WifiBssInfo instance representing the information of current Wi-Fi connection target
153 * else @c null if GetConnectionState() is WIFI_CONNECTION_STATE_NOT_CONNECTED
155 WifiBssInfo* GetConnectionTargetInfoN(void) const;
158 * Gets a list of the latest search results which the underlying Wi-Fi system scan periodically on background.
160 * @return An IList containing WifiBssInfo of existing Wi-Fi connections if successful, @n
163 Tizen::Base::Collection::IList* GetSystemScanResultN(void) const;
166 * Called when the device state is changed.
168 * @param[in] state Device status
169 * @param[in] pUserData The user data passed from the callback registration function
171 static void OnWifiDeviceStateChanged(wifi_device_state_e state, void* pUserData);
174 * Called when the connection state is changed.
176 * @param[in] state Connection status
177 * @param[in] pApHandle A handle of access point
178 * @param[in] pUserData The user data passed from the callback registration function
180 static void OnWifiConnectionStateChanged(wifi_connection_state_e state, wifi_ap_h pApHandle, void* pUserData);
183 * Called when each access point is found.
185 * @param[in] pApHandle A handle of access point
186 * @param[in] pUserData The user data passed from the callback registration function
188 static bool OnWifiEachAccessPointFound(wifi_ap_h pApHandle, void* pUserData);
191 * Called when each access point is checked.
193 * @param[in] pApHandle A handle of access point
194 * @param[in] pUserData The user data passed from the callback registration function
196 static bool OnWifiEachAccessPointChecked(wifi_ap_h pApHandle, void* pUserData);
199 * Called when Wifi is activated.
201 * @param[in] errorCode Error code
202 * @param[in] pUserData The user data passed from the callback registration function
204 static void OnWifiActivated(wifi_error_e errorCode, void* pUserData);
207 * Called when Wifi is dectivated.
209 * @param[in] errorCode Error code
210 * @param[in] pUserData The user data passed from the callback registration function
212 static void OnWifiDeactivated(wifi_error_e errorCode, void* pUserData);
215 * Called when the local device is connected with Wifi access point.
217 * @param[in] errorCode Error code
218 * @param[in] pUserData The user data passed from the callback registration function
220 static void OnWifiConnected(wifi_error_e errorCode, void* pUserData);
223 * Called when the scan process is completed.
225 * @param[in] errorCode Error code
226 * @param[in] pUserData The user data passed from the callback registration function
228 static void OnWifiScanCompleted(wifi_error_e errorCode, void* pUserData);
231 * Called when the rssi value is changed.
233 * @param[in] rssiLevel Rssi level
234 * @param[in] pUserData The user data passed from the callback registration function
236 static void OnWifiRssiLevelChanged(wifi_rssi_level_e rssiLevel, void* pUserData);
239 * Called when the background scan result is updated.
241 * @param[in] errorCode Error code
242 * @param[in] pUserData The user data passed from the callback registration function
244 static void OnWifiBackgroundScanResultUpdated(wifi_error_e errorCode, void* pUserData);
247 * Get the singleton insatnce of _WifiSystemAdapter.
249 * @return The pointer to _WifiSystemAdapter
251 static _WifiSystemAdapter* GetInstance(void);
255 * This default constructor is intentionally declared as private to implement the Singleton semantic.
257 * @remarks After creating an instance of this class, you must explicitly call
258 * the construction method to initialize the instance.
261 _WifiSystemAdapter(void);
264 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
266 * @param[in] rhs An instance of %_WifiSystemAdapter
268 _WifiSystemAdapter(const _WifiSystemAdapter& rhs);
271 * This destructor is intentionally declared as private to implement the Singleton semantic.
274 virtual ~_WifiSystemAdapter(void);
277 * Initializes the _WifiSystemAdapter instance and adds the listener instance.
279 * @return An error code
280 * @exception E_SUCCESS The initialization was successful.
281 * @exception E_SYSTEM A system error occurred.
286 * Initializes the _WifiSystemAdapter singletone instance.
288 * @exception E_SUCCESS The initialization was successful.
289 * @exception E_SYSTEM A system error occurred.
290 * @exception E_OUT_OF_MEMORY The memory is insufficient.
292 static void InitSingleton(void);
295 * Destorys instance of singleton class.
298 static void DestroySingleton(void);
301 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
303 * @param[in] rhs An instance of %_WifiSystemAdapter
305 _WifiSystemAdapter& operator=(const _WifiSystemAdapter& rhs);
308 Tizen::Base::Collection::LinkedListT<_IWifiManagerEventListener*> __mgrEvtListenerList;
309 WifiBssInfo* __pBssInfo;
311 friend class std::default_delete<_WifiSystemAdapter>;
313 }; // _WifiSystemAdapter
315 } } } // Tizen::Net::Wifi
317 #endif // _FNET_WIFI_INTERNAL_WIFI_SYSTEM_ADAPTER_H_