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