[TCSACR-10] Add new methods
authorchleun.moon <chleun.moon@samsung.com>
Wed, 31 May 2017 01:06:11 +0000 (10:06 +0900)
committerchleun.moon <chleun.moon@samsung.com>
Fri, 2 Jun 2017 03:55:35 +0000 (12:55 +0900)
1. Change ConnectionProfile.State --> ConnectionProfile.GetState(AddressFamily family)
2. Add PrefixLength to IAddressInformation
3. Add DnsConfigType to IAddressInformation
4. Add GetStatistics() and ResetStatistics() to ConnectionManager
5. Add Refresh() to ConnectionProfile
6. Add PdnType and RoamPdnType to CellularProfile
7. Add GetAllIPv6Addresses() to ConnectionManager
8. Change the return type of ConnectionManager.GetIPAddress()

Change-Id: Ie6cab571c3f7ed080dee63874fec78bb8722b431
Signed-off-by: cheoleun <chleun.moon@samsung.com>
packaging/csapi-network-connection.spec
src/Tizen.Network.Connection/Interop/Interop.Connection.cs
src/Tizen.Network.Connection/Tizen.Network.Connection/CellularProfile.cs
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionManager.cs
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfileManager.cs
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionTypes.cs
src/Tizen.Network.Connection/Tizen.Network.Connection/IAddressInformation.cs

index 6d48f9f..614a320 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       csapi-network-connection
 Summary:    Tizen Connection API for C#
-Version:    1.0.17
+Version:    1.0.18
 Release:    1
 Group:      Development/Libraries
 License:    Apache-2.0
index 097da6b..5563025 100755 (executable)
@@ -30,6 +30,8 @@ internal static partial class Interop
         public delegate void ConnectionAddressChangedCallback(IntPtr ipv4, IntPtr ipv6, IntPtr userData);
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         public delegate void ConnectionCallback(ConnectionError result, IntPtr userData);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        public delegate bool IPv6AddressCallback(IntPtr ipv6, IntPtr userData);
 
         [DllImport(Libraries.Connection, EntryPoint = "connection_create")]
         public static extern int Create(out IntPtr handle);
@@ -43,6 +45,9 @@ internal static partial class Interop
         [DllImport(Libraries.Connection, EntryPoint = "connection_get_ip_address")]
         public static extern int GetIPAddress(IntPtr handle, int family, out IntPtr address);
 
+        [DllImport(Libraries.Connection, EntryPoint = "connection_foreach_ipv6_address")]
+        public static extern int GetAllIPv6Addresses(IntPtr handle, int type, IPv6AddressCallback callback, IntPtr userData);
+
         [DllImport(Libraries.Connection, EntryPoint = "connection_get_proxy")]
         public static extern int GetProxy(IntPtr handle, int family, out IntPtr address);
 
@@ -64,6 +69,12 @@ internal static partial class Interop
         [DllImport(Libraries.Connection, EntryPoint = "connection_get_bt_state")]
         public static extern int GetBtState(IntPtr handle, out int state);
 
+        [DllImport(Libraries.Connection, EntryPoint = "connection_get_statistics")]
+        public static extern int GetStatistics(IntPtr handle, int connectionType, int statisticsType, out long size);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_reset_statistics")]
+        public static extern int ResetStatistics(IntPtr handle, int connectionType, int statisticsType);
+
         [DllImport(Libraries.Connection, EntryPoint = "connection_set_type_changed_cb")]
         public static extern int SetTypeChangedCallback(IntPtr handle, ConnectionTypeChangedCallback callback, IntPtr userData);
 
@@ -157,6 +168,9 @@ internal static partial class Interop
         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_state")]
         public static extern int GetState(IntPtr profileHandle, out int type);
 
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_ipv6_state")]
+        public static extern int GetIPv6State(IntPtr profileHandle, out int type);
+
         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_ip_config_type")]
         public static extern int GetIPConfigType(IntPtr profileHandle, int family, out int type);
 
