From: shikha.ta Date: Wed, 8 Feb 2017 07:53:14 +0000 (+0530) Subject: [Connection]Fixed profile classes, callback and doxygen X-Git-Tag: submit/trunk/20170823.075128~116^2~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dc0f27f357163f89fbd8a9574fe01720d6a5dab2;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [Connection]Fixed profile classes, callback and doxygen Change-Id: If40a200090563c62b135efd1f579be76b98fcfb6 Signed-off-by: shikha.ta --- diff --git a/packaging/csapi-network-connection.spec b/packaging/csapi-network-connection.spec index 42730fa..7ce0f5c 100644 --- 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.6 +Version: 1.0.7 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 9ca98e5..713d30c 100755 --- a/src/Tizen.Network.Connection/Interop/Interop.Connection.cs +++ b/src/Tizen.Network.Connection/Interop/Interop.Connection.cs @@ -130,7 +130,8 @@ internal static partial class Interop internal static partial class ConnectionProfile { - public delegate void profile_state_changed_cb(ProfileState type, IntPtr userData); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void ProfileStateChangedCallback(ProfileState type, IntPtr userData); [DllImport(Libraries.Connection, EntryPoint = "connection_profile_create")] public static extern int Create(int ProfileType, string Keyword, out IntPtr profileHandle); @@ -199,7 +200,7 @@ internal static partial class Interop public static extern int SetProxyAddress(IntPtr profileHandle, int family, string address); [DllImport(Libraries.Connection, EntryPoint = "connection_profile_set_state_changed_cb")] - public static extern int SetStateChangeCallback(IntPtr profileHandle, profile_state_changed_cb callback, IntPtr userData); + public static extern int SetStateChangeCallback(IntPtr profileHandle, ProfileStateChangedCallback callback, IntPtr userData); [DllImport(Libraries.Connection, EntryPoint = "connection_profile_unset_state_changed_cb")] public static extern int UnsetStateChangeCallback(IntPtr profileHandle); diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection.Net45.csproj b/src/Tizen.Network.Connection/Tizen.Network.Connection.Net45.csproj old mode 100644 new mode 100755 index 7f2ed68..af6d291 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection.Net45.csproj +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection.Net45.csproj @@ -56,9 +56,6 @@ - - - diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection.csproj b/src/Tizen.Network.Connection/Tizen.Network.Connection.csproj old mode 100644 new mode 100755 index f1a1f9a..dfbb11c --- a/src/Tizen.Network.Connection/Tizen.Network.Connection.csproj +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection.csproj @@ -1,4 +1,4 @@ - + Debug @@ -53,9 +53,6 @@ - - - diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/CellularProfile.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/CellularProfile.cs old mode 100644 new mode 100755 index d6c9c12..628cc33 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/CellularProfile.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/CellularProfile.cs @@ -23,7 +23,7 @@ using System.Runtime.InteropServices; namespace Tizen.Network.Connection { /// - /// This Class is CellularProfile + /// This Class is CellularProfile. It provides functions to manage the cellular profile. /// public class CellularProfile : ConnectionProfile { @@ -39,7 +39,7 @@ namespace Tizen.Network.Connection } /// - /// Gets the APN (access point name). + /// The APN (access point name). /// public string Apn { @@ -67,7 +67,7 @@ namespace Tizen.Network.Connection } /// - /// Gets the home URL. + /// The home URL. /// public string HomeUri { @@ -96,7 +96,7 @@ namespace Tizen.Network.Connection } /// - /// Gets the service type. + /// The service type. /// public CellularServiceType ServiceType { @@ -185,7 +185,7 @@ namespace Tizen.Network.Connection } /// - /// The authentication information. + /// This Class is CellularAuthInformation. It provides the properties to get and set the cellular authentication information. /// public class CellularAuthInformation { diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs index 4dd5710..ba622b0 100755 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs @@ -295,7 +295,7 @@ namespace Tizen.Network.Connection } } - public event EventHandler ProxyAddressChanged + internal event EventHandler ProxyAddressChanged { add { @@ -390,7 +390,7 @@ namespace Tizen.Network.Connection return Interop.Connection.DestroyProfileIterator(iterator); } - public string GetIpAddress(AddressFamily family) + internal string GetIpAddress(AddressFamily family) { IntPtr ip; int ret = Interop.Connection.GetIpAddress(GetHandle(), (int)family, out ip); @@ -404,7 +404,7 @@ namespace Tizen.Network.Connection return result; } - public string GetProxy(AddressFamily family) + internal string GetProxy(AddressFamily family) { IntPtr ip; int ret = Interop.Connection.GetProxy(GetHandle(), (int)family, out ip); @@ -418,7 +418,7 @@ namespace Tizen.Network.Connection return result; } - public string GetMacAddress(ConnectionType type) + internal string GetMacAddress(ConnectionType type) { IntPtr ip; int ret = Interop.Connection.GetMacAddress(GetHandle(), (int)type, out ip); @@ -432,7 +432,7 @@ namespace Tizen.Network.Connection return result; } - public ConnectionType ConnectionType + internal ConnectionType ConnectionType { get { @@ -448,7 +448,7 @@ namespace Tizen.Network.Connection } } - public CellularState CellularState + internal CellularState CellularState { get { @@ -464,7 +464,7 @@ namespace Tizen.Network.Connection } } - public ConnectionState WiFiState + internal ConnectionState WiFiState { get { @@ -479,7 +479,7 @@ namespace Tizen.Network.Connection } } - public ConnectionState BluetoothState + internal ConnectionState BluetoothState { get { @@ -494,7 +494,7 @@ namespace Tizen.Network.Connection } } - public ConnectionState EthernetState + internal ConnectionState EthernetState { get { @@ -509,7 +509,7 @@ namespace Tizen.Network.Connection } } - public EthernetCableState EthernetCableState + internal EthernetCableState EthernetCableState { get { @@ -524,9 +524,16 @@ namespace Tizen.Network.Connection } } - static public IntPtr CreateRequestProfile(ConnectionProfileType type, string keyword) + internal IntPtr CreateCellularProfile(ConnectionProfileType type, string keyword) { - Log.Error(Globals.LogTag, "CreateRequestProfile, " + type + ", " + keyword); + Log.Error(Globals.LogTag, "CreateCellularProfile, " + type + ", " + keyword); + IntPtr connectionHandle = GetHandle(); + if (connectionHandle == IntPtr.Zero) + { + Log.Error(Globals.LogTag, "It failed to create connection handle"); + throw new InvalidOperationException("Invalid connection handle"); + } + IntPtr handle = IntPtr.Zero; int ret = Interop.ConnectionProfile.Create((int)type, keyword, out handle); if ((ConnectionError)ret != ConnectionError.None) @@ -538,31 +545,27 @@ namespace Tizen.Network.Connection return handle; } - public int AddProfile(RequestProfile profile) + internal int AddCellularProfile(CellularProfile profile) { - int ret = 0; + int ret = -1; if (profile.Type == ConnectionProfileType.Cellular) { - ret = Interop.Connection.AddProfile(GetHandle(), ((RequestCellularProfile)profile).ProfileHandle); + ret = Interop.Connection.AddProfile(GetHandle(), profile.ProfileHandle); if ((ConnectionError)ret != ConnectionError.None) { - Log.Error(Globals.LogTag, "It failed to add profile, " + (ConnectionError)ret); + Log.Error(Globals.LogTag, "Failed to add cellular profile, " + (ConnectionError)ret); ConnectionErrorFactory.ThrowConnectionException(ret); } + return ret; } - else if (profile.Type == ConnectionProfileType.WiFi) + + else { - ret = Interop.Connection.AddProfile(GetHandle(), ((RequestWiFiProfile)profile).ProfileHandle); - if ((ConnectionError)ret != ConnectionError.None) - { - Log.Error(Globals.LogTag, "It failed to add profile, " + (ConnectionError)ret); - ConnectionErrorFactory.ThrowConnectionException(ret); - } + throw new InvalidOperationException("Profile type is not cellular"); } - return ret; } - public int RemoveProfile(ConnectionProfile profile) + internal int RemoveProfile(ConnectionProfile profile) { int ret = Interop.Connection.RemoveProfile(GetHandle(), profile.ProfileHandle); if ((ConnectionError)ret != ConnectionError.None) @@ -573,7 +576,7 @@ namespace Tizen.Network.Connection return ret; } - public int UpdateProfile(ConnectionProfile profile) + internal int UpdateProfile(ConnectionProfile profile) { int ret = Interop.Connection.UpdateProfile(GetHandle(), profile.ProfileHandle); if ((ConnectionError)ret != ConnectionError.None) @@ -584,7 +587,7 @@ namespace Tizen.Network.Connection return ret; } - public ConnectionProfile GetCurrentProfile() + internal ConnectionProfile GetCurrentProfile() { IntPtr ProfileHandle; int ret = Interop.Connection.GetCurrentProfile(GetHandle(), out ProfileHandle); @@ -597,7 +600,7 @@ namespace Tizen.Network.Connection return Profile; } - public ConnectionProfile GetDefaultCellularProfile(CellularServiceType type) + internal ConnectionProfile GetDefaultCellularProfile(CellularServiceType type) { IntPtr ProfileHandle; int ret = Interop.Connection.GetDefaultCellularServiceProfile(GetHandle(), (int)type, out ProfileHandle); @@ -611,7 +614,7 @@ namespace Tizen.Network.Connection return Profile; } - public Task SetDefaultCellularProfile(CellularServiceType type, ConnectionProfile profile) + internal Task SetDefaultCellularProfile(CellularServiceType type, ConnectionProfile profile) { var task = new TaskCompletionSource(); Interop.Connection.ConnectionCallback Callback = (ConnectionError Result, IntPtr Data) => @@ -629,7 +632,7 @@ namespace Tizen.Network.Connection } - public Task> GetProfileListAsync(ProfileListType type) + internal Task> GetProfileListAsync(ProfileListType type) { var task = new TaskCompletionSource>(); @@ -671,7 +674,7 @@ namespace Tizen.Network.Connection return task.Task; } - public Task OpenProfileAsync(ConnectionProfile profile) + internal Task OpenProfileAsync(ConnectionProfile profile) { var task = new TaskCompletionSource(); Interop.Connection.ConnectionCallback Callback = (ConnectionError Result, IntPtr Data) => @@ -688,7 +691,7 @@ namespace Tizen.Network.Connection return task.Task; } - public Task CloseProfileAsync(ConnectionProfile profile) + internal Task CloseProfileAsync(ConnectionProfile profile) { var task = new TaskCompletionSource(); Interop.Connection.ConnectionCallback Callback = (ConnectionError Result, IntPtr Data) => diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionManager.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionManager.cs index e73c0ca..0bb2ce8 100755 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionManager.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionManager.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); @@ -27,9 +27,9 @@ using System.Runtime.InteropServices; namespace Tizen.Network.Connection { /// - /// This class is ConnectionManager + /// This class is ConnectionManager. It provides functions to manage data connections. /// - public static partial class ConnectionManager + public static class ConnectionManager { private static ConnectionItem _currentConnection = null; @@ -100,6 +100,8 @@ namespace Tizen.Network.Connection /// /// Gets the IP address of the current connection. /// + /// The address family + /// IP address of the connection. /// Thrown when method failed due to invalid operation public static string GetIpAddress(AddressFamily family) { @@ -109,6 +111,8 @@ namespace Tizen.Network.Connection /// /// Gets the proxy address of the current connection. /// + /// The address family + /// Proxy address of the connection. /// Thrown when method failed due to invalid operation public static string GetProxy(AddressFamily family) { @@ -118,6 +122,8 @@ namespace Tizen.Network.Connection /// /// Gets the MAC address of the Wi-Fi or ethernet. /// + /// The type of current network connection + /// MAC address of the Wi-Fi or ethernet. /// Thrown when method failed due to invalid operation public static string GetMacAddress(ConnectionType type) { @@ -125,7 +131,7 @@ namespace Tizen.Network.Connection } /// - /// Gets type and state of the current profile for data connection + /// Type and state of the current profile for data connection /// public static ConnectionItem CurrentConnection { @@ -140,27 +146,31 @@ namespace Tizen.Network.Connection } } - public static RequestProfile CreateRequestProfile(ConnectionProfileType type, string keyword) + /// + /// Creates a cellular profile handle. + /// + /// The type of profile. Cellular profile type is supported. + /// The keyword included in profile name. + /// CellularProfile object + public static CellularProfile CreateCellularProfile(ConnectionProfileType type, string keyword) { - IntPtr ProfileHandle = ConnectionInternalManager.CreateRequestProfile(type, keyword); - if (type == ConnectionProfileType.WiFi) - { - return new RequestWiFiProfile(ProfileHandle); - } - else if (type == ConnectionProfileType.Cellular) + IntPtr profileHandle = IntPtr.Zero; + if (type == ConnectionProfileType.Cellular) { - return new RequestCellularProfile(ProfileHandle); + profileHandle = ConnectionInternalManager.Instance.CreateCellularProfile(type, keyword); } + else { - Log.Error(Globals.LogTag, "Nut supported profile type"); + Log.Error(Globals.LogTag, "ConnectionProfile Type is not supported"); ConnectionErrorFactory.ThrowConnectionException((int)ConnectionError.InvalidParameter); } - return null; + + return new CellularProfile(profileHandle); } /// - /// Gets the state of cellular connection. + /// The state of cellular connection. /// public static CellularState CellularState { @@ -171,7 +181,7 @@ namespace Tizen.Network.Connection } /// - /// Gets the state of the Wi-Fi. + /// The state of the Wi-Fi. /// /// http://tizen.org/privilege/network.get public static ConnectionState WiFiState @@ -221,7 +231,7 @@ namespace Tizen.Network.Connection } // class ConnectionManager /// - /// class which contains connection information such as connection type and state + /// This class contains connection information such as connection type and state. /// public class ConnectionItem { @@ -230,7 +240,7 @@ namespace Tizen.Network.Connection } /// - /// Gets the type of the current profile for data connection. + /// The type of the current profile for data connection. /// public ConnectionType Type { @@ -241,7 +251,7 @@ namespace Tizen.Network.Connection } /// - /// Gets the state of the current profile for data connection. + /// The state of the current profile for data connection. /// public ConnectionState State { diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs old mode 100644 new mode 100755 index f91affe..3f474d2 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); @@ -23,7 +23,7 @@ using System.Runtime.InteropServices; namespace Tizen.Network.Connection { /// - /// This Class is ConnectionProfile + /// This Class is ConnectionProfile. It provides event and propeties of the connection profile. /// public class ConnectionProfile : IDisposable { @@ -31,7 +31,9 @@ namespace Tizen.Network.Connection private IAddressInformation Ipv4; private IAddressInformation Ipv6; private bool disposed = false; - private EventHandler _ProfileStateChanged; + private EventHandler _ProfileStateChanged = null; + + private Interop.ConnectionProfile.ProfileStateChangedCallback _profileChangedCallback; internal IntPtr GetHandle() { @@ -61,17 +63,17 @@ namespace Tizen.Network.Connection } } - private void TypeChangedCallback(ProfileState state, IntPtr userData) + private void ProfileStateChangedStart() { - if (_ProfileStateChanged != null) + _profileChangedCallback = (ProfileState state, IntPtr userData) => { - _ProfileStateChanged(null, new ProfileStateEventArgs(state)); - } - } + if (_ProfileStateChanged != null) + { + _ProfileStateChanged(null, new ProfileStateEventArgs(state)); + } + }; - private void ProfileStateChangedStart() - { - int ret = Interop.ConnectionProfile.SetStateChangeCallback(ProfileHandle, TypeChangedCallback, IntPtr.Zero); + int ret = Interop.ConnectionProfile.SetStateChangeCallback(ProfileHandle, _profileChangedCallback, IntPtr.Zero); if ((ConnectionError)ret != ConnectionError.None) { Log.Error(Globals.LogTag, "It failed to register callback for changing profile state, " + (ConnectionError)ret); @@ -134,7 +136,7 @@ namespace Tizen.Network.Connection } /// - /// Gets the profile ID. + /// The profile ID. /// public string Id { @@ -153,7 +155,7 @@ namespace Tizen.Network.Connection } /// - /// Gets the profile name. + /// The profile name. /// /// http://tizen.org/privilege/network.get public string Name @@ -173,7 +175,7 @@ namespace Tizen.Network.Connection } /// - /// Gets the network type. + /// The network type. /// public ConnectionProfileType Type { @@ -190,7 +192,7 @@ namespace Tizen.Network.Connection } /// - /// Gets the name of the network interface, e.g. eth0 and pdp0. + /// The name of the network interface, e.g. eth0 and pdp0. /// public string InterfaceName { @@ -209,7 +211,7 @@ namespace Tizen.Network.Connection } /// - /// Gets the profile state. + /// The profile state. /// public ProfileState State { @@ -226,7 +228,7 @@ namespace Tizen.Network.Connection } /// - /// Gets the Proxy type. + /// The Proxy type. /// public ProxyType ProxyType { diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfileManager.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfileManager.cs index 8e8bc37..78692ff 100755 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfileManager.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfileManager.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); @@ -24,24 +24,28 @@ using System.Collections; namespace Tizen.Network.Connection { /// - /// This class is ConnectionManager + /// This class is ConnectionProfileManager. It provides functions to add, get, connect or modify the connection profile. /// - public static partial class ConnectionManager + public static class ConnectionProfileManager { /// /// Adds a new profile /// /// http://tizen.org/privilege/network.profile + /// The cellular profile object + /// 0 on success, else exception is thrown. /// Thrown when method failed due to invalid operation - public static int AddProfile(RequestProfile profile) + public static int AddCellularProfile(CellularProfile profile) { - return ConnectionInternalManager.Instance.AddProfile(profile); + return ConnectionInternalManager.Instance.AddCellularProfile(profile); } /// /// Gets the list of profile with profile list type /// /// http://tizen.org/privilege/network.get + /// The type of profile + /// List of connection profile objects. public static Task> GetProfileListAsync(ProfileListType type) { return ConnectionInternalManager.Instance.GetProfileListAsync(type); @@ -52,6 +56,8 @@ namespace Tizen.Network.Connection /// /// http://tizen.org/privilege/network.get /// http://tizen.org/privilege/network.set + /// The connection profile object + /// A task indicates whether the ConnectProfileAsync method is done successfully or not. public static Task ConnectProfileAsync(ConnectionProfile profile) { return ConnectionInternalManager.Instance.OpenProfileAsync(profile); @@ -61,6 +67,8 @@ namespace Tizen.Network.Connection /// Closes a connection of profile. /// /// http://tizen.org/privilege/network.set + /// The connection profile object + /// A task indicates whether the DisconnectProfileAsync method is done successfully or not. public static Task DisconnectProfileAsync(ConnectionProfile profile) { return ConnectionInternalManager.Instance.CloseProfileAsync(profile); @@ -71,6 +79,8 @@ namespace Tizen.Network.Connection /// /// http://tizen.org/privilege/network.get /// http://tizen.org/privilege/network.profile + /// The connection profile object + /// 0 on success, else exception is thrown. /// Thrown when method failed due to invalid operation public static int RemoveProfile(ConnectionProfile profile) { @@ -85,6 +95,8 @@ namespace Tizen.Network.Connection /// /// http://tizen.org/privilege/network.get /// http://tizen.org/privilege/network.profile + /// The connection profile object + /// 0 on success, else exception is thrown. /// Thrown when method failed due to invalid operation public static int UpdateProfile(ConnectionProfile profile) { @@ -95,6 +107,7 @@ namespace Tizen.Network.Connection /// Gets the name of the default profile. /// /// http://tizen.org/privilege/network.get + /// Connection profile object. /// Thrown when method failed due to invalid operation public static ConnectionProfile GetCurrentProfile() { @@ -105,6 +118,8 @@ namespace Tizen.Network.Connection /// Gets the default profile which provides the given cellular service. /// /// http://tizen.org/privilege/network.get + /// The cellular service type + /// Connection profile object. /// Thrown when method failed due to invalid operation public static ConnectionProfile GetDefaultCellularProfile(CellularServiceType type) { @@ -116,6 +131,9 @@ namespace Tizen.Network.Connection /// /// http://tizen.org/privilege/network.get /// http://tizen.org/privilege/network.profile + /// The cellular service type + /// The connection profile object + /// A task indicates whether the SetDefaultCellularProfile method is done successfully or not. /// Thrown when method failed due to invalid operation public static Task SetDefaultCellularProfile(CellularServiceType type, ConnectionProfile profile) { diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/IAddressInformation.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/IAddressInformation.cs old mode 100644 new mode 100755 index f409699..51b9590 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/IAddressInformation.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/IAddressInformation.cs @@ -25,7 +25,7 @@ using System.Runtime.InteropServices; namespace Tizen.Network.Connection { /// - /// This Class is ConnectionAddress + /// This interface provides properties to manage address information of the connection. /// public interface IAddressInformation : IDisposable { diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/RequestCellularProfile.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/RequestCellularProfile.cs deleted file mode 100644 index 3670e8b..0000000 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/RequestCellularProfile.cs +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Runtime.InteropServices; - - -namespace Tizen.Network.Connection -{ - /// - /// This Class is RequestCellularProfile. - /// CellularServiceType should be set before AddProfile method of ConnectionProfileManager is called. - /// - public class RequestCellularProfile : RequestProfile - { - internal IntPtr ProfileHandle = IntPtr.Zero; - private IAddressInformation Ipv4; - private IAddressInformation Ipv6; - private bool disposed = false; - - private CellularAuthInformation AuthInfo; - /// - /// The constructor of CellularProfile class with profile type and keyword. - /// - /// http://tizen.org/privilege/network.get - internal RequestCellularProfile(IntPtr handle) - { - Log.Debug(Globals.LogTag, "RequestCellularProfile is created : " + handle); - - ProfileHandle = handle; - Ipv4 = new ConnectionAddressInformation(ProfileHandle, AddressFamily.Ipv4); - Ipv6 = new ConnectionAddressInformation(ProfileHandle, AddressFamily.Ipv6); - AuthInfo = new CellularAuthInformation(ProfileHandle); - } - - /// - /// The destructor of CellularProfile class - /// - ~RequestCellularProfile() - { - Dispose(false); - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - private void Dispose(bool disposing) - { - Log.Debug(Globals.LogTag, ">>> RequestCellularProfile Dispose with " + disposing); - if (disposed) - return; - - if (disposing) - { - // Free managed objects. - Destroy(); - } - disposed = true; - } - - private void Destroy() - { - Interop.ConnectionProfile.Destroy(ProfileHandle); - } - - /// - /// Gets the network type. - /// - public ConnectionProfileType Type - { - get - { - int Value; - int ret = Interop.ConnectionProfile.GetType(ProfileHandle, out Value); - if ((ConnectionError)ret != ConnectionError.None) - { - Log.Error(Globals.LogTag, "It failed to get profile type, " + (ConnectionError)ret); - } - return (ConnectionProfileType)Value; - } - } - - /// - /// Gets the Proxy type. - /// - public ProxyType ProxyType - { - get - { - int Value; - int ret = Interop.ConnectionProfile.GetProxyType(ProfileHandle, out Value); - if ((ConnectionError)ret != ConnectionError.None) - { - Log.Error(Globals.LogTag, "It failed to get proxy type, " + (ConnectionError)ret); - } - return (ProxyType)Value; - - } - set - { - int ret = Interop.ConnectionProfile.SetProxyType(ProfileHandle, (int)value); - if ((ConnectionError)ret != ConnectionError.None) - { - Log.Error(Globals.LogTag, "It failed to set proxy type, " + (ConnectionError)ret); - ConnectionErrorFactory.ThrowConnectionException(ret); - } - } - } - - /// - /// The proxy address. - /// - public System.Net.IPAddress ProxyAddress - { - get - { - IntPtr Value; - int ret = Interop.ConnectionProfile.GetProxyAddress(ProfileHandle, (int)AddressFamily.Ipv4, out Value); - if ((ConnectionError)ret != ConnectionError.None) - { - Log.Error(Globals.LogTag, "It failed to get proxy address, " + (ConnectionError)ret); - } - string result = Marshal.PtrToStringAnsi(Value); - Interop.Libc.Free(Value); - if (result == null) - return System.Net.IPAddress.Parse("0.0.0.0"); - return System.Net.IPAddress.Parse(result); - - } - set - { - int ret = Interop.ConnectionProfile.SetProxyAddress(ProfileHandle, (int)AddressFamily.Ipv4, value.ToString()); - if ((ConnectionError)ret != ConnectionError.None) - { - Log.Error(Globals.LogTag, "It failed to set proxy address, " + (ConnectionError)ret); - ConnectionErrorFactory.ThrowConnectionException(ret); - } - } - - } - - /// - /// The subnet mask address(Ipv4). - /// - public IAddressInformation Ipv4Settings - { - get - { - return Ipv4; - } - } - - - /// - /// The subnet mask address(Ipv4). - /// - public IAddressInformation Ipv6Settings - { - get - { - return Ipv6; - } - } - - /// - /// Gets the APN (access point name). - /// - public string Apn - { - get - { - IntPtr Value; - int ret = Interop.ConnectionCellularProfile.GetApn(ProfileHandle, out Value); - if ((ConnectionError)ret != ConnectionError.None) - { - Log.Error(Globals.LogTag, "It failed to get apn, " + (ConnectionError)ret); - } - string result = Marshal.PtrToStringAnsi(Value); - Interop.Libc.Free(Value); - return result; - } - set - { - int ret = Interop.ConnectionCellularProfile.SetApn(ProfileHandle, (string)value); - if ((ConnectionError)ret != ConnectionError.None) - { - Log.Error(Globals.LogTag, "It failed to set apn, " + (ConnectionError)ret); - ConnectionErrorFactory.ThrowConnectionException(ret); - } - } - } - - /// - /// Gets the home URL. - /// - public string HomeUri - { - get - { - IntPtr Value; - int ret = Interop.ConnectionCellularProfile.GetHomeUrl(ProfileHandle, out Value); - if ((ConnectionError)ret != ConnectionError.None) - { - Log.Error(Globals.LogTag, "It failed to get home uri, " + (ConnectionError)ret); - } - string result = Marshal.PtrToStringAnsi(Value); - Interop.Libc.Free(Value); - return result; - } - set - { - int ret = Interop.ConnectionCellularProfile.SetHomeUrl(ProfileHandle, value); - Log.Error(Globals.LogTag, "home uri " + value); - if ((ConnectionError)ret != ConnectionError.None) - { - Log.Error(Globals.LogTag, "It failed to set home uri, " + (ConnectionError)ret); - ConnectionErrorFactory.ThrowConnectionException(ret); - } - } - } - - /// - /// Gets the service type. - /// - public CellularServiceType ServiceType - { - get - { - int value; - int ret = Interop.ConnectionCellularProfile.GetServiceType(ProfileHandle, out value); - if ((ConnectionError)ret != ConnectionError.None) - { - Log.Error(Globals.LogTag, "It failed to get service type, " + (ConnectionError)ret); - } - return (CellularServiceType)value; - } - set - { - int ret = Interop.ConnectionCellularProfile.SetServiceType(ProfileHandle, (int)value); - if ((ConnectionError)ret != ConnectionError.None) - { - Log.Error(Globals.LogTag, "It failed to set service type, " + (ConnectionError)ret); - ConnectionErrorFactory.ThrowConnectionException(ret); - } - } - } - - /// - /// Gets cellular Authentification Information. - /// - public CellularAuthInformation CellularAuthInfo - { - get - { - return AuthInfo; - } - } - } -} diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/RequestProfile.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/RequestProfile.cs deleted file mode 100644 index 80c69829..0000000 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/RequestProfile.cs +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Runtime.InteropServices; - -namespace Tizen.Network.Connection -{ - /// - /// RequestProfile is interface for RequestCellularProfile and RequestWiFiProfile - /// - public interface RequestProfile : IDisposable - { - /// - /// Gets the network type. - /// - ConnectionProfileType Type{ get; } - - /// - /// Gets the Proxy type. - /// - ProxyType ProxyType { get; set; } - - /// - /// The proxy address. - /// - System.Net.IPAddress ProxyAddress { get; set; } - - /// - /// The subnet mask address(Ipv4). - /// - IAddressInformation Ipv4Settings { get; } - - /// - /// The subnet mask address(Ipv4). - /// - IAddressInformation Ipv6Settings { get; } - } -} diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/RequestWiFiProfile.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/RequestWiFiProfile.cs deleted file mode 100644 index 055d7c1..0000000 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/RequestWiFiProfile.cs +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Runtime.InteropServices; - -namespace Tizen.Network.Connection -{ - /// - /// This Class is RequestWiFiProfile - /// - public class RequestWiFiProfile : RequestProfile - { - internal IntPtr ProfileHandle = IntPtr.Zero; - private IAddressInformation Ipv4; - private IAddressInformation Ipv6; - private bool disposed = false; - - /// - /// The constructor of WiFiProfile class with profile type and keyword. - /// - /// http://tizen.org/privilege/network.get - internal RequestWiFiProfile(IntPtr handle) - { - Log.Debug(Globals.LogTag, "RequestWiFiProfile is created : " + handle); - - ProfileHandle = handle; - Ipv4 = new ConnectionAddressInformation(ProfileHandle, AddressFamily.Ipv4); - Ipv6 = new ConnectionAddressInformation(ProfileHandle, AddressFamily.Ipv6); - } - - /// - /// The destructor of WiFiProfile class - /// - ~RequestWiFiProfile() - { - Dispose(false); - } - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - private void Dispose(bool disposing) - { - Log.Debug(Globals.LogTag, ">>> RequestWiFiProfile Dispose with " + disposing); - if (disposed) - return; - - if (disposing) - { - // Free managed objects. - Destroy(); - } - disposed = true; - } - - private void Destroy() - { - Interop.ConnectionProfile.Destroy(ProfileHandle); - } - - /// - /// Gets the network type. - /// - public ConnectionProfileType Type - { - get - { - int Value; - int ret = Interop.ConnectionProfile.GetType(ProfileHandle, out Value); - if ((ConnectionError)ret != ConnectionError.None) - { - Log.Error(Globals.LogTag, "It failed to get profile type, " + (ConnectionError)ret); - } - return (ConnectionProfileType)Value; - } - } - - /// - /// Gets the Proxy type. - /// - public ProxyType ProxyType - { - get - { - int Value; - int ret = Interop.ConnectionProfile.GetProxyType(ProfileHandle, out Value); - if ((ConnectionError)ret != ConnectionError.None) - { - Log.Error(Globals.LogTag, "It failed to get proxy type, " + (ConnectionError)ret); - } - return (ProxyType)Value; - - } - set - { - int ret = Interop.ConnectionProfile.SetProxyType(ProfileHandle, (int)value); - if ((ConnectionError)ret != ConnectionError.None) - { - Log.Error(Globals.LogTag, "It failed to set proxy type, " + (ConnectionError)ret); - ConnectionErrorFactory.ThrowConnectionException(ret); - } - } - } - - /// - /// The proxy address. - /// - public System.Net.IPAddress ProxyAddress - { - get - { - IntPtr Value; - int ret = Interop.ConnectionProfile.GetProxyAddress(ProfileHandle, (int)AddressFamily.Ipv4, out Value); - if ((ConnectionError)ret != ConnectionError.None) - { - Log.Error(Globals.LogTag, "It failed to get proxy address, " + (ConnectionError)ret); - } - string result = Marshal.PtrToStringAnsi(Value); - Interop.Libc.Free(Value); - if (result == null) - return System.Net.IPAddress.Parse("0.0.0.0"); - return System.Net.IPAddress.Parse(result); - - } - set - { - int ret = Interop.ConnectionProfile.SetProxyAddress(ProfileHandle, (int)AddressFamily.Ipv4, value.ToString()); - if ((ConnectionError)ret != ConnectionError.None) - { - Log.Error(Globals.LogTag, "It failed to set proxy address, " + (ConnectionError)ret); - ConnectionErrorFactory.ThrowConnectionException(ret); - } - } - } - - /// - /// The subnet mask address(Ipv4). - /// - public IAddressInformation Ipv4Settings - { - get - { - return Ipv4; - - } - } - - /// - /// The subnet mask address(Ipv4). - /// - public IAddressInformation Ipv6Settings - { - get - { - return Ipv6; - - } - } - - /// - /// Sets the passphrase of the Wi-Fi WPA. - /// - public int SetPassphrase(string passphrase) - { - int ret = Interop.ConnectionWiFiProfile.SetPassphrase(ProfileHandle, (string)passphrase); - if ((ConnectionError)ret != ConnectionError.None) - { - Log.Error(Globals.LogTag, "It failed to set passphrase, " + (ConnectionError)ret); - ConnectionErrorFactory.ThrowConnectionException(ret); - } - return ret; - } - } -} diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/WiFiProfile.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/WiFiProfile.cs old mode 100644 new mode 100755 index 9b08cf0..425b893 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/WiFiProfile.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/WiFiProfile.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); @@ -23,7 +23,7 @@ using System.Runtime.InteropServices; namespace Tizen.Network.Connection { /// - /// This Class is WiFiProfile + /// This Class is WiFiProfile. It provides functions to manage the WiFi profile. /// public class WiFiProfile : ConnectionProfile { @@ -36,7 +36,7 @@ namespace Tizen.Network.Connection } /// - /// Gets the ESSID (Extended Service Set Identifier). + /// The ESSID (Extended Service Set Identifier). /// public string Essid { @@ -55,7 +55,7 @@ namespace Tizen.Network.Connection } /// - /// Gets the BSSID (Basic Service Set Identifier). + /// The BSSID (Basic Service Set Identifier). /// public string Bssid { @@ -74,7 +74,7 @@ namespace Tizen.Network.Connection } /// - /// Gets the RSSI. + /// The RSSI. /// public int Rssi { @@ -91,7 +91,7 @@ namespace Tizen.Network.Connection } /// - /// Gets the frequency (MHz). + /// The frequency (MHz). /// public int Frequency { @@ -108,7 +108,7 @@ namespace Tizen.Network.Connection } /// - /// Gets the max speed (Mbps). + /// The max speed (Mbps). /// public int MaxSpeed { @@ -125,7 +125,7 @@ namespace Tizen.Network.Connection } /// - /// Gets the security type of Wi-Fi. + /// The security type of Wi-Fi. /// public WiFiSecureType SecureType { @@ -142,7 +142,7 @@ namespace Tizen.Network.Connection } /// - /// Gets the encryption type of Wi-Fi. + /// The encryption type of Wi-Fi. /// public WiFiEncryptionType EncryptionType { @@ -195,10 +195,13 @@ namespace Tizen.Network.Connection /// /// Sets the passphrase of the Wi-Fi WPA. /// + /// The passphrase of Wi-Fi security + /// 0 on success, else exception is thrown. + /// Thrown when method failed due to invalid operation public int SetPassphrase(string passphrase) { int ret = Interop.ConnectionWiFiProfile.SetPassphrase(ProfileHandle, (string)passphrase); - if ((ConnectionError)ret != ConnectionError.NoConnection) + if ((ConnectionError)ret != ConnectionError.None) { Log.Error(Globals.LogTag, "It failed to set passphrase, " + (ConnectionError)ret); ConnectionErrorFactory.ThrowConnectionException(ret);