2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Collections.Generic;
21 using System.Threading.Tasks;
22 using System.Collections;
24 namespace Tizen.Network.Connection
27 /// This class is ConnectionProfileManager. It provides functions to add, get, connect or modify the connection profile.
29 /// <since_tizen> 3 </since_tizen>
30 public static class ConnectionProfileManager
33 /// Adds a new profile
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 feature is not supported.</exception>
44 /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
45 /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
46 /// <exception cref="System.ArgumentNullException">Thrown when 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 method failed due to invalid operation</exception>
49 public static void AddCellularProfile(CellularProfile profile)
51 Log.Debug(Globals.LogTag, "AddCellularProfile");
52 ConnectionInternalManager.Instance.AddCellularProfile(profile);
56 /// Gets the list of profile with profile list type
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 feature is not supported.</exception>
67 /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
68 /// <exception cref="System.ArgumentException">Thrown when value is 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 connection instance has been disposed.</exception>
71 public static Task<IEnumerable<ConnectionProfile>> GetProfileListAsync(ProfileListType type)
73 Log.Debug(Globals.LogTag, "GetProfileListAsync");
74 return ConnectionInternalManager.Instance.GetProfileListAsync(type);
78 /// Opens a connection of profile, asynchronously.
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 /// <privilege>http://tizen.org/privilege/network.get</privilege>
84 /// <privilege>http://tizen.org/privilege/network.set</privilege>
85 /// <feature>http://tizen.org/feature/network.telephony</feature>
86 /// <feature>http://tizen.org/feature/network.wifi</feature>
87 /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
88 /// <feature>http://tizen.org/feature/network.ethernet</feature>
89 /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
90 /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
91 /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
92 /// <exception cref="System.ArgumentNullException">Thrown when value is null.</exception>
93 /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
94 /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when method failed due to invalid operation</exception>
95 public static Task ConnectProfileAsync(ConnectionProfile profile)
97 Log.Debug(Globals.LogTag, "ConnectProfile");
98 return ConnectionInternalManager.Instance.OpenProfileAsync(profile);
102 /// Closes a connection of profile.
104 /// <since_tizen> 3 </since_tizen>
105 /// <param name="profile">The connection profile object</param>
106 /// <returns>A task indicates whether the DisconnectProfileAsync method is done successfully or not.</returns>
107 /// <privilege>http://tizen.org/privilege/network.get</privilege>
108 /// <privilege>http://tizen.org/privilege/network.set</privilege>
109 /// <feature>http://tizen.org/feature/network.telephony</feature>
110 /// <feature>http://tizen.org/feature/network.wifi</feature>
111 /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
112 /// <feature>http://tizen.org/feature/network.ethernet</feature>
113 /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
114 /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
115 /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
116 /// <exception cref="System.ArgumentNullException">Thrown when value is null.</exception>
117 /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
118 /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when method failed due to invalid operation</exception>
119 public static Task DisconnectProfileAsync(ConnectionProfile profile)
121 Log.Debug(Globals.LogTag, "DisconnectProfileAsync");
122 return ConnectionInternalManager.Instance.CloseProfileAsync(profile);
126 /// Removes an existing profile.
128 /// <since_tizen> 3 </since_tizen>
129 /// <param name="profile">The connection profile object</param>
130 /// <privilege>http://tizen.org/privilege/network.get</privilege>
131 /// <privilege>http://tizen.org/privilege/network.profile</privilege>
132 /// <feature>http://tizen.org/feature/network.telephony</feature>
133 /// <feature>http://tizen.org/feature/network.wifi</feature>
134 /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
135 /// <feature>http://tizen.org/feature/network.ethernet</feature>
136 /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
137 /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
138 /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
139 /// <exception cref="System.ArgumentNullException">Thrown when value is null.</exception>
140 /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
141 /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when method failed due to invalid operation</exception>
142 public static void RemoveProfile(ConnectionProfile profile)
144 Log.Debug(Globals.LogTag, "RemoveProfile. Id: " + profile.Id + ", Name: " + profile.Name + ", Type: " + profile.Type);
145 ConnectionInternalManager.Instance.RemoveProfile(profile);
149 /// Updates an existing profile.
150 /// When a profile is changed, these changes will be not applied to the ConnectionProfileManager immediately.
151 /// When you call this function, your changes affect the ConnectionProfileManager and the existing profile is updated.
153 /// <since_tizen> 3 </since_tizen>
154 /// <param name="profile">The connection profile object</param>
155 /// <privilege>http://tizen.org/privilege/network.get</privilege>
156 /// <privilege>http://tizen.org/privilege/network.profile</privilege>
157 /// <feature>http://tizen.org/feature/network.telephony</feature>
158 /// <feature>http://tizen.org/feature/network.wifi</feature>
159 /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
160 /// <feature>http://tizen.org/feature/network.ethernet</feature>
161 /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
162 /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
163 /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
164 /// <exception cref="System.ArgumentNullException">Thrown when value is null.</exception>
165 /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
166 /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when method failed due to invalid operation</exception>
167 public static void UpdateProfile(ConnectionProfile profile)
169 Log.Debug(Globals.LogTag, "UpdateProfile");
170 ConnectionInternalManager.Instance.UpdateProfile(profile);
174 /// Gets the name of the default profile.
176 /// <since_tizen> 3 </since_tizen>
177 /// <returns>Connection profile object.</returns>
178 /// <privilege>http://tizen.org/privilege/network.get</privilege>
179 /// <feature>http://tizen.org/feature/network.telephony</feature>
180 /// <feature>http://tizen.org/feature/network.wifi</feature>
181 /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
182 /// <feature>http://tizen.org/feature/network.ethernet</feature>
183 /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
184 /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
185 /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
186 /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
187 /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation</exception>
188 public static ConnectionProfile GetCurrentProfile()
190 Log.Debug(Globals.LogTag, "GetCurrentProfile");
191 return ConnectionInternalManager.Instance.GetCurrentProfile();
195 /// Gets the default profile which provides the given cellular service.
197 /// <since_tizen> 3 </since_tizen>
198 /// <param name="type">The cellular service type</param>
199 /// <returns>Connection profile object.</returns>
200 /// <privilege>http://tizen.org/privilege/network.get</privilege>
201 /// <feature>http://tizen.org/feature/network.telephony</feature>
202 /// <feature>http://tizen.org/feature/network.wifi</feature>
203 /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
204 /// <feature>http://tizen.org/feature/network.ethernet</feature>
205 /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
206 /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
207 /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
208 /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
209 /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation</exception>
210 public static ConnectionProfile GetDefaultCellularProfile(CellularServiceType type)
212 Log.Debug(Globals.LogTag, "GetDefaultCurrentProfile");
213 return ConnectionInternalManager.Instance.GetDefaultCellularProfile(type);
217 /// Sets the default profile which provides the given cellular service.
219 /// <since_tizen> 3 </since_tizen>
220 /// <param name="type">The cellular service type</param>
221 /// <param name="profile">The connection profile object</param>
222 /// <returns>A task indicates whether the SetDefaultCellularProfile method is done successfully or not.</returns>
223 /// <privilege>http://tizen.org/privilege/network.get</privilege>
224 /// <privilege>http://tizen.org/privilege/network.profile</privilege>
225 /// <feature>http://tizen.org/feature/network.telephony</feature>
226 /// <feature>http://tizen.org/feature/network.wifi</feature>
227 /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
228 /// <feature>http://tizen.org/feature/network.ethernet</feature>
229 /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
230 /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
231 /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
232 /// <exception cref="System.ArgumentNullException">Thrown when value is null.</exception>
233 /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
234 /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when method failed due to invalid operation</exception>
235 public static Task SetDefaultCellularProfile(CellularServiceType type, ConnectionProfile profile)
237 Log.Debug(Globals.LogTag, "SetDefaultCellularProfile");
238 return ConnectionInternalManager.Instance.SetDefaultCellularProfile(type, profile);
243 /// An extended EventArgs class which contains the state of changed connection profile.
245 /// <since_tizen> 3 </since_tizen>
246 public class ConnectionProfileStateEventArgs : EventArgs
248 private ConnectionProfileState State;
250 internal ConnectionProfileStateEventArgs(ConnectionProfileState state)
256 /// The connection profile state.
258 /// <since_tizen> 3 </since_tizen>
259 /// <value>State of the connection profile.</value>
260 public ConnectionProfileState ConnectionProfileState