@@ -178,6 +192,15 @@ internal static partial class Interop
         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_proxy_address")]
         public static extern int GetProxyAddress(IntPtr profileHandle, int family, out IntPtr address);
 
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_prefix_length")]
+        public static extern int GetPrefixLength(IntPtr profileHandle, int family, out int length);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_dns_config_type")]
+        public static extern int GetDnsConfigType(IntPtr profileHandle, int family, out int type);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_refresh")]
+        public static extern int Refresh(IntPtr profileHandle);
+
         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_ip_config_type")]
         public static extern int SetIPConfigType(IntPtr profileHandle, int family, int type);
 
@@ -199,6 +222,12 @@ internal static partial class Interop
         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_proxy_address")]
         public static extern int SetProxyAddress(IntPtr profileHandle, int family, string address);
 
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_prefix_length")]
+        public static extern int SetPrefixLength(IntPtr profileHandle, int family, int length);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_dns_config_type")]
+        public static extern int SetDnsConfigType(IntPtr profileHandle, int family, int type);
+
         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_state_changed_cb")]
         public static extern int SetStateChangeCallback(IntPtr profileHandle, ProfileStateChangedCallback callback, IntPtr userData);
 
@@ -220,6 +249,12 @@ internal static partial class Interop
         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_home_url")]
         public static extern int GetHomeUrl(IntPtr profileHandle, out IntPtr homeUrl);
 
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_pdn_type")]
+        public static extern int GetPdnType(IntPtr profileHandle, out int pdnType);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_get_cellular_roam_pdn_type")]
+        public static extern int GetRoamingPdnType(IntPtr profileHandle, out int roamPdnType);
+
         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_is_cellular_roaming")]
         public static extern int IsRoaming(IntPtr profileHandle, out bool roaming);
 
@@ -244,6 +279,11 @@ internal static partial class Interop
         [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_home_url")]
         public static extern int SetHomeUrl(IntPtr profileHandle, string homeUrl);
 
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_pdn_type")]
+        public static extern int SetPdnType(IntPtr profileHandle, int pdnType);
+
+        [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_cellular_roam_pdn_type")]
+        public static extern int SetRoamingPdnType(IntPtr profileHandle, int roamPdnType);
     }
 
     internal static partial class ConnectionWiFiProfile
index 2c58096..900c4a2 100755 (executable)
@@ -171,10 +171,89 @@ namespace Tizen.Network.Connection
             }
         }
 
