From 09c65f58e7fb7759a83864e7b338559892e1e81d Mon Sep 17 00:00:00 2001 From: "chleun.moon" Date: Mon, 15 May 2017 16:56:50 +0900 Subject: [PATCH] Revert before adding new apis Change-Id: Ie8fe14ee863fccb3fad5b289c708c46e2ac79e90 Signed-off-by: cheoleun --- packaging/csapi-network-connection.spec | 2 +- .../Interop/Interop.Connection.cs | 40 ---------- .../Tizen.Network.Connection/CellularProfile.cs | 72 ----------------- .../Tizen.Network.Connection/ConnectionError.cs | 39 ++------- .../ConnectionInternalManager.cs | 92 +++------------------- .../Tizen.Network.Connection/ConnectionManager.cs | 91 ++------------------- .../Tizen.Network.Connection/ConnectionProfile.cs | 49 ++---------- .../ConnectionProfileManager.cs | 8 -- .../Tizen.Network.Connection/ConnectionTypes.cs | 36 +-------- .../IAddressInformation.cs | 88 +-------------------- 10 files changed, 35 insertions(+), 482 deletions(-) diff --git a/packaging/csapi-network-connection.spec b/packaging/csapi-network-connection.spec index 2898831..157f778 100755 --- a/packaging/csapi-network-connection.spec +++ b/packaging/csapi-network-connection.spec @@ -1,6 +1,6 @@ Name: csapi-network-connection Summary: Tizen Connection API for C# -Version: 1.0.15 +Version: 1.0.16 Release: 1 Group: Development/Libraries License: Apache-2.0 diff --git a/src/Tizen.Network.Connection/Interop/Interop.Connection.cs b/src/Tizen.Network.Connection/Interop/Interop.Connection.cs index 5563025..097da6b 100755 --- a/src/Tizen.Network.Connection/Interop/Interop.Connection.cs +++ b/src/Tizen.Network.Connection/Interop/Interop.Connection.cs @@ -30,8 +30,6 @@ 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); @@ -45,9 +43,6 @@ 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); @@ -69,12 +64,6 @@ 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); @@ -168,9 +157,6 @@ 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); @@ -192,15 +178,6 @@ 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); @@ -222,12 +199,6 @@ 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); @@ -249,12 +220,6 @@ 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); @@ -279,11 +244,6 @@ 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 diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/CellularProfile.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/CellularProfile.cs index 855f5bf..628cc33 100755 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/CellularProfile.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/CellularProfile.cs @@ -122,78 +122,6 @@ namespace Tizen.Network.Connection } /// - /// The cellular pdn type. - /// - /// Thrown during set when feature is not supported. - /// Thrown during set when value is invalid parameter. - /// Thrown during set when profile instance is invalid or when method failed due to invalid operation. - /// Thrown when operation is performed on a disposed object. - 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); - } - } - } - - /// - /// The cellular roaming pdn type. - /// - /// Thrown during set when feature is not supported. - /// Thrown during set when value is invalid parameter. - /// Thrown during set when profile instance is invalid or when method failed due to invalid operation. - /// Thrown when operation is performed on a disposed object. - 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); - } - } - } - - /// /// Gets cellular Authentification Information. /// public CellularAuthInformation CellularAuthInfo diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionError.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionError.cs index 9e8d587..be0e5dc 100755 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionError.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionError.cs @@ -24,34 +24,7 @@ namespace Tizen.Network.Connection { internal static class ConnectionErrorFactory { - internal static void CheckFeatureUnsupportedException(int err, string message) - { - if ((ConnectionError)err == ConnectionError.NotSupported) - { - ThrowConnectionException(err, message); - } - } - - internal static void CheckPermissionDeniedException(int err, string message) - { - if ((ConnectionError)err == ConnectionError.PermissionDenied) - { - ThrowConnectionException(err, message); - } - } - - internal static void CheckHandleNullException(int err, bool isHandleInvalid, string message) - { - if ((ConnectionError)err == ConnectionError.InvalidParameter) - { - if (isHandleInvalid) - { - ThrowConnectionException((int)ConnectionError.InvalidOperation, message); - } - } - } - - internal static void ThrowConnectionException(int errno , string message = "") + internal static void ThrowConnectionException(int errno) { ConnectionError _error = (ConnectionError)errno; Log.Debug(Globals.LogTag, "ThrowConnectionException " + _error); @@ -68,15 +41,15 @@ namespace Tizen.Network.Connection case ConnectionError.InvalidKey: throw new InvalidOperationException("Invalid Key"); case ConnectionError.InvalidOperation: - throw new InvalidOperationException("Invalid Operation " + message); + throw new InvalidOperationException("Invalid Operation"); case ConnectionError.InvalidParameter: - throw new ArgumentException("Invalid Parameter"); + throw new InvalidOperationException("Invalid Parameter"); case ConnectionError.NoConnection: throw new InvalidOperationException("No Connection"); case ConnectionError.NoReply: throw new InvalidOperationException("No Reply"); case ConnectionError.NotSupported: - throw new NotSupportedException("Unsupported feature " + message); + throw new NotSupportedException("Not Supported"); case ConnectionError.NowInProgress: throw new InvalidOperationException("Now In Progress"); case ConnectionError.OperationAborted: @@ -84,9 +57,9 @@ namespace Tizen.Network.Connection case ConnectionError.OperationFailed: throw new InvalidOperationException("Operation Failed"); case ConnectionError.OutOfMemoryError: - throw new OutOfMemoryException("Out Of Memory Error"); + throw new InvalidOperationException("Out Of Memory Error"); case ConnectionError.PermissionDenied: - throw new UnauthorizedAccessException("Permission Denied " + message); + throw new InvalidOperationException("Permission Denied"); } } } diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs index 501b6a5..deb59d4 100755 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs @@ -32,6 +32,7 @@ namespace Tizen.Network.Connection public HandleHolder() { + Log.Debug(Globals.LogTag, "HandleHolder() ^^"); Interop.Connection.Create(out Handle); Log.Debug(Globals.LogTag, "Handle: " + Handle); } @@ -140,6 +141,7 @@ namespace Tizen.Network.Connection internal IntPtr GetHandle() { + Log.Debug(Globals.LogTag, "GetHandle, Thread Id = " + Thread.CurrentThread.ManagedThreadId); return s_threadName.Value.GetHandle(); } @@ -388,9 +390,8 @@ namespace Tizen.Network.Connection return Interop.Connection.DestroyProfileIterator(iterator); } - internal System.Net.IPAddress GetIPAddress(AddressFamily family) + internal string GetIPAddress(AddressFamily family) { - Log.Debug(Globals.LogTag, "GetIPAddress " + family); IntPtr ip; int ret = Interop.Connection.GetIPAddress(GetHandle(), (int)family, out ip); if ((ConnectionError)ret != ConnectionError.None) @@ -400,38 +401,11 @@ namespace Tizen.Network.Connection } string result = Marshal.PtrToStringAnsi(ip); Interop.Libc.Free(ip); - return System.Net.IPAddress.Parse(result); - } - - internal IEnumerable GetAllIPv6Addresses(ConnectionType type) - { - Log.Debug(Globals.LogTag, "GetAllIPv6Addresses"); - List ipList = new List(); - 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.ThrowConnectionException(ret); - } - - return ipList; + return result; } - 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) @@ -446,51 +420,24 @@ namespace Tizen.Network.Connection internal string GetMacAddress(ConnectionType type) { - Log.Debug(Globals.LogTag, "GetMacAddress " + type); - IntPtr mac; - int ret = Interop.Connection.GetMacAddress(GetHandle(), (int)type, out mac); + IntPtr ip; + int ret = Interop.Connection.GetMacAddress(GetHandle(), (int)type, out ip); if ((ConnectionError)ret != ConnectionError.None) { Log.Error(Globals.LogTag, "It failed to get mac address, " + (ConnectionError)ret); ConnectionErrorFactory.ThrowConnectionException(ret); } - string result = Marshal.PtrToStringAnsi(mac); - Interop.Libc.Free(mac); + string result = Marshal.PtrToStringAnsi(ip); + Interop.Libc.Free(ip); 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.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.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) { @@ -505,8 +452,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) { @@ -521,7 +468,6 @@ 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) @@ -537,7 +483,6 @@ 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) @@ -553,7 +498,6 @@ 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) @@ -569,7 +513,6 @@ 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) @@ -583,7 +526,7 @@ namespace Tizen.Network.Connection internal IntPtr CreateCellularProfile(ConnectionProfileType type, string keyword) { - Log.Debug(Globals.LogTag, "CreateCellularProfile, " + type + ", " + keyword); + Log.Error(Globals.LogTag, "CreateCellularProfile, " + type + ", " + keyword); IntPtr connectionHandle = GetHandle(); if (connectionHandle == IntPtr.Zero) { @@ -604,7 +547,6 @@ namespace Tizen.Network.Connection internal void AddCellularProfile(CellularProfile profile) { - Log.Debug(Globals.LogTag, "AddCellularProfile"); if (profile.Type == ConnectionProfileType.Cellular) { int ret = Interop.Connection.AddProfile(GetHandle(), profile.ProfileHandle); @@ -623,7 +565,6 @@ namespace Tizen.Network.Connection internal void RemoveProfile(ConnectionProfile profile) { - Log.Debug(Globals.LogTag, "RemoveProfile"); int ret = Interop.Connection.RemoveProfile(GetHandle(), profile.ProfileHandle); if ((ConnectionError)ret != ConnectionError.None) { @@ -634,7 +575,6 @@ namespace Tizen.Network.Connection internal void UpdateProfile(ConnectionProfile profile) { - Log.Debug(Globals.LogTag, "UpdateProfile"); int ret = Interop.Connection.UpdateProfile(GetHandle(), profile.ProfileHandle); if ((ConnectionError)ret != ConnectionError.None) { @@ -645,7 +585,6 @@ 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) @@ -659,7 +598,6 @@ 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) @@ -674,7 +612,6 @@ namespace Tizen.Network.Connection internal Task SetDefaultCellularProfile(CellularServiceType type, ConnectionProfile profile) { - Log.Debug(Globals.LogTag, "SetDefaultCellularProfile"); TaskCompletionSource task = new TaskCompletionSource(); Interop.Connection.ConnectionCallback Callback = (ConnectionError Result, IntPtr Data) => { @@ -700,8 +637,8 @@ namespace Tizen.Network.Connection internal Task> GetProfileListAsync(ProfileListType type) { - Log.Debug(Globals.LogTag, "GetProfileListAsync"); var task = new TaskCompletionSource>(); + List Result = new List(); IntPtr iterator; int ret = Interop.Connection.GetProfileIterator(GetHandle(), (int)type, out iterator); @@ -742,11 +679,9 @@ namespace Tizen.Network.Connection internal Task OpenProfileAsync(ConnectionProfile profile) { - Log.Debug(Globals.LogTag, "OpenProfileAsync " + profile.Name); TaskCompletionSource task = new TaskCompletionSource(); Interop.Connection.ConnectionCallback Callback = (ConnectionError Result, IntPtr Data) => { - Log.Debug(Globals.LogTag, "Connected " + profile.Name); if (Result != ConnectionError.None) { Log.Error(Globals.LogTag, "Error occurs during connecting profile, " + Result); @@ -768,7 +703,6 @@ namespace Tizen.Network.Connection internal Task CloseProfileAsync(ConnectionProfile profile) { - Log.Debug(Globals.LogTag, "CloseProfileAsync " + profile.Name); TaskCompletionSource task = new TaskCompletionSource(); Interop.Connection.ConnectionCallback Callback = (ConnectionError Result, IntPtr Data) => { @@ -791,4 +725,4 @@ namespace Tizen.Network.Connection return task.Task; } } -} +} \ No newline at end of file diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionManager.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionManager.cs index 256f352..4b1c65b 100755 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionManager.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionManager.cs @@ -141,50 +141,19 @@ namespace Tizen.Network.Connection /// Gets the IP address of the current connection. /// /// The address family - /// IP address of the connection (global address in case of IPv6). - /// http://tizen.org/privilege/network.get - /// 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 - /// Thrown when feature is not supported. - /// Thrown when permission is denied. - /// Thrown when value is invalid parameter. - /// Thrown when memory is not enough to continue execution. - /// Thrown when connection instance is invalid or when method failed due to invalid operation. - public static System.Net.IPAddress GetIPAddress(AddressFamily family) + /// IP address of the connection. + /// Thrown when method failed due to invalid operation + public static string GetIPAddress(AddressFamily family) { return ConnectionInternalManager.Instance.GetIPAddress(family); } /// - /// Gets the all IPv6 addresses of the current connection. - /// - /// The type of current network connection - /// A list of IPv6 addresses of the connection. - /// http://tizen.org/privilege/network.get - /// 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 - /// Thrown when feature is not supported. - /// Thrown when permission is denied. - /// Thrown when value is invalid parameter. - /// Thrown when memory is not enough to continue execution. - /// Thrown when connection instance is invalid or when method failed due to invalid operation. - public static IEnumerable GetAllIPv6Addresses(ConnectionType type) - { - return ConnectionInternalManager.Instance.GetAllIPv6Addresses(type); - } - - /// /// Gets the proxy address of the current connection. /// /// The address family /// Proxy address of the connection. - /// Thrown when feature is not supported. - /// Thrown when value is invalid parameter. - /// Thrown when connection instance is invalid or when method failed due to invalid operation. + /// Thrown when method failed due to invalid operation public static string GetProxy(AddressFamily family) { return ConnectionInternalManager.Instance.GetProxy(family); @@ -195,58 +164,13 @@ namespace Tizen.Network.Connection /// /// The type of current network connection /// MAC address of the Wi-Fi or ethernet. - /// Thrown when feature is not supported. - /// Thrown when value is invalid parameter. - /// Thrown when memory is not enough to continue execution. - /// Thrown when connection instance is invalid or when method failed due to invalid operation. + /// Thrown when method failed due to invalid operation public static string GetMacAddress(ConnectionType type) { return ConnectionInternalManager.Instance.GetMacAddress(type); } /// - /// Gets the statistics information. - /// - /// The type of connection (only WiFi and Cellular are supported) - /// The type of statistics - /// The statistics information associated with statisticsType - /// http://tizen.org/privilege/network.get - /// 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 - /// Thrown when feature is not supported. - /// Thrown when permission is denied. - /// Thrown when value is invalid parameter. - /// Thrown when memory is not enough to continue execution. - /// Thrown when connection instance is invalid or when method failed due to invalid operation. - public static long GetStatistics(ConnectionType connectionType, StatisticsType statisticsType) - { - return ConnectionInternalManager.Instance.GetStatistics(connectionType, statisticsType); - } - - /// - /// Resets the statistics information. - /// - /// The type of connection (only WiFi and Cellular are supported) - /// The type of statistics - /// http://tizen.org/privilege/network.get - /// http://tizen.org/privilege/network.set - /// 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 - /// Thrown when feature is not supported. - /// Thrown when permission is denied. - /// Thrown when value is invalid parameter. - /// Thrown when memory is not enough to continue execution. - /// Thrown when connection instance is invalid or when method failed due to invalid operation. - public static void ResetStatistics(ConnectionType connectionType, StatisticsType statisticsType) - { - ConnectionInternalManager.Instance.ResetStatistics(connectionType, statisticsType); - } - - /// /// Type and state of the current profile for data connection /// public static ConnectionItem CurrentConnection @@ -268,11 +192,6 @@ namespace Tizen.Network.Connection /// The type of profile. Cellular profile type is supported. /// The keyword included in profile name. /// CellularProfile object - /// Thrown when feature is not supported. - /// Thrown when permission is denied. - /// Thrown when value is invalid parameter. - /// Thrown when keyword value is null. - /// Thrown when method failed due to invalid operation. public static CellularProfile CreateCellularProfile(ConnectionProfileType type, string keyword) { IntPtr profileHandle = IntPtr.Zero; diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs index 4512996..7e70bc9 100755 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs @@ -47,7 +47,6 @@ namespace Tizen.Network.Connection { add { - Log.Debug(Globals.LogTag, "ProfileStateChanged add"); if (_ProfileStateChanged == null) { ProfileStateChangedStart(); @@ -56,7 +55,6 @@ namespace Tizen.Network.Connection } remove { - Log.Debug(Globals.LogTag, "ProfileStateChanged remove"); _ProfileStateChanged -= value; if (_ProfileStateChanged == null) { @@ -75,7 +73,6 @@ namespace Tizen.Network.Connection } }; - Log.Debug(Globals.LogTag, "ProfileStateChangedStart"); int ret = Interop.ConnectionProfile.SetStateChangeCallback(ProfileHandle, _profileChangedCallback, IntPtr.Zero); if ((ConnectionError)ret != ConnectionError.None) { @@ -85,7 +82,6 @@ namespace Tizen.Network.Connection private void ProfileStateChangedStop() { - Log.Debug(Globals.LogTag, "ProfileStateChangedStop"); int ret = Interop.ConnectionProfile.UnsetStateChangeCallback(ProfileHandle); if ((ConnectionError)ret != ConnectionError.None) { @@ -137,15 +133,6 @@ namespace Tizen.Network.Connection private void Destroy() { Interop.ConnectionProfile.Destroy(ProfileHandle); - ProfileHandle = IntPtr.Zero; - } - - internal void CheckDisposed() - { - if (disposed) - { - throw new ObjectDisposedException(GetType().FullName); - } } /// @@ -224,42 +211,20 @@ namespace Tizen.Network.Connection } /// - /// Refreshes the profile information. + /// The profile state. /// - /// Thrown when method failed due to invalid operation - public void Refresh() + public ProfileState State { - int ret = Interop.ConnectionProfile.Refresh(ProfileHandle); - if ((ConnectionError)ret != ConnectionError.None) + get { - Log.Error(Globals.LogTag, "It failed to get network interface name, " + (ConnectionError)ret); - ConnectionErrorFactory.ThrowConnectionException(ret); - } - } - - /// - /// Get the network state. - /// - /// The address family - /// The network state. - public ProfileState GetState(AddressFamily family) - { int 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); - } - + int ret = Interop.ConnectionProfile.GetState(ProfileHandle, out Value); if ((ConnectionError)ret != ConnectionError.None) { Log.Error(Globals.LogTag, "It failed to get profile state, " + (ConnectionError)ret); } return (ProfileState)Value; + } } /// @@ -319,7 +284,7 @@ namespace Tizen.Network.Connection } /// - /// The address information (IPv4) + /// The subnet mask address(IPv4). /// public IAddressInformation IPv4Settings { @@ -331,7 +296,7 @@ namespace Tizen.Network.Connection } /// - /// The address information (IPv6) + /// The subnet mask address(IPv4). /// public IAddressInformation IPv6Settings { diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfileManager.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfileManager.cs index baa7d06..cbd2933 100755 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfileManager.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfileManager.cs @@ -36,7 +36,6 @@ namespace Tizen.Network.Connection /// Thrown when method failed due to invalid operation public static void AddCellularProfile(CellularProfile profile) { - Log.Debug(Globals.LogTag, "AddCellularProfile"); ConnectionInternalManager.Instance.AddCellularProfile(profile); } @@ -48,7 +47,6 @@ namespace Tizen.Network.Connection /// List of connection profile objects. public static Task> GetProfileListAsync(ProfileListType type) { - Log.Debug(Globals.LogTag, "GetProfileListAsync"); return ConnectionInternalManager.Instance.GetProfileListAsync(type); } @@ -62,7 +60,6 @@ namespace Tizen.Network.Connection /// Thrown when method failed due to invalid operation public static Task ConnectProfileAsync(ConnectionProfile profile) { - Log.Debug(Globals.LogTag, "ConnectProfile"); return ConnectionInternalManager.Instance.OpenProfileAsync(profile); } @@ -75,7 +72,6 @@ namespace Tizen.Network.Connection /// Thrown when method failed due to invalid operation public static Task DisconnectProfileAsync(ConnectionProfile profile) { - Log.Debug(Globals.LogTag, "DisconnectProfileAsync"); return ConnectionInternalManager.Instance.CloseProfileAsync(profile); } @@ -103,7 +99,6 @@ namespace Tizen.Network.Connection /// Thrown when method failed due to invalid operation public static void UpdateProfile(ConnectionProfile profile) { - Log.Debug(Globals.LogTag, "UpdateProfile"); ConnectionInternalManager.Instance.UpdateProfile(profile); } @@ -115,7 +110,6 @@ namespace Tizen.Network.Connection /// Thrown when method failed due to invalid operation public static ConnectionProfile GetCurrentProfile() { - Log.Debug(Globals.LogTag, "GetCurrentProfile"); return ConnectionInternalManager.Instance.GetCurrentProfile(); } @@ -128,7 +122,6 @@ namespace Tizen.Network.Connection /// Thrown when method failed due to invalid operation public static ConnectionProfile GetDefaultCellularProfile(CellularServiceType type) { - Log.Debug(Globals.LogTag, "GetDefaultCurrentProfile"); return ConnectionInternalManager.Instance.GetDefaultCellularProfile(type); } @@ -143,7 +136,6 @@ namespace Tizen.Network.Connection /// Thrown when method failed due to invalid operation public static Task SetDefaultCellularProfile(CellularServiceType type, ConnectionProfile profile) { - Log.Debug(Globals.LogTag, "SetDefaultCellularProfile"); return ConnectionInternalManager.Instance.SetDefaultCellularProfile(type, profile); } } diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionTypes.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionTypes.cs index 075967d..817128c 100755 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionTypes.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionTypes.cs @@ -41,8 +41,8 @@ namespace Tizen.Network.Connection /// public enum AddressFamily { - IPv4 = 0, /**< IPv4 Address */ - IPv6 = 1 /**< IPv6 Address */ + IPv4 = 0, + IPv6 = 1 } /// @@ -78,17 +78,6 @@ namespace Tizen.Network.Connection } /// - /// Enumeration for statistics type. - /// - public enum StatisticsType - { - LastReceivedData = 0, /**< Last received data */ - LastSentData = 1, /**< Last sent data */ - TotalReceivedData = 2, /**< Total received data */ - TotalSentData = 3, /**< Total sent data */ - } - - /// /// Enumeration for network connection type. /// public enum ConnectionProfileType @@ -146,27 +135,6 @@ namespace Tizen.Network.Connection Application = 6, /**< Specific application */ } - /// - /// Enumeration for cellular pdn type. - /// - public enum CellularPdnType - { - Unknown = 0, /**< Unknown */ - IPv4 = 1, /**< IPv4 */ - IPv6 = 2, /**< IPv6 */ - IPv4_IPv6 = 3, /**< Both IPv4 and IPv6 */ - } - - /// - /// Enumeration for DNS configuration type. - /// - 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; diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/IAddressInformation.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/IAddressInformation.cs index 2407419..b9f76aa 100755 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/IAddressInformation.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/IAddressInformation.cs @@ -32,66 +32,32 @@ namespace Tizen.Network.Connection /// /// The DNS address. /// - /// Thrown during set when feature is not supported. - /// Thrown during set when value is invalid parameter. - /// Thrown during set when profile instance is invalid or when method failed due to invalid operation. System.Net.IPAddress Dns1 { get; set; } /// /// The DNS address. /// - /// Thrown during set when feature is not supported. - /// Thrown during set when value is invalid parameter. - /// Thrown during set when profile instance is invalid or when method failed due to invalid operation. System.Net.IPAddress Dns2 { get; set; } /// /// The gateway address. /// - /// Thrown during set when feature is not supported. - /// Thrown during set when value is invalid parameter. - /// Thrown during set when profile instance is invalid or when method failed due to invalid operation. System.Net.IPAddress Gateway { get; set; } /// /// The subnet mask address. /// - /// Thrown during set when feature is not supported. - /// Thrown during set when value is invalid parameter. - /// Thrown during set when profile instance is invalid or when method failed due to invalid operation. System.Net.IPAddress SubnetMask { get; set; } /// /// The IP address. /// - /// Thrown during set when feature is not supported. - /// Thrown during set when value is invalid parameter. - /// Thrown during set when profile instance is invalid or when method failed due to invalid operation. System.Net.IPAddress IP { get; set; } /// /// The type of IP config. /// - /// Thrown during set when feature is not supported. - /// Thrown during set when value is invalid parameter. - /// Thrown during set when profile instance is invalid or when method failed due to invalid operation. IPConfigType IPConfigType { get; set; } - - /// - /// The prefix length. - /// - /// Thrown during set when feature is not supported. - /// Thrown during set when value is invalid parameter. - /// Thrown during set when profile instance is invalid or when method failed due to invalid operation. - int PrefixLength { get; set; } - - /// - /// The DNS config type. - /// - /// Thrown during set when feature is not supported. - /// Thrown during set when value is invalid parameter. - /// Thrown during set when profile instance is invalid or when method failed due to invalid operation. - DnsConfigType DnsConfigType { get; set; } } internal class ConnectionAddressInformation : IAddressInformation @@ -114,6 +80,7 @@ namespace Tizen.Network.Connection if ((ConnectionError)ret != ConnectionError.None) { Log.Error(Globals.LogTag, "It failed to get dns1 address, " + (ConnectionError)ret); + ConnectionErrorFactory.ThrowConnectionException(ret); } string result = Marshal.PtrToStringAnsi(Value); Interop.Libc.Free(Value); @@ -121,7 +88,6 @@ namespace Tizen.Network.Connection return System.Net.IPAddress.Parse("0.0.0.0"); return System.Net.IPAddress.Parse(result); } - set { int ret = Interop.ConnectionProfile.SetDnsAddress(_profileHandle, (int)_family, value.ToString()); @@ -269,57 +235,5 @@ 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); - } - } - } } } -- 2.7.4