Binding KeyboardGrab and KeyboardUnGrab
[platform/core/csapi/tizenfx.git] / src / Tizen.Network.Connection / Tizen.Network.Connection / ConnectionProfileManager.cs
1 /*
2  * Copyright (c) 2018 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.Linq;
20 using System.Text;
21 using System.Threading.Tasks;
22 using System.Collections;
23
24 namespace Tizen.Network.Connection
25 {
26     /// <summary>
27     /// This is the ConnectionProfileManager class. It provides functions to add, get, connect, or modify the connection profile.
28     /// </summary>
29     /// <since_tizen> 3 </since_tizen>
30     public static class ConnectionProfileManager
31     {
32         /// <summary>
33         /// Adds a new profile.
34         /// </summary>
35         /// <since_tizen> 3 </since_tizen>
36         /// <param name="profile">The cellular profile object.</param>
37         /// <privilege>http://tizen.org/privilege/network.profile</privilege>
38         /// <privilege>http://tizen.org/privilege/network.get</privilege>
39         /// <feature>http://tizen.org/feature/network.telephony</feature>
40         /// <feature>http://tizen.org/feature/network.wifi</feature>
41         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
42         /// <feature>http://tizen.org/feature/network.ethernet</feature>
43         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
44         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
45         /// <exception cref="System.ArgumentException">Thrown when a value is an invalid parameter.</exception>
46         /// <exception cref="System.ArgumentNullException">Thrown when a value is null.</exception>
47         /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
48         /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when a method fails due to an invalid operation.</exception>
49         public static void AddCellularProfile(CellularProfile profile)
50         {
51             Log.Debug(Globals.LogTag, "AddCellularProfile");
52             ConnectionInternalManager.Instance.AddCellularProfile(profile);
53         }
54
55         /// <summary>
56         /// Gets the list of the profile with the profile list type.
57         /// </summary>
58         /// <since_tizen> 3 </since_tizen>
59         /// <param name="type">The type of profile.</param>
60         /// <returns>List of connection profile objects.</returns>
61         /// <privilege>http://tizen.org/privilege/network.get</privilege>
62         /// <feature>http://tizen.org/feature/network.telephony</feature>
63         /// <feature>http://tizen.org/feature/network.wifi</feature>
64         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
65         /// <feature>http://tizen.org/feature/network.ethernet</feature>
66         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
67         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
68         /// <exception cref="System.ArgumentException">Thrown when value is an invalid parameter.</exception>
69         /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
70         /// <exception cref="System.InvalidOperationException">Thrown when a connection instance has been disposed.</exception>
71         public static Task<IEnumerable<ConnectionProfile>> GetProfileListAsync(ProfileListType type)
72         {
73             Log.Debug(Globals.LogTag, "GetProfileListAsync");
74             return ConnectionInternalManager.Instance.GetProfileListAsync(type);
75         }
76
77         /// <summary>
78         /// Opens a connection of profile asynchronously.
79         /// </summary>
80         /// <since_tizen> 3 </since_tizen>
81         /// <param name="profile">The connection profile object.</param>
82         /// <returns>A task indicates whether the ConnectProfileAsync method is done successfully or not.</returns>
83         /// <remarks>
84         /// This method must be called from MainThread.
85         /// </remarks>
86         /// <privilege>http://tizen.org/privilege/network.get</privilege>
87         /// <privilege>http://tizen.org/privilege/network.set</privilege>
88         /// <feature>http://tizen.org/feature/network.telephony</feature>
89         /// <feature>http://tizen.org/feature/network.wifi</feature>
90         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
91         /// <feature>http://tizen.org/feature/network.ethernet</feature>
92         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
93         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
94         /// <exception cref="System.ArgumentException">Thrown when value is an invalid parameter.</exception>
95         /// <exception cref="System.ArgumentNullException">Thrown when a value is null.</exception>
96         /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
97         /// <exception cref="System.InvalidOperationException">Thrown when a connection or a profile instance is invalid or when a method fails due to an invalid operation.</exception>
98         public static Task ConnectProfileAsync(ConnectionProfile profile)
99         {
100             Log.Debug(Globals.LogTag, "ConnectProfile");
101             return ConnectionInternalManager.Instance.OpenProfileAsync(profile);
102         }
103
104         /// <summary>
105         /// Closes a connection of profile.
106         /// </summary>
107         /// <since_tizen> 3 </since_tizen>
108         /// <param name="profile">The connection profile object.</param>
109         /// <returns>A task indicates whether the DisconnectProfileAsync method is done successfully or not.</returns>
110         /// <remarks>
111         /// This method must be called from MainThread.
112         /// </remarks>
113         /// <privilege>http://tizen.org/privilege/network.get</privilege>
114         /// <privilege>http://tizen.org/privilege/network.set</privilege>
115         /// <feature>http://tizen.org/feature/network.telephony</feature>
116         /// <feature>http://tizen.org/feature/network.wifi</feature>
117         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
118         /// <feature>http://tizen.org/feature/network.ethernet</feature>
119         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
120         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
121         /// <exception cref="System.ArgumentException">Thrown when a value is an invalid parameter.</exception>
122         /// <exception cref="System.ArgumentNullException">Thrown when a value is null.</exception>
123         /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
124         /// <exception cref="System.InvalidOperationException">Thrown when a connection or a profile instance is invalid or when a method fails due to invalid operation.</exception>
125         public static Task DisconnectProfileAsync(ConnectionProfile profile)
126         {
127             Log.Debug(Globals.LogTag, "DisconnectProfileAsync");
128             return ConnectionInternalManager.Instance.CloseProfileAsync(profile);
129         }
130
131         /// <summary>
132         /// Removes an existing profile.
133         /// </summary>
134         /// <since_tizen> 3 </since_tizen>
135         /// <param name="profile">The connection profile object.</param>
136         /// <privilege>http://tizen.org/privilege/network.get</privilege>
137         /// <privilege>http://tizen.org/privilege/network.profile</privilege>
138         /// <feature>http://tizen.org/feature/network.telephony</feature>
139         /// <feature>http://tizen.org/feature/network.wifi</feature>
140         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
141         /// <feature>http://tizen.org/feature/network.ethernet</feature>
142         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
143         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
144         /// <exception cref="System.ArgumentException">Thrown when value is an invalid parameter.</exception>
145         /// <exception cref="System.ArgumentNullException">Thrown when a value is null.</exception>
146         /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
147         /// <exception cref="System.InvalidOperationException">Thrown when a connection or a profile instance is invalid or when a method fails due to invalid operation.</exception>
148         public static void RemoveProfile(ConnectionProfile profile)
149         {
150             Log.Debug(Globals.LogTag, "RemoveProfile. Id: " + profile.Id + ", Name: " + profile.Name + ", Type: " + profile.Type);
151             ConnectionInternalManager.Instance.RemoveProfile(profile);
152         }
153
154         /// <summary>
155         /// Updates an existing profile.
156         /// When a profile is changed, these changes will be not applied to the ConnectionProfileManager immediately.
157         /// When you call this function, your changes affect the ConnectionProfileManager and the existing profile is updated.
158         /// </summary>
159         /// <since_tizen> 3 </since_tizen>
160         /// <param name="profile">The connection profile object.</param>
161         /// <privilege>http://tizen.org/privilege/network.get</privilege>
162         /// <privilege>http://tizen.org/privilege/network.profile</privilege>
163         /// <feature>http://tizen.org/feature/network.telephony</feature>
164         /// <feature>http://tizen.org/feature/network.wifi</feature>
165         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
166         /// <feature>http://tizen.org/feature/network.ethernet</feature>
167         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
168         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
169         /// <exception cref="System.ArgumentException">Thrown when a value is an invalid parameter.</exception>
170         /// <exception cref="System.ArgumentNullException">Thrown when a value is null.</exception>
171         /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
172         /// <exception cref="System.InvalidOperationException">Thrown when a connection or a profile instance is invalid or when a method fails due to an invalid operation.</exception>
173         public static void UpdateProfile(ConnectionProfile profile)
174         {
175             Log.Debug(Globals.LogTag, "UpdateProfile");
176             ConnectionInternalManager.Instance.UpdateProfile(profile);
177         }
178
179         /// <summary>
180         /// Gets the name of the default profile.
181         /// </summary>
182         /// <since_tizen> 3 </since_tizen>
183         /// <returns>Connection profile object.</returns>
184         /// <privilege>http://tizen.org/privilege/network.get</privilege>
185         /// <feature>http://tizen.org/feature/network.telephony</feature>
186         /// <feature>http://tizen.org/feature/network.wifi</feature>
187         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
188         /// <feature>http://tizen.org/feature/network.ethernet</feature>
189         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
190         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
191         /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
192         /// <exception cref="System.InvalidOperationException">Thrown when a connection instance is invalid or when a method fails due to an invalid operation.</exception>
193         public static ConnectionProfile GetCurrentProfile()
194         {
195             Log.Debug(Globals.LogTag, "GetCurrentProfile");
196             return ConnectionInternalManager.Instance.GetCurrentProfile();
197         }
198
199         /// <summary>
200         /// Gets the default profile, which provides the given cellular service.
201         /// </summary>
202         /// <since_tizen> 3 </since_tizen>
203         /// <param name="type">The cellular service type.</param>
204         /// <returns>Connection profile object.</returns>
205         /// <privilege>http://tizen.org/privilege/network.get</privilege>
206         /// <feature>http://tizen.org/feature/network.telephony</feature>
207         /// <feature>http://tizen.org/feature/network.wifi</feature>
208         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
209         /// <feature>http://tizen.org/feature/network.ethernet</feature>
210         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
211         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
212         /// <exception cref="System.ArgumentException">Thrown when a value is an invalid parameter.</exception>
213         /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
214         /// <exception cref="System.InvalidOperationException">Thrown when a connection instance is invalid or when a method fails due to an invalid operation.</exception>
215         public static ConnectionProfile GetDefaultCellularProfile(CellularServiceType type)
216         {
217             Log.Debug(Globals.LogTag, "GetDefaultCurrentProfile");
218             return ConnectionInternalManager.Instance.GetDefaultCellularProfile(type);
219         }
220
221         /// <summary>
222         /// Sets the default profile, which provides the given cellular service.
223         /// </summary>
224         /// <since_tizen> 3 </since_tizen>
225         /// <param name="type">The cellular service type.</param>
226         /// <param name="profile">The connection profile object.</param>
227         /// <returns>A task indicates whether the SetDefaultCellularProfile method is done successfully or not.</returns>
228         /// <remarks>
229         /// This method must be called from MainThread.
230         /// </remarks>
231         /// <privilege>http://tizen.org/privilege/network.get</privilege>
232         /// <privilege>http://tizen.org/privilege/network.profile</privilege>
233         /// <feature>http://tizen.org/feature/network.telephony</feature>
234         /// <feature>http://tizen.org/feature/network.wifi</feature>
235         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
236         /// <feature>http://tizen.org/feature/network.ethernet</feature>
237         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
238         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
239         /// <exception cref="System.ArgumentException">Thrown when a value is an invalid parameter.</exception>
240         /// <exception cref="System.ArgumentNullException">Thrown when a value is null.</exception>
241         /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
242         /// <exception cref="System.InvalidOperationException">Thrown when a connection or a profile instance is invalid or when a method fails due to invalid operation.</exception>
243         public static Task SetDefaultCellularProfile(CellularServiceType type, ConnectionProfile profile)
244         {
245             Log.Debug(Globals.LogTag, "SetDefaultCellularProfile");
246             return ConnectionInternalManager.Instance.SetDefaultCellularProfile(type, profile);
247         }
248     }
249
250     /// <summary>
251     /// An extended EventArgs class, which contains the state of changed connection profile.
252     /// </summary>
253     /// <since_tizen> 3 </since_tizen>
254     public class ConnectionProfileStateEventArgs : EventArgs
255     {
256         private  ConnectionProfileState State;
257
258         internal ConnectionProfileStateEventArgs(ConnectionProfileState state)
259         {
260             State = state;
261         }
262
263         /// <summary>
264         /// The connection profile state.
265         /// </summary>
266         /// <since_tizen> 3 </since_tizen>
267         /// <value>State of the connection profile.</value>
268         public ConnectionProfileState ConnectionProfileState
269         {
270             get
271             {
272                 return State;
273             }
274         }
275     }
276 }