Revert before adding new apis
[platform/core/csapi/tizenfx.git] / src / Tizen.Network.WiFi / Tizen.Network.WiFi / WiFiManager.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18 using System.Collections.Generic;
19 using System.Threading.Tasks;
20
21 namespace Tizen.Network.WiFi
22 {
23     /// <summary>
24     /// A manager class which allows applications to connect to a Wireless Local Area Network (WLAN) and to transfer data over the network.<br>
25     /// The Wi-Fi Manager enables your application to activate and deactivate a local Wi-Fi device, and to connect to a WLAN network in the infrastructure mode.
26     /// </summary>
27     static public class WiFiManager
28     {
29         /// <summary>
30         /// The local MAC address.
31         /// </summary>
32         static public string MacAddress
33         {
34             get
35             {
36                 return WiFiManagerImpl.Instance.MacAddress;
37             }
38         }
39
40         /// <summary>
41         /// The name of the network interface.
42         /// </summary>
43         static public string InterfaceName
44         {
45             get
46             {
47                 return WiFiManagerImpl.Instance.InterfaceName;
48             }
49         }
50
51         /// <summary>
52         /// The network connection state.
53         /// </summary>
54         static public WiFiConnectionState ConnectionState
55         {
56             get
57             {
58                 return WiFiManagerImpl.Instance.ConnectionState;
59             }
60         }
61
62         /// <summary>
63         /// A property to Check whether Wi-Fi is activated.
64         /// </summary>
65         static public bool IsActive
66         {
67             get
68             {
69                 return WiFiManagerImpl.Instance.IsActive;
70             }
71         }
72
73         /// <summary>
74         /// DeviceStateChanged is raised when the device state is changed.
75         /// </summary>
76         static public event EventHandler<DeviceStateChangedEventArgs> DeviceStateChanged
77         {
78             add
79             {
80                 WiFiManagerImpl.Instance.DeviceStateChanged += value;
81             }
82             remove
83             {
84                 WiFiManagerImpl.Instance.DeviceStateChanged -= value;
85             }
86         }
87
88         /// <summary>
89         /// ConnectionStateChanged is raised when the connection state is changed.
90         /// </summary>
91         static public event EventHandler<ConnectionStateChangedEventArgs> ConnectionStateChanged
92         {
93             add
94             {
95                 WiFiManagerImpl.Instance.ConnectionStateChanged += value;
96             }
97             remove
98             {
99                 WiFiManagerImpl.Instance.ConnectionStateChanged -= value;
100             }
101         }
102
103         /// <summary>
104         /// RssiLevelChanged is raised when the RSSI of connected Wi-Fi is changed.
105         /// </summary>
106         static public event EventHandler<RssiLevelChangedEventArgs> RssiLevelChanged
107         {
108             add
109             {
110                 WiFiManagerImpl.Instance.RssiLevelChanged += value;
111             }
112             remove
113             {
114                 WiFiManagerImpl.Instance.RssiLevelChanged -= value;
115             }
116         }
117
118         /// <summary>
119         /// BackgroundScanFinished is raised when the background scan is finished.
120         /// The background scan starts automatically when wifi is activated. The callback will be invoked periodically.
121         /// </summary>
122         static public event EventHandler BackgroundScanFinished
123         {
124             add
125             {
126                 WiFiManagerImpl.Instance.BackgroundScanFinished += value;
127             }
128             remove
129             {
130                 WiFiManagerImpl.Instance.BackgroundScanFinished -= value;
131             }
132         }
133
134         /// <summary>
135         /// Gets the result of the scan.
136         /// </summary>
137         /// <returns> A list of WiFiAP objects.</returns>
138         static public IEnumerable<WiFiAP> GetFoundAPs()
139         {
140             return WiFiManagerImpl.Instance.GetFoundAPs();
141         }
142
143         /// <summary>
144         /// Gets the result of specific AP scan.
145         /// </summary>
146         /// <returns> A list contains the WiFiAP objects.</returns>
147         static public IEnumerable<WiFiAP> GetFoundSpecificAPs()
148         {
149             return WiFiManagerImpl.Instance.GetFoundSpecificAPs();
150         }
151
152         /// <summary>
153         /// Gets the list of wifi configurations.
154         /// </summary>
155         /// <returns>A list contains the WiFiConfiguration objects.</returns>
156         static public IEnumerable<WiFiConfiguration> GetWiFiConfigurations()
157         {
158             return WiFiManagerImpl.Instance.GetWiFiConfigurations();
159         }
160
161         /// <summary>
162         /// Saves Wi-Fi configuration of access point.
163         /// </summary>
164         /// <param name="configuration">The configuration to be stored</param>
165         static public void SaveWiFiConfiguration(WiFiConfiguration configuration)
166         {
167             WiFiManagerImpl.Instance.SaveWiFiNetworkConfiguration(configuration);
168         }
169
170         /// <summary>
171         /// Gets the object of the connected WiFiAP.
172         /// </summary>
173         /// <returns> The connected wifi access point(AP) information.</returns>
174         static public WiFiAP GetConnectedAP()
175         {
176             return WiFiManagerImpl.Instance.GetConnectedAP();
177         }
178
179         /// <summary>
180         /// Activates Wi-Fi asynchronously.
181         /// </summary>
182         /// <returns> A task indicating whether the Activate method is done or not.</returns>
183         static public Task ActivateAsync()
184         {
185             return WiFiManagerImpl.Instance.ActivateAsync();
186         }
187
188         /// <summary>
189         /// Activates Wi-Fi asynchronously and displays Wi-Fi picker (popup) when Wi-Fi is not automatically connected.
190         /// </summary>
191         /// <returns> A task indicating whether the ActivateWithPicker method is done or not.</returns>
192         static public Task ActivateWithPickerAsync()
193         {
194             return WiFiManagerImpl.Instance.ActivateWithWiFiPickerTestedAsync();
195         }
196
197         /// <summary>
198         /// Deactivates Wi-Fi asynchronously.
199         /// </summary>
200         /// <returns> A task indicating whether the Deactivate method is done or not.</returns>
201         static public Task DeactivateAsync()
202         {
203             return WiFiManagerImpl.Instance.DeactivateAsync();
204         }
205
206         /// <summary>
207         /// Starts scan asynchronously.
208         /// </summary>
209         /// <returns> A task indicating whether the Scan method is done or not.</returns>
210         static public Task ScanAsync()
211         {
212             return WiFiManagerImpl.Instance.ScanAsync();
213         }
214
215         /// <summary>
216         /// Starts specific access point scan, asynchronously.
217         /// </summary>
218         /// <returns> A task indicating whether the ScanSpecificAP method is done or not.</returns>
219         /// <param name="essid">The essid of hidden ap</param>
220         static public Task ScanSpecificAPAsync(string essid)
221         {
222             return WiFiManagerImpl.Instance.ScanSpecificAPAsync(essid);
223         }
224     }
225 }