+   /// <summary>
+        /// The cellular pdn type.
+        /// </summary>
+        /// <value>Cellular pdn type.</value>
+        /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+        /// <exception cref="System.ObjectDisposedException">Thrown when operation is performed on a disposed object.</exception>
+        public CellularPdnType PdnType
+        {
+            get
+            {
+                Log.Debug(Globals.LogTag, "Get PdnType");
+                int value;
+                int ret = Interop.ConnectionCellularProfile.GetPdnType(ProfileHandle, out value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get pdn type, " + (ConnectionError)ret);
+                }
+                return (CellularPdnType)value;
+            }
+
+            set
+            {
+                Log.Debug(Globals.LogTag, "Set PdnType");
+                CheckDisposed();
+                int ret = Interop.ConnectionCellularProfile.SetPdnType(ProfileHandle, (int)value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to set pdn type, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (ProfileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+            }
+        }
+
+        /// <summary>
+        /// The cellular roaming pdn type.
+        /// </summary>
+        /// <value>Cellular roaming pdn type.</value>
+        /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+        /// <exception cref="System.ObjectDisposedException">Thrown when operation is performed on a disposed object.</exception>
+        public CellularPdnType RoamingPdnType
+        {
+            get
+            {
+                Log.Debug(Globals.LogTag, "Get RoamingPdnType");
+                int value;
+                int ret = Interop.ConnectionCellularProfile.GetRoamingPdnType(ProfileHandle, out value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get roam pdn type, " + (ConnectionError)ret);
+                }
+                return (CellularPdnType)value;
+            }
+
+            set
+            {
+                Log.Debug(Globals.LogTag, "Set RoamingPdnType");
+                CheckDisposed();
+                int ret = Interop.ConnectionCellularProfile.SetRoamingPdnType(ProfileHandle, (int)value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to set roam pdn type, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (ProfileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+            }
+        }
+
         /// <summary>
-        /// The cellular Authentication Information.
+        /// Cellular Authentication Information.
         /// </summary>
-        /// <value>Cellular authentication information</value>
+        /// <value>Instance of CellularAuthInformation.</value>
+        /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+        /// <exception cref="System.ArgumentNullException">Thrown during set when value is null.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+        /// <exception cref="System.ObjectDisposedException">Thrown when operation is performed on a disposed object.</exception>
         public CellularAuthInformation CellularAuthInfo
         {
             get
index 374f2c2..715d02d 100755 (executable)
@@ -150,7 +150,6 @@ namespace Tizen.Network.Connection
 
         internal IntPtr GetHandle()
         {
-            Log.Debug(Globals.LogTag, "GetHandle, Thread Id = " + Thread.CurrentThread.ManagedThreadId);
             return s_threadName.Value.GetHandle();
         }
 
@@ -399,7 +398,7 @@ namespace Tizen.Network.Connection
             return Interop.Connection.DestroyProfileIterator(iterator);
         }
 
-        internal string GetIPAddress(AddressFamily family)
+        internal System.Net.IPAddress GetIPAddress(AddressFamily family)
         {
             IntPtr ip;
             int ret = Interop.Connection.GetIPAddress(GetHandle(), (int)family, out ip);
@@ -413,11 +412,39 @@ namespace Tizen.Network.Connection
 
             string result = Marshal.PtrToStringAnsi(ip);
             Interop.Libc.Free(ip);
-            return result;
+            return System.Net.IPAddress.Parse(result);;
+        }
+
+        internal IEnumerable<System.Net.IPAddress> GetAllIPv6Addresses(ConnectionType type)
+        {
+            Log.Debug(Globals.LogTag, "GetAllIPv6Addresses");
+            List<System.Net.IPAddress> ipList = new List<System.Net.IPAddress>();
+            Interop.Connection.IPv6AddressCallback callback = (IntPtr ipv6Address, IntPtr userData) =>
+            {
+                if (ipv6Address != IntPtr.Zero)
+                {
+                    string ipv6 = Marshal.PtrToStringAnsi(ipv6Address);
+                    ipList.Add(System.Net.IPAddress.Parse(ipv6));
+                    return true;
+                }
+                return false;
+            };
+
+            int ret = Interop.Connection.GetAllIPv6Addresses(GetHandle(), (int)type, callback, IntPtr.Zero);
+            if (ret != (int)ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to get all IPv6 addresses, Error - " + (ConnectionError)ret);
+                ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released");
+                ConnectionErrorFactory.ThrowConnectionException(ret);
+            }
+
+            return ipList;
         }
 
         internal string GetProxy(AddressFamily family)
         {
+            Log.Debug(Globals.LogTag, "GetProxy " + family);
             IntPtr ip;
             int ret = Interop.Connection.GetProxy(GetHandle(), (int)family, out ip);
             if ((ConnectionError)ret != ConnectionError.None)
@@ -435,8 +462,9 @@ namespace Tizen.Network.Connection
 
         internal string GetMacAddress(ConnectionType type)
         {
-            IntPtr ip;
-            int ret = Interop.Connection.GetMacAddress(GetHandle(), (int)type, out ip);
+            Log.Debug(Globals.LogTag, "GetMacAddress " + type);
+            IntPtr mac;
+            int ret = Interop.Connection.GetMacAddress(GetHandle(), (int)type, out mac);
             if ((ConnectionError)ret != ConnectionError.None)
             {
                 Log.Error(Globals.LogTag, "It failed to get mac address, " + (ConnectionError)ret);
@@ -444,17 +472,49 @@ namespace Tizen.Network.Connection
                 ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released");
                 ConnectionErrorFactory.ThrowConnectionException(ret);
             }
-            string result = Marshal.PtrToStringAnsi(ip);
-            Interop.Libc.Free(ip);
+            string result = Marshal.PtrToStringAnsi(mac);
+            Interop.Libc.Free(mac);
             return result;
         }
 
+        internal long GetStatistics(ConnectionType connectionType, StatisticsType statisticsType)
+        {
+            Log.Debug(Globals.LogTag, "GetStatistics " + connectionType + ", " + statisticsType);
+            long size;
+            int ret = Interop.Connection.GetStatistics(GetHandle(), (int)connectionType,
+                    (int)statisticsType, out size);
+            if ((ConnectionError)ret != ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "It failed to get statistics, " + (ConnectionError)ret);
+                ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.telephony");
+                ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.get)");
+                ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released");
+                ConnectionErrorFactory.ThrowConnectionException(ret);
+            }
+            return size;
+        }
+
+        internal void ResetStatistics(ConnectionType connectionType, StatisticsType statisticsType)
+        {
+            Log.Debug(Globals.LogTag, "ResetStatistics " + connectionType + ", " + statisticsType);
+            int ret = Interop.Connection.ResetStatistics(GetHandle(), (int)connectionType,
+                    (int)statisticsType);
+            if ((ConnectionError)ret != ConnectionError.None)
+            {
+                Log.Error(Globals.LogTag, "It failed to reset statistics, " + (ConnectionError)ret);
+                ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.telephony");
+                ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.set)");
+                ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero), "Connection Handle may have been disposed or released");
+                ConnectionErrorFactory.ThrowConnectionException(ret);
+            }
+        }
+
         internal ConnectionType ConnectionType
         {
             get
             {
+                Log.Debug(Globals.LogTag, "get ConnectionType");
                 int type = 0;
-                Log.Debug(Globals.LogTag, "Handle: " + GetHandle());
                 int ret = Interop.Connection.GetType(GetHandle(), out type);
                 if ((ConnectionError)ret != ConnectionError.None)
                 {
@@ -469,8 +529,8 @@ namespace Tizen.Network.Connection
         {
             get
             {
+                Log.Debug(Globals.LogTag, "get CellularState");
                 int type = 0;
-                Log.Debug(Globals.LogTag, "CellularState Handle: " + GetHandle());
                 int ret = Interop.Connection.GetCellularState(GetHandle(), out type);
                 if ((ConnectionError)ret != ConnectionError.None)
                 {
@@ -485,6 +545,7 @@ namespace Tizen.Network.Connection
         {
             get
             {
+                Log.Debug(Globals.LogTag, "get WiFiState");
                 int type = 0;
                 int ret = Interop.Connection.GetWiFiState(GetHandle(), out type);
                 if ((ConnectionError)ret != ConnectionError.None)
@@ -500,6 +561,7 @@ namespace Tizen.Network.Connection
         {
             get
             {
+                Log.Debug(Globals.LogTag, "get BluetoothState");
                 int type = 0;
                 int ret = Interop.Connection.GetBtState(GetHandle(), out type);
                 if ((ConnectionError)ret != ConnectionError.None)
@@ -515,6 +577,7 @@ namespace Tizen.Network.Connection
         {
             get
             {
+                Log.Debug(Globals.LogTag, "get ConnectionType");
                 int type = 0;
                 int ret = Interop.Connection.GetEthernetState(GetHandle(), out type);
                 if ((ConnectionError)ret != ConnectionError.None)
@@ -530,6 +593,7 @@ namespace Tizen.Network.Connection
         {
             get
             {
+                Log.Debug(Globals.LogTag, "get EthernetCableState");
                 int type = 0;
                 int ret = Interop.Connection.GetEthernetCableState(GetHandle(), out type);
                 if ((ConnectionError)ret != ConnectionError.None)
@@ -543,7 +607,6 @@ namespace Tizen.Network.Connection
 
         internal IntPtr CreateCellularProfile(ConnectionProfileType type, string keyword)
         {
-
             Log.Debug(Globals.LogTag, "CreateCellularProfile, " + type + ", " + keyword);
             if (keyword != null)
             {
@@ -641,6 +704,7 @@ namespace Tizen.Network.Connection
 
         internal ConnectionProfile GetCurrentProfile()
         {
+            Log.Debug(Globals.LogTag, "GetCurrentProfile");
             IntPtr ProfileHandle;
             int ret = Interop.Connection.GetCurrentProfile(GetHandle(), out ProfileHandle);
             if ((ConnectionError)ret != ConnectionError.None)
@@ -658,6 +722,7 @@ namespace Tizen.Network.Connection
 
         internal ConnectionProfile GetDefaultCellularProfile(CellularServiceType type)
         {
+            Log.Debug(Globals.LogTag, "GetDefaultCellularProfile");
             IntPtr ProfileHandle;
             int ret = Interop.Connection.GetDefaultCellularServiceProfile(GetHandle(), (int)type, out ProfileHandle);
             if ((ConnectionError)ret != ConnectionError.None)
@@ -712,6 +777,7 @@ namespace Tizen.Network.Connection
 
         internal Task<IEnumerable<ConnectionProfile>> GetProfileListAsync(ProfileListType type)
         {
+            Log.Debug(Globals.LogTag, "GetProfileListAsync");
             var task = new TaskCompletionSource<IEnumerable<ConnectionProfile>>();
 
             List<ConnectionProfile> Result = new List<ConnectionProfile>();
index 13c4e58..43c84b6 100755 (executable)
@@ -157,12 +157,32 @@ namespace Tizen.Network.Connection
         /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
         /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
         /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation.</exception>
-        public static string GetIPAddress(AddressFamily family)
+        public static System.Net.IPAddress GetIPAddress(AddressFamily family)
         {
             return ConnectionInternalManager.Instance.GetIPAddress(family);
         }
 
         /// <summary>
+        /// Gets the all IPv6 addresses of the current connection.
+        /// </summary>
+        /// <param name="type">The type of current network connection</param>
+        /// <returns>A list of IPv6 addresses of the connection.</returns>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation.</exception>
+        public static IEnumerable<System.Net.IPAddress> GetAllIPv6Addresses(ConnectionType type)
+        {
+            return ConnectionInternalManager.Instance.GetAllIPv6Addresses(type);
+        }
+
+        /// <summary>
         /// Gets the proxy address of the current connection.
         /// </summary>
         /// <param name="family">The address family</param>
@@ -203,6 +223,48 @@ namespace Tizen.Network.Connection
         }
 
         /// <summary>
+        /// Gets the statistics information.
+        /// </summary>
+        /// <param name="connectionType">The type of connection (only WiFi and Cellular are supported)</param>
+        /// <param name="statisticsType">The type of statistics</param>
+        /// <returns>The statistics information associated with statisticsType</returns>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation.</exception>
+        public static long GetStatistics(ConnectionType connectionType, StatisticsType statisticsType)
+        {
+            return ConnectionInternalManager.Instance.GetStatistics(connectionType, statisticsType);
+        }
+
+        /// <summary>
+        /// Resets the statistics information.
+        /// </summary>
+        /// <param name="connectionType">The type of connection (only WiFi and Cellular are supported)</param>
+        /// <param name="statisticsType">The type of statistics</param>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <privilege>http://tizen.org/privilege/network.set</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.OutOfMemoryException">Thrown when memory is not enough to continue execution.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation.</exception>
+        public static void ResetStatistics(ConnectionType connectionType, StatisticsType statisticsType)
+        {
+            ConnectionInternalManager.Instance.ResetStatistics(connectionType, statisticsType);
+        }
+
+        /// <summary>
         /// Type and state of the current profile for data connection
         /// </summary>
         /// <value>Instance of ConnectionItem</value>
index 5087d8b..85232d1 100755 (executable)
@@ -47,6 +47,7 @@ namespace Tizen.Network.Connection
         {
             add
             {
+                Log.Debug(Globals.LogTag, "ProfileStateChanged add");
                 if (_ProfileStateChanged == null)
                 {
                     ProfileStateChangedStart();
@@ -55,6 +56,7 @@ namespace Tizen.Network.Connection
             }
             remove
             {
+                Log.Debug(Globals.LogTag, "ProfileStateChanged remove");
                 _ProfileStateChanged -= value;
                 if (_ProfileStateChanged == null)
                 {
@@ -73,6 +75,7 @@ namespace Tizen.Network.Connection
                 }
             };
 
+            Log.Debug(Globals.LogTag, "ProfileStateChangedStart");
             int ret = Interop.ConnectionProfile.SetStateChangeCallback(ProfileHandle, _profileChangedCallback, IntPtr.Zero);
             if ((ConnectionError)ret != ConnectionError.None)
             {
@@ -82,6 +85,7 @@ namespace Tizen.Network.Connection
 
         private void ProfileStateChangedStop()
         {
+            Log.Debug(Globals.LogTag, "ProfileStateChangedStop");
             int ret = Interop.ConnectionProfile.UnsetStateChangeCallback(ProfileHandle);
             if ((ConnectionError)ret != ConnectionError.None)
             {
@@ -226,20 +230,63 @@ namespace Tizen.Network.Connection
         }
 
         /// <summary>
-        /// The profile state.
+        /// Refreshes the profile information.
         /// </summary>
-        public ProfileState State
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when profile instance is invalid or when method failed due to invalid operation</exception>
+        /// <exception cref="System.ObjectDisposedException">Thrown when operation is performed on a disposed object.</exception>
+        public void Refresh()
         {
-            get
+            CheckDisposed();
+            int ret = Interop.ConnectionProfile.Refresh(ProfileHandle);
+            if ((ConnectionError)ret != ConnectionError.None)
             {
+                Log.Error(Globals.LogTag, "It failed to get network interface name, " + (ConnectionError)ret);
+                ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.get)");
+                ConnectionErrorFactory.CheckHandleNullException(ret, (ProfileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                ConnectionErrorFactory.ThrowConnectionException(ret);
+            }
+        }
+
+        /// <summary>
+        /// Get the network state.
+        /// </summary>
+        /// <param name="family">The address family</param>
+        /// <returns>The network state.</returns>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <feature>http://tizen.org/feature/network.tethering.bluetooth</feature>
+        /// <feature>http://tizen.org/feature/network.ethernet</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown when value is invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when profile instance is invalid or when method failed due to invalid operation</exception>
+        /// <exception cref="System.ObjectDisposedException">Thrown when operation is performed on a disposed object.</exception>
+        public ProfileState GetState(AddressFamily family)
+        {
                 int Value;
-                int ret = Interop.ConnectionProfile.GetState(ProfileHandle, out Value);
+                int ret = (int)ConnectionError.None;
+                if (family == AddressFamily.IPv4)
+                {
+                    ret = Interop.ConnectionProfile.GetState(ProfileHandle, out Value);
+                }
+                else
+                {
+                    ret = Interop.ConnectionProfile.GetIPv6State(ProfileHandle, out Value);
+                }
+
                 if ((ConnectionError)ret != ConnectionError.None)
                 {
                     Log.Error(Globals.LogTag, "It failed to get profile state, " + (ConnectionError)ret);
                 }
                 return (ProfileState)Value;
-            }
         }
 
         /// <summary>
@@ -326,7 +373,7 @@ namespace Tizen.Network.Connection
         }
 
         /// <summary>
-        /// The subnet mask address(IPv4).
+        /// The address information (IPv4)
         /// </summary>
         /// <value>Instance of IAddressInformation with IPV4 address.</value>
         public IAddressInformation IPv4Settings
@@ -339,7 +386,7 @@ namespace Tizen.Network.Connection
         }
 
         /// <summary>
-        /// The subnet mask address(IPv4).
+        /// The address information (IPv6)
         /// </summary>
         /// <value>Instance of IAddressInformation with IPV6 address.</value>
         public IAddressInformation IPv6Settings
index af696c4..7b789c5 100755 (executable)
@@ -46,6 +46,7 @@ namespace Tizen.Network.Connection
         /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when method failed due to invalid operation</exception>
         public static void AddCellularProfile(CellularProfile profile)
         {
+            Log.Debug(Globals.LogTag, "AddCellularProfile");
             ConnectionInternalManager.Instance.AddCellularProfile(profile);
         }
 
@@ -66,6 +67,7 @@ namespace Tizen.Network.Connection
         /// <exception cref="System.InvalidOperationException">Thrown when connection instance has been disposed.</exception>
         public static Task<IEnumerable<ConnectionProfile>> GetProfileListAsync(ProfileListType type)
         {
+            Log.Debug(Globals.LogTag, "GetProfileListAsync");
             return ConnectionInternalManager.Instance.GetProfileListAsync(type);
         }
 
@@ -88,6 +90,7 @@ namespace Tizen.Network.Connection
         /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when method failed due to invalid operation</exception>
         public static Task ConnectProfileAsync(ConnectionProfile profile)
         {
+            Log.Debug(Globals.LogTag, "ConnectProfile");
             return ConnectionInternalManager.Instance.OpenProfileAsync(profile);
         }
 
@@ -110,6 +113,7 @@ namespace Tizen.Network.Connection
         /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when method failed due to invalid operation</exception>
         public static Task DisconnectProfileAsync(ConnectionProfile profile)
         {
+            Log.Debug(Globals.LogTag, "DisconnectProfileAsync");
             return ConnectionInternalManager.Instance.CloseProfileAsync(profile);
         }
 
@@ -155,6 +159,7 @@ namespace Tizen.Network.Connection
         /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when method failed due to invalid operation</exception>
         public static void UpdateProfile(ConnectionProfile profile)
         {
+            Log.Debug(Globals.LogTag, "UpdateProfile");
             ConnectionInternalManager.Instance.UpdateProfile(profile);
         }
 
@@ -174,6 +179,7 @@ namespace Tizen.Network.Connection
         /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation</exception>
         public static ConnectionProfile GetCurrentProfile()
         {
+            Log.Debug(Globals.LogTag, "GetCurrentProfile");
             return ConnectionInternalManager.Instance.GetCurrentProfile();
         }
 
@@ -194,6 +200,7 @@ namespace Tizen.Network.Connection
         /// <exception cref="System.InvalidOperationException">Thrown when connection instance is invalid or when method failed due to invalid operation</exception>
         public static ConnectionProfile GetDefaultCellularProfile(CellularServiceType type)
         {
+            Log.Debug(Globals.LogTag, "GetDefaultCurrentProfile");
             return ConnectionInternalManager.Instance.GetDefaultCellularProfile(type);
         }
 
@@ -217,6 +224,7 @@ namespace Tizen.Network.Connection
         /// <exception cref="System.InvalidOperationException">Thrown when connection or profile instance is invalid or when method failed due to invalid operation</exception>
         public static Task SetDefaultCellularProfile(CellularServiceType type, ConnectionProfile profile)
         {
+            Log.Debug(Globals.LogTag, "SetDefaultCellularProfile");
             return ConnectionInternalManager.Instance.SetDefaultCellularProfile(type, profile);
         }
     }
index 817128c..075967d 100755 (executable)
@@ -41,8 +41,8 @@ namespace Tizen.Network.Connection
     /// </summary>
     public enum AddressFamily
     {
-        IPv4 = 0,
-        IPv6 = 1
+        IPv4 = 0,   /**< IPv4 Address */
+        IPv6 = 1    /**< IPv6 Address */
     }
 
     /// <summary>
@@ -78,6 +78,17 @@ namespace Tizen.Network.Connection
     }
 
     /// <summary>
+    /// Enumeration for statistics type.
+    /// </summary>
+    public enum StatisticsType
+    {
+        LastReceivedData = 0,  /**< Last received data */
+        LastSentData = 1,  /**< Last sent data */
+        TotalReceivedData = 2,  /**< Total received data */
+        TotalSentData = 3,  /**< Total sent data */
+    }
+
+    /// <summary>
     /// Enumeration for network connection type.
     /// </summary>
     public enum ConnectionProfileType
@@ -135,6 +146,27 @@ namespace Tizen.Network.Connection
         Application = 6,  /**< Specific application */
     }
 
+    /// <summary>
+    /// Enumeration for cellular pdn type.
+    /// </summary>
+    public enum CellularPdnType
+    {
+        Unknown = 0,  /**< Unknown */
+        IPv4 = 1,  /**< IPv4 */
+        IPv6 = 2,  /**< IPv6 */
+        IPv4_IPv6 = 3,  /**< Both IPv4 and IPv6 */
+    }
+
+    /// <summary>
+    /// Enumeration for DNS configuration type.
+    /// </summary>
+    public enum DnsConfigType
+    {
+        None = 0,  /**< Not defined */
+        Static = 1,  /**< Manual DNS configuration */
+        Dynamic = 2,  /**< Config DNS using DHCP client */
+    }
+
     static internal class ConnectionErrorValue
     {
         internal const int Base = -0x01C10000;
index 767893d..f9b4efa 100755 (executable)
@@ -82,6 +82,24 @@ namespace Tizen.Network.Connection
         /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
         /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
         IPConfigType IPConfigType { get; set; }
+
+        /// <summary>
+        /// The prefix length.
+        /// </summary>
+        /// <value>Prefix length of the connection.</value>
+        /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+        int PrefixLength { get; set; }
+
+        /// <summary>
+        /// The DNS config type.
+        /// </summary>
+        /// <value>Config type of the DNS.</value>
+        /// <exception cref="System.NotSupportedException">Thrown during set when feature is not supported.</exception>
+        /// <exception cref="System.ArgumentException">Thrown during set when value is invalid parameter.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown during set when profile instance is invalid or when method failed due to invalid operation.</exception>
+        DnsConfigType DnsConfigType { get; set; }
     }
 
     internal class ConnectionAddressInformation : IAddressInformation
@@ -271,5 +289,57 @@ namespace Tizen.Network.Connection
                 }
             }
         }
+
+        public int PrefixLength
+        {
+            get
+            {
+                int Value;
+                int ret = Interop.ConnectionProfile.GetPrefixLength(_profileHandle, (int)_family, out Value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get prefix length, " + (ConnectionError)ret);
+                }
+                return Value;
+            }
+
+            set
+            {
+                int ret = Interop.ConnectionProfile.SetPrefixLength(_profileHandle, (int)_family, value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to set prefix length, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (_profileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+            }
+        }
+
+        public DnsConfigType DnsConfigType
+        {
+            get
+            {
+                int Value;
+                int ret = Interop.ConnectionProfile.GetDnsConfigType(_profileHandle, (int)_family, out Value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to get DNS config type, " + (ConnectionError)ret);
+                }
+                return (DnsConfigType)Value;
+            }
+
+            set
+            {
+                int ret = Interop.ConnectionProfile.SetDnsConfigType(_profileHandle, (int)_family, (int)value);
+                if ((ConnectionError)ret != ConnectionError.None)
+                {
+                    Log.Error(Globals.LogTag, "It failed to set DNS config type, " + (ConnectionError)ret);
+                    ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth " + "http://tizen.org/feature/network.ethernet");
+                    ConnectionErrorFactory.CheckHandleNullException(ret, (_profileHandle == IntPtr.Zero), "ProfileHandle may have been disposed or released");
+                    ConnectionErrorFactory.ThrowConnectionException(ret);
+                }
+            }
+        }
     }
 }