Modified to return an exception(E_INVALID_STATE) when you try to connect to a speicif...
[framework/osp/net.git] / src / inc / FNetWifi_WifiUtility.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file    FNetWifi_WifiUtility.h
20  * @brief   This is the header file for the %_WifiUtility class.
21  *
22  * This header file contains the declarations of the %_WifiUtility class.
23  */
24
25 #ifndef _FNET_WIFI_INTERNAL_WIFI_UTILITY_H_
26 #define _FNET_WIFI_INTERNAL_WIFI_UTILITY_H_
27
28 #include <FOspConfig.h>
29 #include <wifi.h>
30 #include <FNetWifiWifiTypes.h>
31
32 namespace Tizen { namespace Base
33 {
34
35 class String;
36
37 } } // Tizen::Base
38
39
40 namespace Tizen { namespace Net
41 {
42 class IpAddress;
43 } } // Tizen::Net
44
45 namespace Tizen { namespace Net { namespace Wifi
46 {
47 class WifiBssInfo;
48
49 struct _CharDeleter
50 {
51         void operator ()(char* pChar)
52         {
53                 free(pChar);
54         }
55 };
56
57 /**
58  * The length of a security key value with Wired Equivalent Privacy (WEP-64Bit)
59  */
60 static const int WIFI_WEP_64BIT_KEY_LENGTH = 10;
61
62 /**
63  * The length of a security key value with Wired Equivalent Privacy (WEP-128Bit)
64  */
65 static const int WIFI_WEP_128BIT_KEY_LENGTH = 26;
66
67 /**
68  * The length of a security key value with Advanced Encryption Standard (AES)
69  */
70 static const int WIFI_AES_KEY_LENGTH = 64;
71 /**
72  * The length of a security key value with Temporal Key Integrity Protocol (TKIP)
73  */
74 static const int WIFI_TKIP_KEY_LENGTH = WIFI_AES_KEY_LENGTH;
75 /**
76  * The length of the user and password values of Extensible Authentication Protocol method (EAP)
77  */
78 static const int WIFI_EAP_KEY_LENGTH = 256;
79
80 class _OSP_EXPORT_ _WifiUtility
81 {
82 public:
83         /**
84          * Converts wlan_security_mode_type_t to WifiAuthentication Type
85          *
86          * @return       WifiAuthenticationType
87          * @param[in]   securityMode        Security Mode
88          * @param[in]   encType             Encryption Type
89          */
90         static WifiAuthenticationType ConvertAuthType(wifi_security_type_e securityMode, wifi_encryption_type_e encType);
91
92         /**
93         * Converts WifiAuthenticationType to wifi_security_type_e
94         *
95         * @return       wifi_security_type_e
96         * @param[in]   authMode             Authentication Mode
97         */
98
99         static wifi_security_type_e ConvertSecurityType(WifiAuthenticationType authMode);
100         /**
101          * Converts frequency to RadioChannel.
102          *
103          * @return       WifiRadioChannel
104          * @param[in]    frequency          radio frequency value
105          */
106         static WifiRadioChannel ConvertRadioChannel(int frequency);
107
108         /**
109          * Converts Rssi value from level
110          *
111          * @return       long
112          * @param[in]    val                rssi value
113          */
114         static long ConvertLeveltoRssiValue(wifi_rssi_level_e val);
115
116         /**
117          * Converts Rssi value from percentage
118          *
119          * @return       long
120          * @param[in]    val                Rssi percentage value
121          */
122         static long ConvertPercentagetoRssiValue(char val);
123
124
125         /**
126          * Converts Encryption Type
127          *
128          * @return       WifiEncryptionType
129          * @param[in]    encType            Encryption Type
130          */
131         static WifiEncryptionType ConvertEncryptionType(wifi_encryption_type_e encType);
132
133         /**
134          * Converts Encryption Type
135          *
136          * @return       wifi_encryption_type_e
137          * @param[in]    encryptionMode     Encryption Type
138          */
139         static wifi_encryption_type_e ConvertEncryptionType(WifiEncryptionType encryptionMode);
140
141         /**
142          * Converts EAP Type
143          *
144          * @return       WifiEapType
145          * @param[in]    eapType            EAP Type
146          * @param[in]    eapAuthType        EAP authentication type
147          */
148         static WifiEapType ConvertEapType(wifi_eap_type_e eapType, wifi_eap_auth_type_e eapAuthType);
149
150         /**
151          * Converts EAP Type
152          *
153          * @return       wlan_eap_type_t
154          * @param[in]    eapType            EAP Type
155          */
156         static wifi_eap_type_e ConvertEapType(WifiEapType eapType);
157
158         /**
159          * Converts EAP Authentication Type
160          *
161          * @return       wlan_eap_auth_type_t
162          * @param[in]    eapType            EAP authentication type
163          */
164         static wifi_eap_auth_type_e ConvertEapAuthType(WifiEapType eapype);
165
166         /**
167          * Converts Mac Address
168          *
169          * @return       String
170          * @param[in]    macAddress         mac address
171          */
172         static Tizen::Base::String ConvertMacAddress(char macAddress[]);
173
174         /**
175          * Gets BSS ID from handle of access point
176          *
177          * @return       String
178          * @param[in]    pApHandle          A handle of access point
179          *
180          */
181         static Tizen::Base::String GetBssIdFromApHandle(wifi_ap_h pApHandle);
182
183         /**
184          * Converts profile info to bssinfo
185          *
186          * @return       WifiBssInfo        bss information
187          * @param[in]    pApHandle          A handle of access point
188          */
189         static WifiBssInfo* CreateWifiBssInfoInstanceN(wifi_ap_h& pApHandle);
190
191         /**
192          * Releases memory for wifi aphandler and sets it to null
193          *
194          * @param[in]    pDestHandle        The destination handle of access point
195          * @param[in]    pSrcHandle         The source handle of access point
196          */
197         static void WifiApClone(void*& pDestHandle, void* pSrcHandle);
198
199         /**
200          * Clones access point handler
201          *
202          * @param[in]    apHandler          A handle of access point
203          */
204         static void WifiApDestory(void*& pApHandler);
205
206         /**
207          * Checks whether the values of the two %IpAddress objects are equal.
208          */
209         static bool CheckAddressEquality(Tizen::Net::IpAddress* pFirstAddress, Tizen::Net::IpAddress* pSecondAddress);
210
211         /**
212          * Gets the copy of list of WifiBssInfo.
213          */
214         static Tizen::Base::Collection::IList* GetWifiBssInfoListCloneN(const Tizen::Base::Collection::IList* pSrcList);
215
216 private:
217         /**
218          * This default constructor is intentionally declared as private because this class cannot be constructed.
219          *
220          */
221         _WifiUtility(void);
222
223         /**
224          * This destructor is intentionally declared as private because this class cannot be constructed.
225          *
226          */
227         virtual ~_WifiUtility(void);
228
229 private:
230         /**
231          * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
232          *
233          * @since 2.1
234          *
235          * @param[in] rhs   An instance of %_WifiUtility
236          */
237         _WifiUtility(const _WifiUtility& rhs);
238
239         /**
240          * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
241          *
242          * @param[in] rhs An instance of %_WifiUtility
243          */
244         _WifiUtility& operator =(const _WifiUtility& rhs);
245
246 }; // _WifiUtility
247
248 } } }  // Tizen::Net::Wifi
249 #endif // _FNET_WIFI_INTERNAL_WIFI_UTILITY_H_