Binding KeyboardGrab and KeyboardUnGrab
[platform/core/csapi/tizenfx.git] / src / Tizen.Network.Connection / Tizen.Network.Connection / ConnectionManager.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.ComponentModel;
20 using System.Linq;
21 using System.Text;
22 using System.Threading.Tasks;
23 using System.Runtime.InteropServices;
24
25 namespace Tizen.Network.Connection
26 {
27     /// <summary>
28     /// This class manages the connection handle resources.
29     /// </summary>
30     /// <since_tizen> 3 </since_tizen>
31     [EditorBrowsable(EditorBrowsableState.Never)]
32     public sealed class SafeConnectionHandle : SafeHandle
33     {
34         internal SafeConnectionHandle(IntPtr handle) : base(handle, true)
35         {
36         }
37
38         /// <summary>
39         /// Checks whether the handle value is valid or not.
40         /// </summary>
41         /// <value>True if the handle is invalid, otherwise false.</value>
42         /// <since_tizen> 3 </since_tizen>
43         public override bool IsInvalid
44         {
45             get
46             {
47                 return this.handle == IntPtr.Zero;
48             }
49         }
50
51         /// <summary>
52         /// Frees the handle.
53         /// </summary>
54         /// <returns>True if the handle is released successfully, otherwise false.</returns>
55         protected override bool ReleaseHandle()
56         {
57             this.SetHandle(IntPtr.Zero);
58             return true;
59         }
60     }
61
62     /// <summary>
63     /// This is the ConnectionManager class. It provides functions to manage data connections.
64     /// </summary>
65     /// <since_tizen> 3 </since_tizen>
66     public static class ConnectionManager
67     {
68         private static ConnectionItem _currentConnection = null;
69
70         /// <summary>
71         /// An event is called when the type of the current connection is changed.
72         /// </summary>
73         /// <since_tizen> 3 </since_tizen>
74         /// <privilege>http://tizen.org/privilege/network.get</privilege>
75         /// <feature>http://tizen.org/feature/network.ethernet</feature>
76         /// <feature>http://tizen.org/feature/network.telephony</feature>
77         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
78         /// <feature>http://tizen.org/feature/network.wifi</feature>
79         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
80         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
81         public static event EventHandler<ConnectionTypeEventArgs> ConnectionTypeChanged
82         {
83             add
84             {
85                 ConnectionInternalManager.Instance.ConnectionTypeChanged += value;
86             }
87
88             remove
89             {
90                 ConnectionInternalManager.Instance.ConnectionTypeChanged -= value;
91             }
92         }
93
94         /// <summary>
95         /// An event for the ethernet cable is plugged [in/out] event.
96         /// </summary>
97         /// <since_tizen> 3 </since_tizen>
98         /// <privilege>http://tizen.org/privilege/network.get</privilege>
99         /// <feature>http://tizen.org/feature/network.ethernet</feature>
100         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
101         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
102         public static event EventHandler<EthernetCableStateEventArgs> EthernetCableStateChanged
103         {
104             add
105             {
106                 ConnectionInternalManager.Instance.EthernetCableStateChanged += value;
107             }
108
109             remove
110             {
111                 ConnectionInternalManager.Instance.EthernetCableStateChanged -= value;
112             }
113         }
114
115         /// <summary>
116         /// An event is called when the IP address is changed.
117         /// </summary>
118         /// <since_tizen> 3 </since_tizen>
119         /// <privilege>http://tizen.org/privilege/network.get</privilege>
120         /// <feature>http://tizen.org/feature/network.ethernet</feature>
121         /// <feature>http://tizen.org/feature/network.telephony</feature>
122         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
123         /// <feature>http://tizen.org/feature/network.wifi</feature>
124         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
125         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
126         public static event EventHandler<AddressEventArgs> IPAddressChanged
127         {
128             add
129             {
130                 ConnectionInternalManager.Instance.IPAddressChanged += value;
131             }
132
133             remove
134             {
135                 ConnectionInternalManager.Instance.IPAddressChanged -= value;
136             }
137         }
138
139         /// <summary>
140         /// An event is called when the proxy address is changed.
141         /// </summary>
142         /// <since_tizen> 3 </since_tizen>
143         /// <privilege>http://tizen.org/privilege/network.get</privilege>
144         /// <feature>http://tizen.org/feature/network.ethernet</feature>
145         /// <feature>http://tizen.org/feature/network.telephony</feature>
146         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
147         /// <feature>http://tizen.org/feature/network.wifi</feature>
148         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
149         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
150         public static event EventHandler<AddressEventArgs> ProxyAddressChanged
151         {
152             add
153             {
154                 ConnectionInternalManager.Instance.ProxyAddressChanged += value;
155             }
156
157             remove
158             {
159                 ConnectionInternalManager.Instance.ProxyAddressChanged -= value;
160             }
161         }
162
163         /// <summary>
164         /// Gets the connection handle.
165         /// </summary>
166         /// <since_tizen> 3 </since_tizen>
167         /// <returns>Instance of SafeConnectionHandle.</returns>
168         [EditorBrowsable(EditorBrowsableState.Never)]
169         public static SafeConnectionHandle GetConnectionHandle()
170         {
171             IntPtr handle = ConnectionInternalManager.Instance.GetHandle();
172             return new SafeConnectionHandle(handle);
173         }
174
175         /// <summary>
176         /// Gets the IP address of the current connection.
177         /// </summary>
178         /// <since_tizen> 3 </since_tizen>
179         /// <param name="family">The address family.</param>
180         /// <returns>IP address of the connection (global address in case of IPv6).</returns>
181         /// <privilege>http://tizen.org/privilege/network.get</privilege>
182         /// <feature>http://tizen.org/feature/network.ethernet</feature>
183         /// <feature>http://tizen.org/feature/network.telephony</feature>
184         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
185         /// <feature>http://tizen.org/feature/network.wifi</feature>
186         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
187         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
188         /// <exception cref="System.ArgumentException">Thrown when a value is an invalid parameter.</exception>
189         /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
190         /// <exception cref="System.InvalidOperationException">Thrown when a connection instance is invalid or when a method fails due to an invalid operation.</exception>
191         public static System.Net.IPAddress GetIPAddress(AddressFamily family)
192         {
193             return ConnectionInternalManager.Instance.GetIPAddress(family);
194         }
195
196         /// <summary>
197         /// Gets all the IPv6 addresses of the current connection.
198         /// </summary>
199         /// <since_tizen> 3 </since_tizen>
200         /// <param name="type">The type of current network connection.</param>
201         /// <returns>A list of IPv6 addresses of the connection.</returns>
202         /// <privilege>http://tizen.org/privilege/network.get</privilege>
203         /// <feature>http://tizen.org/feature/network.ethernet</feature>
204         /// <feature>http://tizen.org/feature/network.telephony</feature>
205         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
206         /// <feature>http://tizen.org/feature/network.wifi</feature>
207         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
208         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
209         /// <exception cref="System.ArgumentException">Thrown when a value is an invalid parameter.</exception>
210         /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
211         /// <exception cref="System.InvalidOperationException">Thrown when a connection instance is invalid or when a method fails due to an invalid operation.</exception>
212         public static IEnumerable<System.Net.IPAddress> GetAllIPv6Addresses(ConnectionType type)
213         {
214             return ConnectionInternalManager.Instance.GetAllIPv6Addresses(type);
215         }
216
217         /// <summary>
218         /// Gets the proxy address of the current connection.
219         /// </summary>
220         /// <since_tizen> 3 </since_tizen>
221         /// <param name="family">The address family.</param>
222         /// <returns>Proxy address of the connection.</returns>
223         /// <privilege>http://tizen.org/privilege/network.get</privilege>
224         /// <feature>http://tizen.org/feature/network.ethernet</feature>
225         /// <feature>http://tizen.org/feature/network.telephony</feature>
226         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
227         /// <feature>http://tizen.org/feature/network.wifi</feature>
228         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
229         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
230         /// <exception cref="System.ArgumentException">Thrown when a value is an invalid parameter.</exception>
231         /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
232         /// <exception cref="System.InvalidOperationException">Thrown when a connection instance is invalid or when a method fails due to an invalid operation.</exception>
233         public static string GetProxy(AddressFamily family)
234         {
235             return ConnectionInternalManager.Instance.GetProxy(family);
236         }
237
238         /// <summary>
239         /// Gets the MAC address of the Wi-Fi or ethernet.
240         /// </summary>
241         /// <since_tizen> 3 </since_tizen>
242         /// <param name="type">The type of current network connection.</param>
243         /// <returns>MAC address of the Wi-Fi or ethernet.</returns>
244         /// <privilege>http://tizen.org/privilege/network.get</privilege>
245         /// <feature>http://tizen.org/feature/network.ethernet</feature>
246         /// <feature>http://tizen.org/feature/network.telephony</feature>
247         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
248         /// <feature>http://tizen.org/feature/network.wifi</feature>
249         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
250         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
251         /// <exception cref="System.ArgumentException">Thrown when value is an invalid parameter.</exception>
252         /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
253         /// <exception cref="System.InvalidOperationException">Thrown when a connection instance is invalid or when a method fails due to an invalid operation.</exception>
254         public static string GetMacAddress(ConnectionType type)
255         {
256             return ConnectionInternalManager.Instance.GetMacAddress(type);
257         }
258
259         /// <summary>
260         /// Gets the statistics information.
261         /// </summary>
262         /// <since_tizen> 3 </since_tizen>
263         /// <param name="connectionType">The type of connection (only WiFi and Cellular are supported).</param>
264         /// <param name="statisticsType">The type of statistics.</param>
265         /// <returns>The statistics information associated with statisticsType.</returns>
266         /// <privilege>http://tizen.org/privilege/network.get</privilege>
267         /// <feature>http://tizen.org/feature/network.ethernet</feature>
268         /// <feature>http://tizen.org/feature/network.telephony</feature>
269         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
270         /// <feature>http://tizen.org/feature/network.wifi</feature>
271         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
272         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
273         /// <exception cref="System.ArgumentException">Thrown when value is an invalid parameter.</exception>
274         /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
275         /// <exception cref="System.InvalidOperationException">Thrown when a connection instance is invalid or when a method fails due to invalid operation.</exception>
276         public static long GetStatistics(ConnectionType connectionType, StatisticsType statisticsType)
277         {
278             return ConnectionInternalManager.Instance.GetStatistics(connectionType, statisticsType);
279         }
280
281         /// <summary>
282         /// Resets the statistics information.
283         /// </summary>
284         /// <since_tizen> 3 </since_tizen>
285         /// <param name="connectionType">The type of connection (only WiFi and Cellular are supported).</param>
286         /// <param name="statisticsType">The type of statistics.</param>
287         /// <privilege>http://tizen.org/privilege/network.get</privilege>
288         /// <privilege>http://tizen.org/privilege/network.set</privilege>
289         /// <feature>http://tizen.org/feature/network.ethernet</feature>
290         /// <feature>http://tizen.org/feature/network.telephony</feature>
291         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
292         /// <feature>http://tizen.org/feature/network.wifi</feature>
293         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
294         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
295         /// <exception cref="System.ArgumentException">Thrown when a value is an invalid parameter.</exception>
296         /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
297         /// <exception cref="System.InvalidOperationException">Thrown when a connection instance is invalid or when a method fails due to an invalid operation.</exception>
298         public static void ResetStatistics(ConnectionType connectionType, StatisticsType statisticsType)
299         {
300             ConnectionInternalManager.Instance.ResetStatistics(connectionType, statisticsType);
301         }
302
303         /// <summary>
304         /// Adds a route to the routing table.
305         /// </summary>
306         /// <since_tizen> 4 </since_tizen>
307         /// <param name="family">The address family.</param>
308         /// <param name="interfaceName">The name of the network interface.</param>
309         /// <param name="hostAddress">The IP address of the host.</param>
310         /// <param name="gateway">The gateway address.</param>
311         /// <privilege>http://tizen.org/privilege/network.get</privilege>
312         /// <privilege>http://tizen.org/privilege/network.route</privilege>
313         /// <feature>http://tizen.org/feature/network.telephony</feature>
314         /// <feature>http://tizen.org/feature/network.wifi</feature>
315         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
316         /// <feature>http://tizen.org/feature/network.ethernet</feature>
317         /// <feature>http://tizen.org/feature/network.route</feature>
318         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
319         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
320         /// <exception cref="System.ArgumentException">Thrown when a value is an invalid parameter.</exception>
321         /// <exception cref="System.ArgumentNullException">Thrown when an interfaceName or a hostAddress or a gateway is null.</exception>
322         /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
323         /// <exception cref="System.InvalidOperationException">Thrown when a connection instance is invalid or when a method fails due to an invalid operation.</exception>
324         public static void AddRoute(AddressFamily family, string interfaceName, System.Net.IPAddress hostAddress, System.Net.IPAddress gateway)
325         {
326             ConnectionInternalManager.Instance.AddRoute(family, interfaceName, hostAddress, gateway);
327         }
328
329         /// <summary>
330         /// Removes a route from the routing table.
331         /// </summary>
332         /// <since_tizen> 4 </since_tizen>
333         /// <param name="family">The address family.</param>
334         /// <param name="interfaceName">The name of network interface.</param>
335         /// <param name="hostAddress">The IP address of the host.</param>
336         /// <param name="gateway">The gateway address.</param>
337         /// <privilege>http://tizen.org/privilege/network.get</privilege>
338         /// <privilege>http://tizen.org/privilege/network.route</privilege>
339         /// <feature>http://tizen.org/feature/network.telephony</feature>
340         /// <feature>http://tizen.org/feature/network.wifi</feature>
341         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
342         /// <feature>http://tizen.org/feature/network.ethernet</feature>
343         /// <feature>http://tizen.org/feature/network.route</feature>
344         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
345         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
346         /// <exception cref="System.ArgumentException">Thrown when a value is an invalid parameter.</exception>
347         /// <exception cref="System.ArgumentNullException">Thrown when an interfaceName or a hostAddress or a gateway is null.</exception>
348         /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
349         /// <exception cref="System.InvalidOperationException">Thrown when a connection instance is invalid or when a method fails due to an invalid operation.</exception>
350         public static void RemoveRoute(AddressFamily family, string interfaceName, System.Net.IPAddress hostAddress, System.Net.IPAddress gateway)
351         {
352             ConnectionInternalManager.Instance.RemoveRoute(family, interfaceName, hostAddress, gateway);
353         }
354
355         /// <summary>
356         /// The type and state of the current profile for data connection.
357         /// </summary>
358         /// <since_tizen> 3 </since_tizen>
359         /// <value>Instance of ConnectionItem.</value>
360         public static ConnectionItem CurrentConnection
361         {
362             get
363             {
364                 if (_currentConnection == null)
365                 {
366                     _currentConnection = new ConnectionItem();
367                 }
368
369                 return _currentConnection;
370             }
371         }
372
373         /// <summary>
374         /// Creates a cellular profile handle.
375         /// </summary>
376         /// <since_tizen> 3 </since_tizen>
377         /// <param name="type">The type of profile. Cellular profile type is supported.</param>
378         /// <param name="keyword">The keyword included in profile name.</param>
379         /// <returns>CellularProfile object.</returns>
380         /// <privilege>http://tizen.org/privilege/network.get</privilege>
381         /// <feature>http://tizen.org/feature/network.telephony</feature>
382         /// <feature>http://tizen.org/feature/network.wifi</feature>
383         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
384         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
385         /// <exception cref="System.ArgumentException">Thrown when a value is an invalid parameter.</exception>
386         /// <exception cref="System.ArgumentNullException">Thrown when a keyword value is null.</exception>
387         /// <exception cref="System.InvalidOperationException">Thrown when a method fails due to invalid operation.</exception>
388         public static CellularProfile CreateCellularProfile(ConnectionProfileType type, string keyword)
389         {
390             IntPtr profileHandle = IntPtr.Zero;
391             if (type == ConnectionProfileType.Cellular)
392             {
393                 profileHandle = ConnectionInternalManager.Instance.CreateCellularProfile(type, keyword);
394             }
395
396             else
397             {
398                 Log.Error(Globals.LogTag, "ConnectionProfile Type is not supported");
399                 ConnectionErrorFactory.ThrowConnectionException((int)ConnectionError.InvalidParameter);
400             }
401
402             return new CellularProfile(profileHandle);
403         }
404
405         /// <summary>
406         /// The state of the cellular connection.
407         /// </summary>
408         /// <since_tizen> 3 </since_tizen>
409         /// <value>Cellular network state.</value>
410         /// <feature>http://tizen.org/feature/network.telephony</feature>
411         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
412         public static CellularState CellularState
413         {
414             get
415             {
416                 return ConnectionInternalManager.Instance.CellularState;
417             }
418         }
419
420         /// <summary>
421         /// The state of the Wi-Fi connection.
422         /// </summary>
423         /// <since_tizen> 3 </since_tizen>
424         /// <value>WiFi connection state.</value>
425         /// <privilege>http://tizen.org/privilege/network.get</privilege>
426         /// <feature>http://tizen.org/feature/network.wifi</feature>
427         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
428         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
429         public static ConnectionState WiFiState
430         {
431             get
432             {
433                 return ConnectionInternalManager.Instance.WiFiState;
434             }
435         }
436
437         /// <summary>
438         /// The state of the Bluetooth connection.
439         /// </summary>
440         /// <since_tizen> 3 </since_tizen>
441         /// <value>Bluetooth connection state.</value>
442         /// <privilege>http://tizen.org/privilege/network.get</privilege>
443         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
444         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
445         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
446         public static ConnectionState BluetoothState
447         {
448             get
449             {
450                 return ConnectionInternalManager.Instance.BluetoothState;
451             }
452         }
453
454         /// <summary>
455         /// The Ethernet connection state.
456         /// </summary>
457         /// <since_tizen> 3 </since_tizen>
458         /// <value>Ethernet connection state.</value>
459         /// <privilege>http://tizen.org/privilege/network.get</privilege>
460         /// <feature>http://tizen.org/feature/network.ethernet</feature>
461         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
462         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
463         public static ConnectionState EthernetState
464         {
465             get
466             {
467                 return ConnectionInternalManager.Instance.EthernetState;
468             }
469         }
470
471         /// <summary>
472         /// Checks if the ethernet cable is attached or not.
473         /// </summary>
474         /// <since_tizen> 3 </since_tizen>
475         /// <value>Ethernet cable state.</value>
476         /// <privilege>http://tizen.org/privilege/network.get</privilege>
477         /// <feature>http://tizen.org/feature/network.ethernet</feature>
478         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
479         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
480         public static EthernetCableState EthernetCableState
481         {
482             get
483             {
484                 return ConnectionInternalManager.Instance.EthernetCableState;
485             }
486         }
487
488     } // class ConnectionManager
489
490     /// <summary>
491     /// This class contains connection information, such as connection type and state.
492     /// </summary>
493     /// <since_tizen> 3 </since_tizen>
494     public class ConnectionItem
495     {
496         internal ConnectionItem()
497         {
498         }
499
500         /// <summary>
501         /// The type of the current profile for data connection.
502         /// </summary>
503         /// <since_tizen> 3 </since_tizen>
504         /// <value>Data connection current profile.</value>
505         /// <privilege>http://tizen.org/privilege/network.get</privilege>
506         /// <feature>http://tizen.org/feature/network.ethernet</feature>
507         /// <feature>http://tizen.org/feature/network.telephony</feature>
508         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
509         /// <feature>http://tizen.org/feature/network.wifi</feature>
510         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
511         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
512         public ConnectionType Type
513         {
514             get
515             {
516                 return ConnectionInternalManager.Instance.ConnectionType;
517             }
518         }
519
520         /// <summary>
521         /// The state of the current profile for data connection.
522         /// </summary>
523         /// <since_tizen> 3 </since_tizen>
524         /// <value>Connection state of the current connection type.</value>
525         /// <privilege>http://tizen.org/privilege/network.get</privilege>
526         /// <feature>http://tizen.org/feature/network.ethernet</feature>
527         /// <feature>http://tizen.org/feature/network.telephony</feature>
528         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
529         /// <feature>http://tizen.org/feature/network.wifi</feature>
530         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
531         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
532         public ConnectionState State
533         {
534             get
535             {
536                 if (ConnectionInternalManager.Instance.ConnectionType == ConnectionType.Cellular)
537                 {
538                     if (ConnectionInternalManager.Instance.CellularState == CellularState.Connected)
539                     {
540                         return ConnectionState.Connected;
541                     }
542                     else if (ConnectionInternalManager.Instance.CellularState == CellularState.Available)
543                     {
544                         return ConnectionState.Disconnected;
545                     }
546                     else {
547                         return ConnectionState.Deactivated;
548                     }
549                 }
550                 else if (ConnectionInternalManager.Instance.ConnectionType == ConnectionType.Bluetooth)
551                 {
552                     return ConnectionInternalManager.Instance.BluetoothState;
553                 }
554                 else if (ConnectionInternalManager.Instance.ConnectionType == ConnectionType.WiFi)
555                 {
556                     return ConnectionInternalManager.Instance.WiFiState;
557                 }
558                 else if (ConnectionInternalManager.Instance.ConnectionType == ConnectionType.Ethernet)
559                 {
560                     return ConnectionInternalManager.Instance.EthernetState;
561                 }
562                 else { // TO DO : Add Net Proxy
563                     return ConnectionState.Disconnected;
564                 }
565             }
566         }
567     } // class ConnectionItem
568
569     /// <summary>
570     /// An extended EventArgs class, which contains changed connection type.
571     /// </summary>
572     /// <since_tizen> 3 </since_tizen>
573     public class ConnectionTypeEventArgs : EventArgs
574     {
575         private ConnectionType Type = ConnectionType.Disconnected;
576
577         internal ConnectionTypeEventArgs(ConnectionType type)
578         {
579             Type = type;
580         }
581
582         /// <summary>
583         /// The connection type.
584         /// </summary>
585         /// <since_tizen> 3 </since_tizen>
586         /// <value>Type of the connection.</value>
587         public ConnectionType ConnectionType
588         {
589             get
590             {
591                 return Type;
592             }
593         }
594     }
595
596     /// <summary>
597     /// An extended EventArgs class, which contains changed ethernet cable state.
598     /// </summary>
599     /// <since_tizen> 3 </since_tizen>
600     public class EthernetCableStateEventArgs : EventArgs
601     {
602         private EthernetCableState State;
603
604         internal EthernetCableStateEventArgs(EthernetCableState state)
605         {
606             State = state;
607         }
608
609         /// <summary>
610         /// The ethernet cable state.
611         /// </summary>
612         /// <since_tizen> 3 </since_tizen>
613         /// <value>Attached or detached state of the ethernet cable.</value>
614         public EthernetCableState EthernetCableState
615         {
616             get
617             {
618                 return State;
619             }
620         }
621     }
622
623     /// <summary>
624     /// An extended EventArgs class, which contains changed address.
625     /// </summary>
626     /// <since_tizen> 3 </since_tizen>
627     public class AddressEventArgs : EventArgs
628     {
629         private string IPv4 = "";
630         private string IPv6 = "";
631
632         internal AddressEventArgs(string ipv4, string ipv6)
633         {
634             IPv4 = ipv4;
635             IPv6 = ipv6;
636         }
637
638         /// <summary>
639         /// The IPV4 address.
640         /// </summary>
641         /// <since_tizen> 3 </since_tizen>
642         /// <value>IP address in the format of the IPV4 syntax.</value>
643         public string IPv4Address
644         {
645             get
646             {
647                 return IPv4;
648             }
649         }
650
651         /// <summary>
652         /// The IPV6 address.
653         /// </summary>
654         /// <since_tizen> 3 </since_tizen>
655         /// <value>IP address in the format of the IPV6 syntax.</value>
656         public string IPv6Address
657         {
658             get
659             {
660                 return IPv6;
661             }
662         }
663     }
664 }