From: chleun.moon Date: Wed, 24 May 2017 06:06:27 +0000 (+0900) Subject: Add API reference and exception as per the guidelines X-Git-Tag: accepted/tizen/unified/20170605.150900~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F20%2F130820%2F1;p=platform%2Fcore%2Fcsapi%2Fwifi.git Add API reference and exception as per the guidelines Change-Id: Iaa7e7718402b0347c0121218a3fc8da6753c4f36 Signed-off-by: cheoleun --- diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAP.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAP.cs index 51b79d3..aa8e9cc 100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAP.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAP.cs @@ -37,6 +37,7 @@ namespace Tizen.Network.WiFi /// /// The network information of the access point(AP). /// + /// WiFiNetwork instance containing network information of AP. public WiFiNetwork NetworkInformation { get @@ -48,6 +49,7 @@ namespace Tizen.Network.WiFi /// /// The security information of the access point(AP). /// + /// WiFiSecurity instance containing security information of AP. public WiFiSecurity SecurityInformation { get @@ -67,6 +69,14 @@ namespace Tizen.Network.WiFi /// Creates an object for the access point. /// /// The Extended Service Set Identifier of the access point. + /// http://tizen.org/feature/network.wifi + /// http://tizen.org/privilege/network.get + /// Thrown when WiFi is not supported. + /// Thrown when permission is denied. + /// Thrown when Essid is passed as null. + /// Thrown when it is failed due to an invalid parameter. + /// Thrown when the system is out of memory. + /// Thrown when it is failed due to invalid operation. public WiFiAP(string essid) { Log.Debug(Globals.LogTag, "New WiFiAP. Essid: " + essid); @@ -79,6 +89,14 @@ namespace Tizen.Network.WiFi /// /// The Extended Service Set Identifier of the access point. /// The value to set hidden AP + /// http://tizen.org/feature/network.wifi + /// http://tizen.org/privilege/network.get + /// Thrown when WiFi is not supported. + /// Thrown when permission is denied. + /// Thrown when Essid is passed as null. + /// Thrown when it is failed due to an invalid parameter. + /// Thrown when the system is out of memory. + /// Thrown when it is failed due to invalid operation. public WiFiAP(string essid, bool hidden) { createHandle(essid, hidden); @@ -115,6 +133,11 @@ namespace Tizen.Network.WiFi private void createHandle(string id, bool hidden) { int ret = -1; + if (id == null) + { + throw new ArgumentNullException("Essid is null"); + } + if (hidden) { ret = Interop.WiFi.AP.CreateHiddenAP(WiFiManagerImpl.Instance.GetSafeHandle(), id, out _apHandle); @@ -128,7 +151,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to create handle, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); + WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle()); } } @@ -142,14 +165,25 @@ namespace Tizen.Network.WiFi /// /// Refreshes the access point information. /// + /// http://tizen.org/feature/network.wifi + /// http://tizen.org/privilege/network.get + /// Thrown when WiFi is not supported. + /// Thrown when permission is denied. + /// Thrown when object instance is disposed or released. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. public void Refresh() { Log.Debug(Globals.LogTag, "Refresh"); + if (_disposed) + { + throw new ObjectDisposedException("Invalid AP instance (Object may have been disposed or released)"); + } int ret = Interop.WiFi.AP.Refresh(_apHandle); if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to refresh ap handle, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret, _apHandle); + WiFiErrorFactory.ThrowWiFiException(ret, _apHandle, "http://tizen.org/privilege/network.get"); } } @@ -157,9 +191,22 @@ namespace Tizen.Network.WiFi /// Connects the access point asynchronously. /// /// A task indicating whether the Connect method is done or not. + /// http://tizen.org/feature/network.wifi + /// http://tizen.org/privilege/network.set + /// http://tizen.org/privilege/network.get + /// Thrown when WiFi is not supported. + /// Thrown when permission is denied. + /// Thrown when object instance is disposed or released. + /// Thrown when the system is out of memory. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. public Task ConnectAsync() { Log.Debug(Globals.LogTag, "ConnectAsync"); + if (_disposed) + { + throw new ObjectDisposedException("Invalid AP instance (Object may have been disposed or released)"); + } TaskCompletionSource task = new TaskCompletionSource(); IntPtr id; lock (_callback_map) @@ -180,12 +227,14 @@ namespace Tizen.Network.WiFi } }; } + int ret = Interop.WiFi.Connect(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id); if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); + WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle); } + return task.Task; } @@ -194,9 +243,24 @@ namespace Tizen.Network.WiFi /// /// A WpsInfo instance which is of type WpsPbcInfo or WpsPinInfo. /// A task indicating whether the ConnectWps method is done or not. + /// http://tizen.org/feature/network.wifi + /// http://tizen.org/privilege/network.profile + /// http://tizen.org/privilege/network.get + /// Thrown when WiFi is not supported. + /// Thrown when permission is denied. + /// Thrown when object instance is disposed or released. + /// Thrown when WpsPinInfo object is constructed with null pin. + /// Thrown when WpsPinInfo object is constructed with pin which is an empty string or more than 7 characters. + /// Thrown when the system is out of memory. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. public Task ConnectWpsAsync(WpsInfo info) { Log.Debug(Globals.LogTag, "ConnectWpsAsync"); + if (_disposed) + { + throw new ObjectDisposedException("Invalid AP instance (Object may have been disposed or released)"); + } TaskCompletionSource task = new TaskCompletionSource(); IntPtr id; lock (_callback_map) @@ -218,25 +282,32 @@ namespace Tizen.Network.WiFi }; } + int ret = -1; if (info.GetType() == typeof(WpsPbcInfo)) { - int ret = Interop.WiFi.ConnectByWpsPbc(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id); - if (ret != (int)WiFiError.None) - { - Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); - } + ret = Interop.WiFi.ConnectByWpsPbc(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id); } else if (info.GetType() == typeof(WpsPinInfo)) { WpsPinInfo pinInfo = (WpsPinInfo)info; - int ret = Interop.WiFi.ConnectByWpsPin(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, pinInfo.GetWpsPin(), _callback_map[id], id); - if (ret != (int)WiFiError.None) + if (pinInfo.GetWpsPin() == null) { - Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); + throw new ArgumentNullException("Wps pin should not be null"); } + + if (pinInfo.GetWpsPin().Length == 0 || pinInfo.GetWpsPin().Length > 8) + { + throw new ArgumentOutOfRangeException("Wps pin should not be empty or more than 7 characters"); + } + + ret = Interop.WiFi.ConnectByWpsPin(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, pinInfo.GetWpsPin(), _callback_map[id], id); + } + + if (ret != (int)WiFiError.None) + { + Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle); } return task.Task; @@ -247,6 +318,20 @@ namespace Tizen.Network.WiFi /// /// A WpsInfo instance which is of type WpsPbcInfo or WpsPinInfo. /// A task which contains Connected access point information. + /// + /// If WpsPinInfo is used, its object has to be constructed with a pin which must be 4 or 8 characters long. + /// + /// http://tizen.org/feature/network.wifi + /// http://tizen.org/privilege/network.set + /// http://tizen.org/privilege/network.get + /// http://tizen.org/privilege/network.profile + /// Thrown when WiFi is not supported. + /// Thrown when permission is denied. + /// Thrown when WpsPinInfo object is constructed with null pin. + /// Thrown when WpsPinInfo object is constructed with pin which is not of 4 or 8 characters long. + /// Thrown when the system is out of memory. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. public static Task ConnectWpsWithoutSsidAsync(WpsInfo info) { TaskCompletionSource task = new TaskCompletionSource(); @@ -271,25 +356,32 @@ namespace Tizen.Network.WiFi }; } + int ret = -1; if (info.GetType() == typeof(WpsPbcInfo)) { - int ret = Interop.WiFi.ConnectByWpsPbcWithoutSsid(WiFiManagerImpl.Instance.GetSafeHandle(), s_callbackMap[id], id); - if (ret != (int)WiFiError.None) - { - Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); - } + ret = Interop.WiFi.ConnectByWpsPbcWithoutSsid(WiFiManagerImpl.Instance.GetSafeHandle(), s_callbackMap[id], id); } else if (info.GetType() == typeof(WpsPinInfo)) { WpsPinInfo pinInfo = (WpsPinInfo)info; - int ret = Interop.WiFi.ConnectByWpsPinWithoutSsid(WiFiManagerImpl.Instance.GetSafeHandle(), pinInfo.GetWpsPin(), s_callbackMap[id], id); - if (ret != (int)WiFiError.None) + if (pinInfo.GetWpsPin() == null) { - Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); + throw new ArgumentNullException("Wps pin should not be null"); } + + if (pinInfo.GetWpsPin().Length != 4 && pinInfo.GetWpsPin().Length != 8) + { + throw new ArgumentOutOfRangeException("Wps pin should be of 4 or 8 characters long"); + } + + ret = Interop.WiFi.ConnectByWpsPinWithoutSsid(WiFiManagerImpl.Instance.GetSafeHandle(), pinInfo.GetWpsPin(), s_callbackMap[id], id); + } + + if (ret != (int)WiFiError.None) + { + Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle()); } return task.Task; @@ -299,9 +391,22 @@ namespace Tizen.Network.WiFi /// Disconnects the access point asynchronously. /// /// A task indicating whether the Disconnect method is done or not. + /// http://tizen.org/feature/network.wifi + /// http://tizen.org/privilege/network.set + /// http://tizen.org/privilege/network.get + /// Thrown when WiFi is not supported. + /// Thrown when permission is denied. + /// Thrown when object instance is disposed or released. + /// Thrown when the system is out of memory. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. public Task DisconnectAsync() { Log.Debug(Globals.LogTag, "DisconnectAsync"); + if (_disposed) + { + throw new ObjectDisposedException("Invalid AP instance (Object may have been disposed or released)"); + } TaskCompletionSource task = new TaskCompletionSource(); IntPtr id; lock (_callback_map) @@ -326,7 +431,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to disconnect wifi, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); + WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle); } return task.Task; } @@ -335,14 +440,27 @@ namespace Tizen.Network.WiFi /// Deletes the information of stored access point and disconnects it when it is connected.
/// If an AP is connected, then connection information will be stored. This information is used when a connection to that AP is established automatically. /// + /// http://tizen.org/feature/network.wifi + /// http://tizen.org/privilege/network.profile + /// http://tizen.org/privilege/network.get + /// Thrown when WiFi is not supported. + /// Thrown when permission is denied. + /// Thrown when object instance is disposed or released. + /// Thrown when the system is out of memory. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. public void ForgetAP() { Log.Debug(Globals.LogTag, "ForgetAP"); + if (_disposed) + { + throw new ObjectDisposedException("Invalid AP instance (Object may have been disposed or released)"); + } int ret = Interop.WiFi.RemoveAP(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle); if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to forget AP, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); + WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle); } } } @@ -376,6 +494,9 @@ namespace Tizen.Network.WiFi /// A public constructor which instantiates WpsPinInfo class with the given pin. /// /// WPS Pin of the access point. + /// + /// Pin should not be null or empty. It should be of less than 8 characters. + /// public WpsPinInfo(string pin) { _pin = pin; diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAddressInformation.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAddressInformation.cs index 716a5df..895ded4 100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAddressInformation.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAddressInformation.cs @@ -54,6 +54,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to set first dns address, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, _handle.DangerousGetHandle()); } } } @@ -81,6 +82,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to set second dns address, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, _handle.DangerousGetHandle()); } } } @@ -108,6 +110,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to set gateway address, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, _handle.DangerousGetHandle()); } } } @@ -135,6 +138,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to set subnet mask, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, _handle.DangerousGetHandle()); } } } @@ -162,6 +166,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to set ip address, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, _handle.DangerousGetHandle()); } } } @@ -184,6 +189,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to set ip config type, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, _handle.DangerousGetHandle()); } } } diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiConfiguration.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiConfiguration.cs index 1f25515..162cd78 100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiConfiguration.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiConfiguration.cs @@ -34,6 +34,7 @@ namespace Tizen.Network.WiFi /// /// The name of access point(AP). /// + /// Name assigned to AP in WiFi configuration. public string Name { get @@ -52,6 +53,7 @@ namespace Tizen.Network.WiFi /// /// The security type of access point(AP). /// + /// Security type of AP in WiFi configuration. public WiFiSecurityType SecurityType { get @@ -69,6 +71,10 @@ namespace Tizen.Network.WiFi /// /// The proxy address. /// + /// Proxy address of the access point. + /// Thrown while setting this property when WiFi is not supported. + /// Thrown while setting this property due to an invalid parameter. + /// Thrown while setting this value due to invalid operation. public string ProxyAddress { get @@ -85,10 +91,15 @@ namespace Tizen.Network.WiFi } set { + if (_disposed) + { + throw new ObjectDisposedException("Invalid WiFiConfiguration instance (Object may have been disposed or released)"); + } int ret = Interop.WiFi.Config.SetProxyAddress(_configHandle, (int)AddressFamily.IPv4, value); if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to set proxy address, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, _configHandle); } } } @@ -96,6 +107,10 @@ namespace Tizen.Network.WiFi /// /// A property check whether the access point(AP) is hidden or not. /// + /// Boolean value indicating whether AP is hidden or not. + /// Thrown while setting this property when WiFi is not supported. + /// Thrown while setting this property due to an invalid parameter. + /// Thrown while setting this value due to invalid operation. public bool IsHidden { get @@ -110,10 +125,15 @@ namespace Tizen.Network.WiFi } set { + if (_disposed) + { + throw new ObjectDisposedException("Invalid WiFiConfiguration instance (Object may have been disposed or released)"); + } int ret = Interop.WiFi.Config.SetHiddenAPProperty(_configHandle, value); if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to set IsHidden, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, _configHandle); } } } @@ -121,6 +141,7 @@ namespace Tizen.Network.WiFi /// /// The EAP Configuration. /// + /// EAP configuration assigned to WiFi. public WiFiEapConfiguration EapConfiguration { get @@ -142,13 +163,28 @@ namespace Tizen.Network.WiFi /// Name of the WiFi. /// Password to access the WiFi. /// Security type of the WiFi. + /// http://tizen.org/feature/network.wifi + /// http://tizen.org/privilege/network.get + /// Thrown when WiFi is not supported. + /// Thrown when permission is denied. + /// Thrown when the object is constructed with name as null. + /// Thrown when the system is out of memory. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when it is failed due to invalid operation. public WiFiConfiguration(string name, string passPhrase, WiFiSecurityType type) { + if (name == null) + { + throw new ArgumentNullException("Name of the WiFi is null"); + } + int ret = Interop.WiFi.Config.Create(WiFiManagerImpl.Instance.GetSafeHandle(), name, passPhrase, (int)type, out _configHandle); if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to create config handle, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle()); } + Interop.WiFi.SafeWiFiConfigHandle configHandle = new Interop.WiFi.SafeWiFiConfigHandle(_configHandle); _eapConfig = new WiFiEapConfiguration(configHandle); } diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiEap.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiEap.cs index dcc174c..203884b 100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiEap.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiEap.cs @@ -33,6 +33,11 @@ namespace Tizen.Network.WiFi /// /// The file path of CA Certificate of EAP. /// + /// CA certification file of EAP. + /// Thrown while setting this value when WiFi is not supported. + /// Thrown while setting this value when file value is null. + /// Thrown while setting this property due to an invalid parameter. + /// Thrown while setting this value due to invalid operation. public string CaCertificationFile { get @@ -42,18 +47,21 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to get caCertFile, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); return ""; } return Marshal.PtrToStringAnsi(strPtr); } set { + if (value == null) + { + throw new ArgumentNullException("File value is null"); + } int ret = Interop.WiFi.AP.SetEapCaCertFile(_apHandle, value); if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to set caCertFile, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); + WiFiErrorFactory.ThrowWiFiException(ret, _apHandle.DangerousGetHandle()); } } } @@ -61,6 +69,10 @@ namespace Tizen.Network.WiFi /// /// The EAP type of wifi. /// + /// Type of EAP. + /// Thrown while setting this value when WiFi is not supported. + /// Thrown while setting this property due to an invalid parameter. + /// Thrown while setting this value due to invalid operation. public WiFiEapType EapType { get @@ -70,7 +82,6 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to get eap type, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); } return (WiFiEapType)type; } @@ -80,7 +91,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to set eap type, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); + WiFiErrorFactory.ThrowWiFiException(ret, _apHandle.DangerousGetHandle()); } } } @@ -88,6 +99,10 @@ namespace Tizen.Network.WiFi /// /// The type of EAP phase2 authentication of Wi-Fi. /// + /// Authentication type of WiFi. + /// Thrown while setting this value when WiFi is not supported. + /// Thrown while setting this property due to an invalid parameter. + /// Thrown while setting this value due to invalid operation. public WiFiAuthenticationType AuthenticationType { get @@ -97,7 +112,6 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to get auth type, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); } return (WiFiAuthenticationType)type; } @@ -107,7 +121,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to set eap auth type, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); + WiFiErrorFactory.ThrowWiFiException(ret, _apHandle.DangerousGetHandle()); } } } @@ -121,6 +135,11 @@ namespace Tizen.Network.WiFi /// Gets the private key file of EAP. /// /// The file path of private key. + /// http://tizen.org/feature/network.wifi + /// Thrown when WiFi is not supported. + /// Thrown when the system is out of memory. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. public string GetPrivateKeyFile() { IntPtr strPtr; @@ -138,8 +157,17 @@ namespace Tizen.Network.WiFi /// /// The file path of private key. /// The password. + /// http://tizen.org/feature/network.wifi + /// Thrown when WiFi is not supported. + /// Thrown when file path of private key is null. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. public void SetPrivateKeyFile(string privateKeyFile, string password) { + if (privateKeyFile == null) + { + throw new ArgumentNullException("File path of private key is null"); + } int ret = Interop.WiFi.AP.SetEapPrivateKeyFile(_apHandle, privateKeyFile, password); if (ret != (int)WiFiError.None) { @@ -152,6 +180,11 @@ namespace Tizen.Network.WiFi /// Gets the Client Certificate of EAP. /// /// The file path of Client Certificate. + /// http://tizen.org/feature/network.wifi + /// Thrown when WiFi is not supported. + /// Thrown when the system is out of memory. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. public string GetClientCertFile() { IntPtr strPtr; @@ -168,8 +201,17 @@ namespace Tizen.Network.WiFi /// Sets the CA Certificate of EAP. /// /// The file path of Client Certificate. + /// http://tizen.org/feature/network.wifi + /// Thrown when WiFi is not supported. + /// Thrown when file path of Client Certificate is null. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. public void SetClientCertFile(string clientCertFile) { + if (clientCertFile == null) + { + throw new ArgumentNullException("File path of Client certificate is null"); + } int ret = Interop.WiFi.AP.SetEapClientCertFile(_apHandle, clientCertFile); if (ret != (int)WiFiError.None) { @@ -182,6 +224,11 @@ namespace Tizen.Network.WiFi /// Gets the username of EAP passphrase. /// /// The user name + /// http://tizen.org/feature/network.wifi + /// Thrown when WiFi is not supported. + /// Thrown when the system is out of memory. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. public string GetUserName() { IntPtr strptr; @@ -199,6 +246,11 @@ namespace Tizen.Network.WiFi /// Returns whether the password is set or not. /// /// True if password is set, false if password is not set. + /// http://tizen.org/feature/network.wifi + /// Thrown when WiFi is not supported. + /// Thrown when the system is out of memory. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. public bool IsPasswordSet() { IntPtr strptr; @@ -216,8 +268,17 @@ namespace Tizen.Network.WiFi /// Sets the user name of EAP. /// /// The user name + /// http://tizen.org/feature/network.wifi + /// Thrown when WiFi is not supported. + /// Thrown when the user name is passed as null. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. public void SetUserName(string userName) { + if (userName == null) + { + throw new ArgumentNullException("User name is null"); + } int ret = Interop.WiFi.AP.SetEapPassphrase(_apHandle, userName, null); if (ret != (int)WiFiError.None) { @@ -230,8 +291,17 @@ namespace Tizen.Network.WiFi /// Sets the password of EAP. /// /// The password + /// http://tizen.org/feature/network.wifi + /// Thrown when WiFi is not supported. + /// Thrown when the password is passed as null. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. public void SetPassword(string password) { + if (password == null) + { + throw new ArgumentNullException("Password is null"); + } int ret = Interop.WiFi.AP.SetEapPassphrase(_apHandle, null, password); if (ret != (int)WiFiError.None) { diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiEapConfiguration.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiEapConfiguration.cs index 5d301d8..ad63382 100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiEapConfiguration.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiEapConfiguration.cs @@ -29,6 +29,10 @@ namespace Tizen.Network.WiFi /// /// The file path of CA Certificate of EAP. /// + /// CA certification file of EAP. + /// Thrown while setting this value when WiFi is not supported. + /// Thrown while setting this property due to an invalid parameter. + /// Thrown while setting this value due to invalid operation. public string CaCertificationFile { get @@ -38,7 +42,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to get caCertFile Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret, _configHandle.DangerousGetHandle()); + return ""; } return Marshal.PtrToStringAnsi(strPtr); } @@ -56,6 +60,10 @@ namespace Tizen.Network.WiFi /// /// The EAP type of wifi. /// + /// Type of EAP. + /// Thrown while setting this value when WiFi is not supported. + /// Thrown while setting this property due to an invalid parameter. + /// Thrown while setting this value due to invalid operation. public WiFiEapType EapType { get @@ -65,7 +73,6 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to eap type Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret, _configHandle.DangerousGetHandle()); } return (WiFiEapType)type; } @@ -83,6 +90,10 @@ namespace Tizen.Network.WiFi /// /// The type of EAP phase2 authentication of Wi-Fi. /// + /// Authentication type of WiFi. + /// Thrown while setting this value when WiFi is not supported. + /// Thrown while setting this property due to an invalid parameter. + /// Thrown while setting this value due to invalid operation. public WiFiAuthenticationType AuthenticationType { get @@ -92,7 +103,6 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to get auth type Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret, _configHandle.DangerousGetHandle()); } return (WiFiAuthenticationType)type; } @@ -110,6 +120,10 @@ namespace Tizen.Network.WiFi /// /// The anonymous identity of access point(AP). /// + /// Represents the anonymous identity of the access point. + /// Thrown while setting this value when WiFi is not supported. + /// Thrown while setting this property due to an invalid parameter. + /// Thrown while setting this value due to invalid operation. public string AnonymousIdentify { get @@ -119,7 +133,6 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to get anonymous identify Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret, _configHandle.DangerousGetHandle()); return ""; } return Marshal.PtrToStringAnsi(strPtr); @@ -138,6 +151,10 @@ namespace Tizen.Network.WiFi /// /// The identity of access point(AP). /// + /// Represents the identity of the access point. + /// Thrown while setting this value when WiFi is not supported. + /// Thrown while setting this property due to an invalid parameter. + /// Thrown while setting this value due to invalid operation. public string Identity { get @@ -147,7 +164,6 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to get identify Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret, _configHandle.DangerousGetHandle()); return ""; } return Marshal.PtrToStringAnsi(strPtr); @@ -166,6 +182,10 @@ namespace Tizen.Network.WiFi /// /// The subject match of access point(AP). /// + /// Represents the subject match of AP. + /// Thrown while setting this value when WiFi is not supported. + /// Thrown while setting this property due to an invalid parameter. + /// Thrown while setting this value due to invalid operation. public string SubjectMatch { get @@ -175,7 +195,6 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to get subject match Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret, _configHandle.DangerousGetHandle()); return ""; } return Marshal.PtrToStringAnsi(strPtr); @@ -200,6 +219,10 @@ namespace Tizen.Network.WiFi /// Gets access point client cert file from configuration. /// /// The certification authority(CA) certificates file of access point. + /// http://tizen.org/feature/network.wifi + /// Thrown when WiFi is not supported. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when method failed due to invalid operation. public string GetClientCertFile() { IntPtr strPtr; @@ -217,6 +240,10 @@ namespace Tizen.Network.WiFi /// /// The private key file. /// The certification authority(CA) certificates file of access point. + /// http://tizen.org/feature/network.wifi + /// Thrown when WiFi is not supported. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when method failed due to invalid operation. public void SetClientCertFile(string privateKey, string clientCert) { int ret = Interop.WiFi.Config.SetEapClientCertFile(_configHandle, privateKey, clientCert); diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiErrorFactory.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiErrorFactory.cs index 93e9f57..1b43a1d 100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiErrorFactory.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiErrorFactory.cs @@ -41,44 +41,60 @@ namespace Tizen.Network.WiFi internal static class WiFiErrorFactory { - static internal void ThrowWiFiException(int e) + static internal void ThrowWiFiException(int e, IntPtr handle) { - ThrowExcption(e, false); + ThrowExcption(e, (handle == IntPtr.Zero), false, ""); } - static internal void ThrowWiFiException(int e, IntPtr handle) + static internal void ThrowWiFiException(int e, IntPtr handle1, IntPtr handle2) + { + ThrowExcption(e, (handle1 == IntPtr.Zero), (handle2 == IntPtr.Zero), ""); + } + + static internal void ThrowWiFiException(int e, string message) + { + ThrowExcption(e, false, false, message); + } + + static internal void ThrowWiFiException(int e, IntPtr handle, string message) + { + ThrowExcption(e, (handle == IntPtr.Zero), false, message); + } + + static internal void ThrowWiFiException(int e, IntPtr handle1, IntPtr handle2, string message) { - ThrowExcption(e, (handle == IntPtr.Zero)); + ThrowExcption(e, (handle1 == IntPtr.Zero), (handle2 == IntPtr.Zero), message); } - static private void ThrowExcption(int e, bool isHandleNull) + static private void ThrowExcption(int e, bool isHandle1Null, bool isHandle2Null, string message) { WiFiError err = (WiFiError)e; if (err == WiFiError.NotSupportedError) { - throw new NotSupportedException("Not Supported"); + throw new NotSupportedException("Unsupported feature http://tizen.org/feature/network.wifi"); } - if (isHandleNull) + if (err == WiFiError.PermissionDeniedError) { - if (err == WiFiError.InvalidParameterError || err == WiFiError.InvalidKeyError) - { - throw new ArgumentException(err.ToString()); - } - else - { - throw new InvalidOperationException("Invalid instance (object may have been disposed or released)"); - } + throw new UnauthorizedAccessException("Permission denied " + message); } - if (err == WiFiError.InvalidParameterError || err == WiFiError.InvalidKeyError) + if (err == WiFiError.OutOfMemoryError) { - throw new ArgumentException(err.ToString()); + throw new OutOfMemoryException("Out of memory"); } - else + + if (err == WiFiError.InvalidParameterError || err == WiFiError.InvalidKeyError) { - throw new InvalidOperationException(err.ToString()); + if (isHandle1Null || isHandle2Null) + { + throw new InvalidOperationException("Invalid instance (object may have been disposed or released)"); + } + + throw new ArgumentException("Invalid parameter"); } + + throw new InvalidOperationException(err.ToString()); } } } diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManager.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManager.cs index 5767956..9df0503 100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManager.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManager.cs @@ -29,6 +29,8 @@ namespace Tizen.Network.WiFi /// /// The local MAC address. /// + /// Represents the mac address of the WiFi. + /// http://tizen.org/privilege/network.get static public string MacAddress { get @@ -40,6 +42,8 @@ namespace Tizen.Network.WiFi /// /// The name of the network interface. /// + /// Interface name of WiFi. + /// http://tizen.org/privilege/network.get static public string InterfaceName { get @@ -51,6 +55,8 @@ namespace Tizen.Network.WiFi /// /// The network connection state. /// + /// Represents the connection state of WiFi. + /// http://tizen.org/privilege/network.get static public WiFiConnectionState ConnectionState { get @@ -62,6 +68,8 @@ namespace Tizen.Network.WiFi /// /// A property to Check whether Wi-Fi is activated. /// + /// Boolean value to check whether WiFi is activated or not. + /// http://tizen.org/privilege/network.get static public bool IsActive { get @@ -135,6 +143,12 @@ namespace Tizen.Network.WiFi /// Gets the result of the scan. /// /// A list of WiFiAP objects. + /// http://tizen.org/feature/network.wifi + /// http://tizen.org/privilege/network.get + /// Thrown when WiFi is not supported. + /// Thrown when permission is denied. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. static public IEnumerable GetFoundAPs() { return WiFiManagerImpl.Instance.GetFoundAPs(); @@ -144,6 +158,12 @@ namespace Tizen.Network.WiFi /// Gets the result of specific AP scan. /// /// A list contains the WiFiAP objects. + /// http://tizen.org/feature/network.wifi + /// http://tizen.org/privilege/network.get + /// Thrown when WiFi is not supported. + /// Thrown when permission is denied. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. static public IEnumerable GetFoundSpecificAPs() { return WiFiManagerImpl.Instance.GetFoundSpecificAPs(); @@ -153,6 +173,13 @@ namespace Tizen.Network.WiFi /// Gets the list of wifi configurations. /// /// A list contains the WiFiConfiguration objects. + /// http://tizen.org/feature/network.wifi + /// http://tizen.org/privilege/network.profile + /// Thrown when WiFi is not supported. + /// Thrown when permission is denied. + /// Thrown when system is out of memory. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. static public IEnumerable GetWiFiConfigurations() { return WiFiManagerImpl.Instance.GetWiFiConfigurations(); @@ -162,6 +189,13 @@ namespace Tizen.Network.WiFi /// Saves Wi-Fi configuration of access point. /// /// The configuration to be stored + /// http://tizen.org/feature/network.wifi + /// http://tizen.org/privilege/network.profile + /// Thrown when WiFi is not supported. + /// Thrown when permission is denied. + /// Thrown when WiFiConfiguration is passed as null. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. static public void SaveWiFiConfiguration(WiFiConfiguration configuration) { WiFiManagerImpl.Instance.SaveWiFiNetworkConfiguration(configuration); @@ -171,6 +205,13 @@ namespace Tizen.Network.WiFi /// Gets the object of the connected WiFiAP. /// /// The connected wifi access point(AP) information. + /// http://tizen.org/feature/network.wifi + /// http://tizen.org/privilege/network.get + /// Thrown when WiFi is not supported. + /// Thrown when permission is denied. + /// Thrown when system is out of memory. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. static public WiFiAP GetConnectedAP() { return WiFiManagerImpl.Instance.GetConnectedAP(); @@ -180,6 +221,13 @@ namespace Tizen.Network.WiFi /// Activates Wi-Fi asynchronously. /// /// A task indicating whether the Activate method is done or not. + /// http://tizen.org/feature/network.wifi + /// http://tizen.org/privilege/network.set + /// http://tizen.org/privilege/network.get + /// Thrown when WiFi is not supported. + /// Thrown when permission is denied. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. static public Task ActivateAsync() { return WiFiManagerImpl.Instance.ActivateAsync(); @@ -189,6 +237,13 @@ namespace Tizen.Network.WiFi /// Activates Wi-Fi asynchronously and displays Wi-Fi picker (popup) when Wi-Fi is not automatically connected. /// /// A task indicating whether the ActivateWithPicker method is done or not. + /// http://tizen.org/feature/network.wifi + /// http://tizen.org/privilege/network.set + /// http://tizen.org/privilege/network.get + /// Thrown when WiFi is not supported. + /// Thrown when permission is denied. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. static public Task ActivateWithPickerAsync() { return WiFiManagerImpl.Instance.ActivateWithWiFiPickerTestedAsync(); @@ -198,6 +253,13 @@ namespace Tizen.Network.WiFi /// Deactivates Wi-Fi asynchronously. /// /// A task indicating whether the Deactivate method is done or not. + /// http://tizen.org/feature/network.wifi + /// http://tizen.org/privilege/network.set + /// http://tizen.org/privilege/network.get + /// Thrown when WiFi is not supported. + /// Thrown when permission is denied. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. static public Task DeactivateAsync() { return WiFiManagerImpl.Instance.DeactivateAsync(); @@ -207,6 +269,13 @@ namespace Tizen.Network.WiFi /// Starts scan asynchronously. /// /// A task indicating whether the Scan method is done or not. + /// http://tizen.org/feature/network.wifi + /// http://tizen.org/privilege/network.set + /// http://tizen.org/privilege/network.get + /// Thrown when WiFi is not supported. + /// Thrown when permission is denied. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. static public Task ScanAsync() { return WiFiManagerImpl.Instance.ScanAsync(); @@ -217,6 +286,13 @@ namespace Tizen.Network.WiFi /// /// A task indicating whether the ScanSpecificAP method is done or not. /// The essid of hidden ap + /// http://tizen.org/feature/network.wifi + /// http://tizen.org/privilege/network.set + /// http://tizen.org/privilege/network.get + /// Thrown when WiFi is not supported. + /// Thrown when permission is denied. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when the method failed due to invalid operation. static public Task ScanSpecificAPAsync(string essid) { return WiFiManagerImpl.Instance.ScanSpecificAPAsync(essid); diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs index 2472463..05fb87c 100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs @@ -153,7 +153,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to initialize wifi, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); + WiFiErrorFactory.ThrowWiFiException(ret, "http://tizen.org/privilege/network.get"); } return handle; } @@ -179,7 +179,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to get all APs, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); + WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle(), "http://tizen.org/privilege/network.get"); } return apList; @@ -207,7 +207,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to get specific APs, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); + WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle(), "http://tizen.org/privilege/network.get"); } return apList; @@ -234,7 +234,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to get configurations, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); + WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle(), "http://tizen.org/privilege/network.profile"); } return configList; @@ -243,12 +243,17 @@ namespace Tizen.Network.WiFi internal void SaveWiFiNetworkConfiguration(WiFiConfiguration config) { Log.Debug(Globals.LogTag, "SaveWiFiNetworkConfiguration"); + if (config == null) + { + throw new ArgumentNullException("WiFi configuration is null"); + } + IntPtr configHandle = config.GetHandle(); int ret = Interop.WiFi.Config.SaveConfiguration(GetSafeHandle(), configHandle); if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to save configuration, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); + WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle(), "http://tizen.org/privilege/network.profile"); } } @@ -260,7 +265,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to connect with AP, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); + WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle(), "http://tizen.org/privilege/network.get"); } WiFiAP ap = new WiFiAP(apHandle); return ap; @@ -293,7 +298,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to activate wifi, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); + WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle()); } return task.Task; } @@ -325,7 +330,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to activate wifi, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); + WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle()); } return task.Task; } @@ -357,7 +362,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to deactivate wifi, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); + WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle()); } return task.Task; } @@ -389,7 +394,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to scan all AP, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); + WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle()); } return task.Task; } @@ -421,7 +426,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to scan with specific AP, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); + WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle()); } return task.Task; } diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetwork.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetwork.cs index 49319bc..896c497 100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetwork.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetwork.cs @@ -35,6 +35,7 @@ namespace Tizen.Network.WiFi /// /// The Extended Service Set Identifier(ESSID). /// + /// Essid of the WiFi. public string Essid { get @@ -60,6 +61,7 @@ namespace Tizen.Network.WiFi /// /// The Basic Service Set Identifier(BSSID). /// + /// Bssid of the WiFi. public string Bssid { get @@ -78,6 +80,7 @@ namespace Tizen.Network.WiFi /// /// The address informaiton for IPv4. /// + /// IP address information for IPv4 type. public IAddressInformation IPv4Setting { get @@ -89,6 +92,7 @@ namespace Tizen.Network.WiFi /// /// The address ainformation for IPv6. /// + /// IP address information for IPv6 type. public IAddressInformation IPv6Setting { get @@ -100,6 +104,10 @@ namespace Tizen.Network.WiFi /// /// The proxy address. /// + /// Represents proxy address of WiFi. + /// Thrown while setting this property when WiFi is not supported. + /// Thrown while setting this property due to an invalid parameter. + /// Thrown while setting this value due to invalid operation. public string ProxyAddress { get @@ -119,6 +127,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to set proxy address, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, _apHandle.DangerousGetHandle()); } } } @@ -126,6 +135,10 @@ namespace Tizen.Network.WiFi /// /// The proxy type(IPv6). /// + /// Represents proxy type of WiFi. + /// Thrown while setting this property when WiFi is not supported. + /// Thrown while setting this property due to an invalid parameter. + /// Thrown while setting this value due to invalid operation. public WiFiProxyType ProxyType { get @@ -144,6 +157,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to set proxy type, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, _apHandle.DangerousGetHandle()); } } } @@ -151,6 +165,7 @@ namespace Tizen.Network.WiFi /// /// The frequency band(MHz). /// + /// Represents the frequency band value. public int Frequency { get @@ -168,6 +183,7 @@ namespace Tizen.Network.WiFi /// /// The Received signal strength indication(RSSI). /// + /// Represents Rssi level of WiFi. public WiFiRssiLevel Rssi { get @@ -185,6 +201,7 @@ namespace Tizen.Network.WiFi /// /// The max speed (Mbps). /// + /// Represents max speed value. public int MaxSpeed { get @@ -202,6 +219,7 @@ namespace Tizen.Network.WiFi /// /// A property to check whether the access point is favorite or not. /// + /// Boolean value to check if the access point is favorite or not. public bool IsFavorite { get @@ -219,6 +237,7 @@ namespace Tizen.Network.WiFi /// /// A property to check whether the access point is passpoint or not. /// + /// Boolean value to check if the access point is passpoint or not. public bool IsPasspoint { get @@ -237,6 +256,7 @@ namespace Tizen.Network.WiFi /// /// The connection state. /// + /// Represents the connection state of WiFi. public WiFiConnectionState ConnectionState { get diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiSecurity.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiSecurity.cs index 47646dd..ae0d4dd 100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiSecurity.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiSecurity.cs @@ -30,6 +30,10 @@ namespace Tizen.Network.WiFi /// /// The type of Wi-Fi security. /// + /// Represents the security type of WiFi. + /// Thrown while setting this property when WiFi is not supported. + /// Thrown while setting this property due to an invalid parameter. + /// Thrown while setting this value due to invalid operation. public WiFiSecurityType SecurityType { get @@ -39,7 +43,6 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to get security type, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); } return (WiFiSecurityType)type; } @@ -49,7 +52,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to set security type, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); + WiFiErrorFactory.ThrowWiFiException(ret, _apHandle.DangerousGetHandle()); } } } @@ -57,6 +60,10 @@ namespace Tizen.Network.WiFi /// /// The type of Wi-Fi encryption /// + /// Represents the encryption type of WiFi. + /// Thrown while setting this property when WiFi is not supported. + /// Thrown while setting this property due to an invalid parameter. + /// Thrown while setting this value due to invalid operation. public WiFiEncryptionType EncryptionType { get @@ -66,7 +73,6 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to get encryption type, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); } return (WiFiEncryptionType)type; } @@ -76,7 +82,7 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to set encryption type, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); + WiFiErrorFactory.ThrowWiFiException(ret, _apHandle.DangerousGetHandle()); } } } @@ -84,6 +90,7 @@ namespace Tizen.Network.WiFi /// /// The EAP information /// + /// Eap information of WiFi. public WiFiEap EapInformation { get @@ -95,6 +102,7 @@ namespace Tizen.Network.WiFi /// /// A property to check whether the passphrase is required or not. /// + /// Boolean value to check if passphrase is required or not. public bool IsPassphraseRequired { get @@ -104,7 +112,6 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to get isPassportRequired, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); } return required; } @@ -113,6 +120,7 @@ namespace Tizen.Network.WiFi /// /// A property to check whether the Wi-Fi Protected Setup(WPS) is supported or not. /// + /// Boolean value to check if wps is supported or not. public bool IsWpsSupported { get @@ -122,7 +130,6 @@ namespace Tizen.Network.WiFi if (ret != (int)WiFiError.None) { Log.Error(Globals.LogTag, "Failed to get isWapSupported, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); } return supported; } @@ -137,8 +144,18 @@ namespace Tizen.Network.WiFi /// /// Sets the passphrase. /// + /// The passphrase of the access point. + /// http://tizen.org/feature/network.wifi + /// Thrown when WiFi is not supported. + /// Thrown when passphrase is passed as null. + /// Thrown when method is failed due to an invalid parameter. + /// Thrown when method failed due to invalid operation. public void SetPassphrase(string passphrase) { + if (passphrase == null) + { + throw new ArgumentNullException("Passphrase is null"); + } int ret = Interop.WiFi.AP.SetPassphrase(_apHandle, passphrase); if (ret != (int)WiFiError.None) { diff --git a/packaging/csapi-network-wifi.spec b/packaging/csapi-network-wifi.spec index 22ea531..83b1803 100755 --- a/packaging/csapi-network-wifi.spec +++ b/packaging/csapi-network-wifi.spec @@ -1,6 +1,6 @@ Name: csapi-network-wifi Summary: Tizen Wi-Fi API for C# -Version: 1.0.15 +Version: 1.0.16 Release: 1 Group: Development/Libraries License: Apache-2.0