Setting since_tizen 3/4 on Tizen.NET API
[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.set</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         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
318         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
319         /// <exception cref="System.ArgumentException">Thrown when a value is an invalid parameter.</exception>
320         /// <exception cref="System.ArgumentNullException">Thrown when an interfaceName or a hostAddress or a gateway is null.</exception>
321         /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
322         /// <exception cref="System.InvalidOperationException">Thrown when a connection instance is invalid or when a method fails due to an invalid operation.</exception>
323         public static void AddRoute(AddressFamily family, string interfaceName, System.Net.IPAddress hostAddress, System.Net.IPAddress gateway)
324         {
325             ConnectionInternalManager.Instance.AddRoute(family, interfaceName, hostAddress, gateway);
326         }
327
328         /// <summary>
329         /// Removes a route from the routing table.
330         /// </summary>
331         /// <since_tizen> 4 </since_tizen>
332         /// <param name="family">The address family.</param>
333         /// <param name="interfaceName">The name of network interface.</param>
334         /// <param name="hostAddress">The IP address of the host.</param>
335         /// <param name="gateway">The gateway address.</param>
336         /// <privilege>http://tizen.org/privilege/network.get</privilege>
337         /// <privilege>http://tizen.org/privilege/network.set</privilege>
338         /// <feature>http://tizen.org/feature/network.telephony</feature>
339         /// <feature>http://tizen.org/feature/network.wifi</feature>
340         /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
341         /// <feature>http://tizen.org/feature/network.ethernet</feature>
342         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
343         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
344         /// <exception cref="System.ArgumentException">Thrown when a value is an invalid parameter.</exception>
345         /// <exception cref="System.ArgumentNullException">Thrown when an interfaceName or a hostAddress or a gateway is null.</exception>
346         /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
347         /// <exception cref="System.InvalidOperationException">Thrown when a connection instance is invalid or when a method fails due to an invalid operation.</exception>
348         public static void RemoveRoute(AddressFamily family, string interfaceName, System.Net.IPAddress hostAddress, System.Net.IPAddress gateway)
349         {
350             ConnectionInternalManager.Instance.RemoveRoute(family, interfaceName, hostAddress, gateway);
351         }
352
353         /// <summary>
354         /// The type and state of the current profile for data connection.
355         /// </summary>
356         /// <since_tizen> 3 </since_tizen>
357         /// <value>Instance of ConnectionItem.</value>
358         public static ConnectionItem CurrentConnection
359         {
360             get
361             {
362                 if (_currentConnection == null)
363                 {
364                     _currentConnection = new ConnectionItem();
365                 }
366
367                 return _currentConnection;
368             }
369         }
370
371         /// <summary>
372         /// Creates a cellular profile handle.
373         /// </summary>
374         /// <since_tizen> 3 </since_tizen>
375         /// <param name="type">The type of profile. Cellular profile type is supported.</param>
376         /// <param name="keyword">The keyword included in profile name.</param>
377         /// <returns>CellularProfile object.</returns>
378         /// <privilege>http://tizen.org/privilege/network.get</privilege>
379         /// <feature>http://tizen.org/feature/network.telephony</feature>
380         /// <feature>http://tizen.org/feature/network.wifi</feature>
381         /// <exception cref="System.NotSupportedException">Thrown when a feature is not supported.</exception>
382         /// <exception cref="System.UnauthorizedAccessException">Thrown when a permission is denied.</exception>
383         /// <exception cref="System.ArgumentException">Thrown when a value is an invalid parameter.</exception>
384         /// <exception cref="System.ArgumentNullException">Thrown when a keyword value is null.</exception>
385         /// <exception cref="System.InvalidOperationException">Thrown when a method fails due to invalid operation.</exception>
386         public static CellularProfile CreateCellularProfile(ConnectionProfileType type, string keyword)
387         {
388             IntPtr profileHandle = IntPtr.Zero;
389             if (type == ConnectionProfileType.Cellular)
390             {
391                 profileHandle = ConnectionInternalManager.Instance.CreateCellularProfile(type, keyword);
392             }
393
394             else
395             {
396                 Log.Error(Globals.LogTag, "ConnectionProfile Type is not supported");
397                 ConnectionErrorFactory.ThrowConnectionException((int)ConnectionError.InvalidParameter);
398             }
399
400             return new CellularProfile(profileHandle);
401         }
402
403         /// <summary>
404         /// The state of the cellular connection.
405         /// </summary>
406         /// <since_tizen> 3 </since_tizen>
407         /// <value>Cellular network state.</value>
408         /// <privilege>http://tizen.org/privilege/network.get</privilege>
409         public static CellularState CellularState
410         {
411             get
412             {
413                 return ConnectionInternalManager.Instance.CellularState;
414             }
415         }
416
417         /// <summary>
418         /// The state of the Wi-Fi connection.
419         /// </summary>
420         /// <since_tizen> 3 </since_tizen>
421         /// <value>WiFi connection state.</value>
422         /// <privilege>http://tizen.org/privilege/network.get</privilege>
423         public static ConnectionState WiFiState
424         {
425             get
426             {
427                 return ConnectionInternalManager.Instance.WiFiState;
428             }
429         }
430
431         /// <summary>
432         /// The state of the Bluetooth connection.
433         /// </summary>
434         /// <since_tizen> 3 </since_tizen>
435         /// <value>Bluetooth connection state.</value>
436         /// <privilege>http://tizen.org/privilege/network.get</privilege>
437         public static ConnectionState BluetoothState
438         {
439             get
440             {
441                 return ConnectionInternalManager.Instance.BluetoothState;
442             }
443         }
444
445         /// <summary>
446         /// The Ethernet connection state.
447         /// </summary>
448         /// <since_tizen> 3 </since_tizen>
449         /// <value>Ethernet connection state.</value>
450         /// <privilege>http://tizen.org/privilege/network.get</privilege>
451         public static ConnectionState EthernetState
452         {
453             get
454             {
455                 return ConnectionInternalManager.Instance.EthernetState;
456             }
457         }
458
459         /// <summary>
460         /// Checks if the ethernet cable is attached or not.
461         /// </summary>
462         /// <since_tizen> 3 </since_tizen>
463         /// <value>Ethernet cable state.</value>
464         /// <privilege>http://tizen.org/privilege/network.get</privilege>
465         public static EthernetCableState EthernetCableState
466         {
467             get
468             {
469                 return ConnectionInternalManager.Instance.EthernetCableState;
470             }
471         }
472
473     } // class ConnectionManager
474
475     /// <summary>
476     /// This class contains connection information, such as connection type and state.
477     /// </summary>
478     /// <since_tizen> 3 </since_tizen>
479     public class ConnectionItem
480     {
481         internal ConnectionItem()
482         {
483         }
484
485         /// <summary>
486         /// The type of the current profile for data connection.
487         /// </summary>
488         /// <since_tizen> 3 </since_tizen>
489         /// <value>Data connection current profile.</value>
490         /// <privilege>http://tizen.org/privilege/network.get</privilege>
491         public ConnectionType Type
492         {
493             get
494             {
495                 return ConnectionInternalManager.Instance.ConnectionType;
496             }
497         }
498
499         /// <summary>
500         /// The state of the current profile for data connection.
501         /// </summary>
502         /// <since_tizen> 3 </since_tizen>
503         /// <value>Connection state of the current connection type.</value>
504         /// <privilege>http://tizen.org/privilege/network.get</privilege>
505         public ConnectionState State
506         {
507             get
508             {
509                 if (ConnectionInternalManager.Instance.ConnectionType == ConnectionType.Cellular)
510                 {
511                     if (ConnectionInternalManager.Instance.CellularState == CellularState.Connected)
512                     {
513                         return ConnectionState.Connected;
514                     }
515                     else if (ConnectionInternalManager.Instance.CellularState == CellularState.Available)
516                     {
517                         return ConnectionState.Disconnected;
518                     }
519                     else {
520                         return ConnectionState.Deactivated;
521                     }
522                 }
523                 else if (ConnectionInternalManager.Instance.ConnectionType == ConnectionType.Bluetooth)
524                 {
525                     return ConnectionInternalManager.Instance.BluetoothState;
526                 }
527                 else if (ConnectionInternalManager.Instance.ConnectionType == ConnectionType.WiFi)
528                 {
529                     return ConnectionInternalManager.Instance.WiFiState;
530                 }
531                 else if (ConnectionInternalManager.Instance.ConnectionType == ConnectionType.Ethernet)
532                 {
533                     return ConnectionInternalManager.Instance.EthernetState;
534                 }
535                 else { // TO DO : Add Net Proxy
536                     return ConnectionState.Disconnected;
537                 }
538             }
539         }
540     } // class ConnectionItem
541
542     /// <summary>
543     /// An extended EventArgs class, which contains changed connection type.
544     /// </summary>
545     /// <since_tizen> 3 </since_tizen>
546     public class ConnectionTypeEventArgs : EventArgs
547     {
548         private ConnectionType Type = ConnectionType.Disconnected;
549
550         internal ConnectionTypeEventArgs(ConnectionType type)
551         {
552             Type = type;
553         }
554
555         /// <summary>
556         /// The connection type.
557         /// </summary>
558         /// <since_tizen> 3 </since_tizen>
559         /// <value>Type of the connection.</value>
560         public ConnectionType ConnectionType
561         {
562             get
563             {
564                 return Type;
565             }
566         }
567     }
568
569     /// <summary>
570     /// An extended EventArgs class, which contains changed ethernet cable state.
571     /// </summary>
572     /// <since_tizen> 3 </since_tizen>
573     public class EthernetCableStateEventArgs : EventArgs
574     {
575         private EthernetCableState State;
576
577         internal EthernetCableStateEventArgs(EthernetCableState state)
578         {
579             State = state;
580         }
581
582         /// <summary>
583         /// The ethernet cable state.
584         /// </summary>
585         /// <since_tizen> 3 </since_tizen>
586         /// <value>Attached or detached state of the ethernet cable.</value>
587         public EthernetCableState EthernetCableState
588         {
589             get
590             {
591                 return State;
592             }
593         }
594     }
595
596     /// <summary>
597     /// An extended EventArgs class, which contains changed address.
598     /// </summary>
599     /// <since_tizen> 3 </since_tizen>
600     public class AddressEventArgs : EventArgs
601     {
602         private string IPv4 = "";
603         private string IPv6 = "";
604
605         internal AddressEventArgs(string ipv4, string ipv6)
606         {
607             IPv4 = ipv4;
608             IPv6 = ipv6;
609         }
610
611         /// <summary>
612         /// The IPV4 address.
613         /// </summary>
614         /// <since_tizen> 3 </since_tizen>
615         /// <value>IP address in the format of the IPV4 syntax.</value>
616         public string IPv4Address
617         {
618             get
619             {
620                 return IPv4;
621             }
622         }
623
624         /// <summary>
625         /// The IPV6 address.
626         /// </summary>
627         /// <since_tizen> 3 </since_tizen>
628         /// <value>IP address in the format of the IPV6 syntax.</value>
629         public string IPv6Address
630         {
631             get
632             {
633                 return IPv6;
634             }
635         }
636     }
637 }